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