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.workflows.v1beta; 18 19 import static com.google.cloud.workflows.v1beta.WorkflowsClient.ListWorkflowsPagedResponse; 20 21 import com.google.api.core.ApiFunction; 22 import com.google.api.core.BetaApi; 23 import com.google.api.gax.core.GoogleCredentialsProvider; 24 import com.google.api.gax.core.InstantiatingExecutorProvider; 25 import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; 26 import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; 27 import com.google.api.gax.rpc.ApiClientHeaderProvider; 28 import com.google.api.gax.rpc.ClientContext; 29 import com.google.api.gax.rpc.ClientSettings; 30 import com.google.api.gax.rpc.OperationCallSettings; 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.workflows.v1beta.stub.WorkflowsStubSettings; 35 import com.google.longrunning.Operation; 36 import com.google.protobuf.Empty; 37 import java.io.IOException; 38 import java.util.List; 39 import javax.annotation.Generated; 40 41 // AUTO-GENERATED DOCUMENTATION AND CLASS. 42 /** 43 * Settings class to configure an instance of {@link WorkflowsClient}. 44 * 45 * <p>The default instance has everything set to sensible defaults: 46 * 47 * <ul> 48 * <li>The default service address (workflows.googleapis.com) and default port (443) are used. 49 * <li>Credentials are acquired automatically through Application Default Credentials. 50 * <li>Retries are configured for idempotent methods but not for non-idempotent methods. 51 * </ul> 52 * 53 * <p>The builder of this class is recursive, so contained classes are themselves builders. When 54 * build() is called, the tree of builders is called to create the complete settings object. 55 * 56 * <p>For example, to set the total timeout of getWorkflow to 30 seconds: 57 * 58 * <pre>{@code 59 * // This snippet has been automatically generated and should be regarded as a code template only. 60 * // It will require modifications to work: 61 * // - It may require correct/in-range values for request initialization. 62 * // - It may require specifying regional endpoints when creating the service client as shown in 63 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 64 * WorkflowsSettings.Builder workflowsSettingsBuilder = WorkflowsSettings.newBuilder(); 65 * workflowsSettingsBuilder 66 * .getWorkflowSettings() 67 * .setRetrySettings( 68 * workflowsSettingsBuilder 69 * .getWorkflowSettings() 70 * .getRetrySettings() 71 * .toBuilder() 72 * .setTotalTimeout(Duration.ofSeconds(30)) 73 * .build()); 74 * WorkflowsSettings workflowsSettings = workflowsSettingsBuilder.build(); 75 * }</pre> 76 */ 77 @BetaApi 78 @Generated("by gapic-generator-java") 79 public class WorkflowsSettings extends ClientSettings<WorkflowsSettings> { 80 81 /** Returns the object with the settings used for calls to listWorkflows. */ 82 public PagedCallSettings<ListWorkflowsRequest, ListWorkflowsResponse, ListWorkflowsPagedResponse> listWorkflowsSettings()83 listWorkflowsSettings() { 84 return ((WorkflowsStubSettings) getStubSettings()).listWorkflowsSettings(); 85 } 86 87 /** Returns the object with the settings used for calls to getWorkflow. */ getWorkflowSettings()88 public UnaryCallSettings<GetWorkflowRequest, Workflow> getWorkflowSettings() { 89 return ((WorkflowsStubSettings) getStubSettings()).getWorkflowSettings(); 90 } 91 92 /** Returns the object with the settings used for calls to createWorkflow. */ createWorkflowSettings()93 public UnaryCallSettings<CreateWorkflowRequest, Operation> createWorkflowSettings() { 94 return ((WorkflowsStubSettings) getStubSettings()).createWorkflowSettings(); 95 } 96 97 /** Returns the object with the settings used for calls to createWorkflow. */ 98 public OperationCallSettings<CreateWorkflowRequest, Workflow, OperationMetadata> createWorkflowOperationSettings()99 createWorkflowOperationSettings() { 100 return ((WorkflowsStubSettings) getStubSettings()).createWorkflowOperationSettings(); 101 } 102 103 /** Returns the object with the settings used for calls to deleteWorkflow. */ deleteWorkflowSettings()104 public UnaryCallSettings<DeleteWorkflowRequest, Operation> deleteWorkflowSettings() { 105 return ((WorkflowsStubSettings) getStubSettings()).deleteWorkflowSettings(); 106 } 107 108 /** Returns the object with the settings used for calls to deleteWorkflow. */ 109 public OperationCallSettings<DeleteWorkflowRequest, Empty, OperationMetadata> deleteWorkflowOperationSettings()110 deleteWorkflowOperationSettings() { 111 return ((WorkflowsStubSettings) getStubSettings()).deleteWorkflowOperationSettings(); 112 } 113 114 /** Returns the object with the settings used for calls to updateWorkflow. */ updateWorkflowSettings()115 public UnaryCallSettings<UpdateWorkflowRequest, Operation> updateWorkflowSettings() { 116 return ((WorkflowsStubSettings) getStubSettings()).updateWorkflowSettings(); 117 } 118 119 /** Returns the object with the settings used for calls to updateWorkflow. */ 120 public OperationCallSettings<UpdateWorkflowRequest, Workflow, OperationMetadata> updateWorkflowOperationSettings()121 updateWorkflowOperationSettings() { 122 return ((WorkflowsStubSettings) getStubSettings()).updateWorkflowOperationSettings(); 123 } 124 create(WorkflowsStubSettings stub)125 public static final WorkflowsSettings create(WorkflowsStubSettings stub) throws IOException { 126 return new WorkflowsSettings.Builder(stub.toBuilder()).build(); 127 } 128 129 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()130 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 131 return WorkflowsStubSettings.defaultExecutorProviderBuilder(); 132 } 133 134 /** Returns the default service endpoint. */ getDefaultEndpoint()135 public static String getDefaultEndpoint() { 136 return WorkflowsStubSettings.getDefaultEndpoint(); 137 } 138 139 /** Returns the default service scopes. */ getDefaultServiceScopes()140 public static List<String> getDefaultServiceScopes() { 141 return WorkflowsStubSettings.getDefaultServiceScopes(); 142 } 143 144 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()145 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 146 return WorkflowsStubSettings.defaultCredentialsProviderBuilder(); 147 } 148 149 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()150 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 151 return WorkflowsStubSettings.defaultGrpcTransportProviderBuilder(); 152 } 153 154 /** Returns a builder for the default REST ChannelProvider for this service. */ 155 @BetaApi 156 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()157 defaultHttpJsonTransportProviderBuilder() { 158 return WorkflowsStubSettings.defaultHttpJsonTransportProviderBuilder(); 159 } 160 defaultTransportChannelProvider()161 public static TransportChannelProvider defaultTransportChannelProvider() { 162 return WorkflowsStubSettings.defaultTransportChannelProvider(); 163 } 164 165 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()166 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 167 return WorkflowsStubSettings.defaultApiClientHeaderProviderBuilder(); 168 } 169 170 /** Returns a new gRPC builder for this class. */ newBuilder()171 public static Builder newBuilder() { 172 return Builder.createDefault(); 173 } 174 175 /** Returns a new REST builder for this class. */ 176 @BetaApi newHttpJsonBuilder()177 public static Builder newHttpJsonBuilder() { 178 return Builder.createHttpJsonDefault(); 179 } 180 181 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)182 public static Builder newBuilder(ClientContext clientContext) { 183 return new Builder(clientContext); 184 } 185 186 /** Returns a builder containing all the values of this settings class. */ toBuilder()187 public Builder toBuilder() { 188 return new Builder(this); 189 } 190 WorkflowsSettings(Builder settingsBuilder)191 protected WorkflowsSettings(Builder settingsBuilder) throws IOException { 192 super(settingsBuilder); 193 } 194 195 /** Builder for WorkflowsSettings. */ 196 public static class Builder extends ClientSettings.Builder<WorkflowsSettings, Builder> { 197 Builder()198 protected Builder() throws IOException { 199 this(((ClientContext) null)); 200 } 201 Builder(ClientContext clientContext)202 protected Builder(ClientContext clientContext) { 203 super(WorkflowsStubSettings.newBuilder(clientContext)); 204 } 205 Builder(WorkflowsSettings settings)206 protected Builder(WorkflowsSettings settings) { 207 super(settings.getStubSettings().toBuilder()); 208 } 209 Builder(WorkflowsStubSettings.Builder stubSettings)210 protected Builder(WorkflowsStubSettings.Builder stubSettings) { 211 super(stubSettings); 212 } 213 createDefault()214 private static Builder createDefault() { 215 return new Builder(WorkflowsStubSettings.newBuilder()); 216 } 217 218 @BetaApi createHttpJsonDefault()219 private static Builder createHttpJsonDefault() { 220 return new Builder(WorkflowsStubSettings.newHttpJsonBuilder()); 221 } 222 getStubSettingsBuilder()223 public WorkflowsStubSettings.Builder getStubSettingsBuilder() { 224 return ((WorkflowsStubSettings.Builder) getStubSettings()); 225 } 226 227 /** 228 * Applies the given settings updater function to all of the unary API methods in this service. 229 * 230 * <p>Note: This method does not support applying settings to streaming methods. 231 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)232 public Builder applyToAllUnaryMethods( 233 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 234 super.applyToAllUnaryMethods( 235 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 236 return this; 237 } 238 239 /** Returns the builder for the settings used for calls to listWorkflows. */ 240 public PagedCallSettings.Builder< 241 ListWorkflowsRequest, ListWorkflowsResponse, ListWorkflowsPagedResponse> listWorkflowsSettings()242 listWorkflowsSettings() { 243 return getStubSettingsBuilder().listWorkflowsSettings(); 244 } 245 246 /** Returns the builder for the settings used for calls to getWorkflow. */ getWorkflowSettings()247 public UnaryCallSettings.Builder<GetWorkflowRequest, Workflow> getWorkflowSettings() { 248 return getStubSettingsBuilder().getWorkflowSettings(); 249 } 250 251 /** Returns the builder for the settings used for calls to createWorkflow. */ createWorkflowSettings()252 public UnaryCallSettings.Builder<CreateWorkflowRequest, Operation> createWorkflowSettings() { 253 return getStubSettingsBuilder().createWorkflowSettings(); 254 } 255 256 /** Returns the builder for the settings used for calls to createWorkflow. */ 257 public OperationCallSettings.Builder<CreateWorkflowRequest, Workflow, OperationMetadata> createWorkflowOperationSettings()258 createWorkflowOperationSettings() { 259 return getStubSettingsBuilder().createWorkflowOperationSettings(); 260 } 261 262 /** Returns the builder for the settings used for calls to deleteWorkflow. */ deleteWorkflowSettings()263 public UnaryCallSettings.Builder<DeleteWorkflowRequest, Operation> deleteWorkflowSettings() { 264 return getStubSettingsBuilder().deleteWorkflowSettings(); 265 } 266 267 /** Returns the builder for the settings used for calls to deleteWorkflow. */ 268 public OperationCallSettings.Builder<DeleteWorkflowRequest, Empty, OperationMetadata> deleteWorkflowOperationSettings()269 deleteWorkflowOperationSettings() { 270 return getStubSettingsBuilder().deleteWorkflowOperationSettings(); 271 } 272 273 /** Returns the builder for the settings used for calls to updateWorkflow. */ updateWorkflowSettings()274 public UnaryCallSettings.Builder<UpdateWorkflowRequest, Operation> updateWorkflowSettings() { 275 return getStubSettingsBuilder().updateWorkflowSettings(); 276 } 277 278 /** Returns the builder for the settings used for calls to updateWorkflow. */ 279 public OperationCallSettings.Builder<UpdateWorkflowRequest, Workflow, OperationMetadata> updateWorkflowOperationSettings()280 updateWorkflowOperationSettings() { 281 return getStubSettingsBuilder().updateWorkflowOperationSettings(); 282 } 283 284 @Override build()285 public WorkflowsSettings build() throws IOException { 286 return new WorkflowsSettings(this); 287 } 288 } 289 } 290