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.v2beta1; 18 19 import static com.google.cloud.dialogflow.v2beta1.AgentsClient.ListLocationsPagedResponse; 20 import static com.google.cloud.dialogflow.v2beta1.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.v2beta1.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 @BetaApi 84 @Generated("by gapic-generator-java") 85 public class AgentsSettings extends ClientSettings<AgentsSettings> { 86 87 /** Returns the object with the settings used for calls to getAgent. */ getAgentSettings()88 public UnaryCallSettings<GetAgentRequest, Agent> getAgentSettings() { 89 return ((AgentsStubSettings) getStubSettings()).getAgentSettings(); 90 } 91 92 /** Returns the object with the settings used for calls to setAgent. */ setAgentSettings()93 public UnaryCallSettings<SetAgentRequest, Agent> setAgentSettings() { 94 return ((AgentsStubSettings) getStubSettings()).setAgentSettings(); 95 } 96 97 /** Returns the object with the settings used for calls to deleteAgent. */ deleteAgentSettings()98 public UnaryCallSettings<DeleteAgentRequest, Empty> deleteAgentSettings() { 99 return ((AgentsStubSettings) getStubSettings()).deleteAgentSettings(); 100 } 101 102 /** Returns the object with the settings used for calls to searchAgents. */ 103 public PagedCallSettings<SearchAgentsRequest, SearchAgentsResponse, SearchAgentsPagedResponse> searchAgentsSettings()104 searchAgentsSettings() { 105 return ((AgentsStubSettings) getStubSettings()).searchAgentsSettings(); 106 } 107 108 /** Returns the object with the settings used for calls to trainAgent. */ trainAgentSettings()109 public UnaryCallSettings<TrainAgentRequest, Operation> trainAgentSettings() { 110 return ((AgentsStubSettings) getStubSettings()).trainAgentSettings(); 111 } 112 113 /** Returns the object with the settings used for calls to trainAgent. */ trainAgentOperationSettings()114 public OperationCallSettings<TrainAgentRequest, Empty, Struct> trainAgentOperationSettings() { 115 return ((AgentsStubSettings) getStubSettings()).trainAgentOperationSettings(); 116 } 117 118 /** Returns the object with the settings used for calls to exportAgent. */ exportAgentSettings()119 public UnaryCallSettings<ExportAgentRequest, Operation> exportAgentSettings() { 120 return ((AgentsStubSettings) getStubSettings()).exportAgentSettings(); 121 } 122 123 /** Returns the object with the settings used for calls to exportAgent. */ 124 public OperationCallSettings<ExportAgentRequest, ExportAgentResponse, Struct> exportAgentOperationSettings()125 exportAgentOperationSettings() { 126 return ((AgentsStubSettings) getStubSettings()).exportAgentOperationSettings(); 127 } 128 129 /** Returns the object with the settings used for calls to importAgent. */ importAgentSettings()130 public UnaryCallSettings<ImportAgentRequest, Operation> importAgentSettings() { 131 return ((AgentsStubSettings) getStubSettings()).importAgentSettings(); 132 } 133 134 /** Returns the object with the settings used for calls to importAgent. */ importAgentOperationSettings()135 public OperationCallSettings<ImportAgentRequest, Empty, Struct> importAgentOperationSettings() { 136 return ((AgentsStubSettings) getStubSettings()).importAgentOperationSettings(); 137 } 138 139 /** Returns the object with the settings used for calls to restoreAgent. */ restoreAgentSettings()140 public UnaryCallSettings<RestoreAgentRequest, Operation> restoreAgentSettings() { 141 return ((AgentsStubSettings) getStubSettings()).restoreAgentSettings(); 142 } 143 144 /** Returns the object with the settings used for calls to restoreAgent. */ restoreAgentOperationSettings()145 public OperationCallSettings<RestoreAgentRequest, Empty, Struct> restoreAgentOperationSettings() { 146 return ((AgentsStubSettings) getStubSettings()).restoreAgentOperationSettings(); 147 } 148 149 /** Returns the object with the settings used for calls to getValidationResult. */ 150 public UnaryCallSettings<GetValidationResultRequest, ValidationResult> getValidationResultSettings()151 getValidationResultSettings() { 152 return ((AgentsStubSettings) getStubSettings()).getValidationResultSettings(); 153 } 154 155 /** Returns the object with the settings used for calls to listLocations. */ 156 public PagedCallSettings<ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> listLocationsSettings()157 listLocationsSettings() { 158 return ((AgentsStubSettings) getStubSettings()).listLocationsSettings(); 159 } 160 161 /** Returns the object with the settings used for calls to getLocation. */ getLocationSettings()162 public UnaryCallSettings<GetLocationRequest, Location> getLocationSettings() { 163 return ((AgentsStubSettings) getStubSettings()).getLocationSettings(); 164 } 165 create(AgentsStubSettings stub)166 public static final AgentsSettings create(AgentsStubSettings stub) throws IOException { 167 return new AgentsSettings.Builder(stub.toBuilder()).build(); 168 } 169 170 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()171 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 172 return AgentsStubSettings.defaultExecutorProviderBuilder(); 173 } 174 175 /** Returns the default service endpoint. */ getDefaultEndpoint()176 public static String getDefaultEndpoint() { 177 return AgentsStubSettings.getDefaultEndpoint(); 178 } 179 180 /** Returns the default service scopes. */ getDefaultServiceScopes()181 public static List<String> getDefaultServiceScopes() { 182 return AgentsStubSettings.getDefaultServiceScopes(); 183 } 184 185 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()186 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 187 return AgentsStubSettings.defaultCredentialsProviderBuilder(); 188 } 189 190 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()191 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 192 return AgentsStubSettings.defaultGrpcTransportProviderBuilder(); 193 } 194 195 /** Returns a builder for the default REST ChannelProvider for this service. */ 196 @BetaApi 197 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()198 defaultHttpJsonTransportProviderBuilder() { 199 return AgentsStubSettings.defaultHttpJsonTransportProviderBuilder(); 200 } 201 defaultTransportChannelProvider()202 public static TransportChannelProvider defaultTransportChannelProvider() { 203 return AgentsStubSettings.defaultTransportChannelProvider(); 204 } 205 206 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()207 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 208 return AgentsStubSettings.defaultApiClientHeaderProviderBuilder(); 209 } 210 211 /** Returns a new gRPC builder for this class. */ newBuilder()212 public static Builder newBuilder() { 213 return Builder.createDefault(); 214 } 215 216 /** Returns a new REST builder for this class. */ 217 @BetaApi newHttpJsonBuilder()218 public static Builder newHttpJsonBuilder() { 219 return Builder.createHttpJsonDefault(); 220 } 221 222 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)223 public static Builder newBuilder(ClientContext clientContext) { 224 return new Builder(clientContext); 225 } 226 227 /** Returns a builder containing all the values of this settings class. */ toBuilder()228 public Builder toBuilder() { 229 return new Builder(this); 230 } 231 AgentsSettings(Builder settingsBuilder)232 protected AgentsSettings(Builder settingsBuilder) throws IOException { 233 super(settingsBuilder); 234 } 235 236 /** Builder for AgentsSettings. */ 237 public static class Builder extends ClientSettings.Builder<AgentsSettings, Builder> { 238 Builder()239 protected Builder() throws IOException { 240 this(((ClientContext) null)); 241 } 242 Builder(ClientContext clientContext)243 protected Builder(ClientContext clientContext) { 244 super(AgentsStubSettings.newBuilder(clientContext)); 245 } 246 Builder(AgentsSettings settings)247 protected Builder(AgentsSettings settings) { 248 super(settings.getStubSettings().toBuilder()); 249 } 250 Builder(AgentsStubSettings.Builder stubSettings)251 protected Builder(AgentsStubSettings.Builder stubSettings) { 252 super(stubSettings); 253 } 254 createDefault()255 private static Builder createDefault() { 256 return new Builder(AgentsStubSettings.newBuilder()); 257 } 258 259 @BetaApi createHttpJsonDefault()260 private static Builder createHttpJsonDefault() { 261 return new Builder(AgentsStubSettings.newHttpJsonBuilder()); 262 } 263 getStubSettingsBuilder()264 public AgentsStubSettings.Builder getStubSettingsBuilder() { 265 return ((AgentsStubSettings.Builder) getStubSettings()); 266 } 267 268 /** 269 * Applies the given settings updater function to all of the unary API methods in this service. 270 * 271 * <p>Note: This method does not support applying settings to streaming methods. 272 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)273 public Builder applyToAllUnaryMethods( 274 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 275 super.applyToAllUnaryMethods( 276 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 277 return this; 278 } 279 280 /** Returns the builder for the settings used for calls to getAgent. */ getAgentSettings()281 public UnaryCallSettings.Builder<GetAgentRequest, Agent> getAgentSettings() { 282 return getStubSettingsBuilder().getAgentSettings(); 283 } 284 285 /** Returns the builder for the settings used for calls to setAgent. */ setAgentSettings()286 public UnaryCallSettings.Builder<SetAgentRequest, Agent> setAgentSettings() { 287 return getStubSettingsBuilder().setAgentSettings(); 288 } 289 290 /** Returns the builder for the settings used for calls to deleteAgent. */ deleteAgentSettings()291 public UnaryCallSettings.Builder<DeleteAgentRequest, Empty> deleteAgentSettings() { 292 return getStubSettingsBuilder().deleteAgentSettings(); 293 } 294 295 /** Returns the builder for the settings used for calls to searchAgents. */ 296 public PagedCallSettings.Builder< 297 SearchAgentsRequest, SearchAgentsResponse, SearchAgentsPagedResponse> searchAgentsSettings()298 searchAgentsSettings() { 299 return getStubSettingsBuilder().searchAgentsSettings(); 300 } 301 302 /** Returns the builder for the settings used for calls to trainAgent. */ trainAgentSettings()303 public UnaryCallSettings.Builder<TrainAgentRequest, Operation> trainAgentSettings() { 304 return getStubSettingsBuilder().trainAgentSettings(); 305 } 306 307 /** Returns the builder for the settings used for calls to trainAgent. */ 308 public OperationCallSettings.Builder<TrainAgentRequest, Empty, Struct> trainAgentOperationSettings()309 trainAgentOperationSettings() { 310 return getStubSettingsBuilder().trainAgentOperationSettings(); 311 } 312 313 /** Returns the builder for the settings used for calls to exportAgent. */ exportAgentSettings()314 public UnaryCallSettings.Builder<ExportAgentRequest, Operation> exportAgentSettings() { 315 return getStubSettingsBuilder().exportAgentSettings(); 316 } 317 318 /** Returns the builder for the settings used for calls to exportAgent. */ 319 public OperationCallSettings.Builder<ExportAgentRequest, ExportAgentResponse, Struct> exportAgentOperationSettings()320 exportAgentOperationSettings() { 321 return getStubSettingsBuilder().exportAgentOperationSettings(); 322 } 323 324 /** Returns the builder for the settings used for calls to importAgent. */ importAgentSettings()325 public UnaryCallSettings.Builder<ImportAgentRequest, Operation> importAgentSettings() { 326 return getStubSettingsBuilder().importAgentSettings(); 327 } 328 329 /** Returns the builder for the settings used for calls to importAgent. */ 330 public OperationCallSettings.Builder<ImportAgentRequest, Empty, Struct> importAgentOperationSettings()331 importAgentOperationSettings() { 332 return getStubSettingsBuilder().importAgentOperationSettings(); 333 } 334 335 /** Returns the builder for the settings used for calls to restoreAgent. */ restoreAgentSettings()336 public UnaryCallSettings.Builder<RestoreAgentRequest, Operation> restoreAgentSettings() { 337 return getStubSettingsBuilder().restoreAgentSettings(); 338 } 339 340 /** Returns the builder for the settings used for calls to restoreAgent. */ 341 public OperationCallSettings.Builder<RestoreAgentRequest, Empty, Struct> restoreAgentOperationSettings()342 restoreAgentOperationSettings() { 343 return getStubSettingsBuilder().restoreAgentOperationSettings(); 344 } 345 346 /** Returns the builder for the settings used for calls to getValidationResult. */ 347 public UnaryCallSettings.Builder<GetValidationResultRequest, ValidationResult> getValidationResultSettings()348 getValidationResultSettings() { 349 return getStubSettingsBuilder().getValidationResultSettings(); 350 } 351 352 /** Returns the builder for the settings used for calls to listLocations. */ 353 public PagedCallSettings.Builder< 354 ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> listLocationsSettings()355 listLocationsSettings() { 356 return getStubSettingsBuilder().listLocationsSettings(); 357 } 358 359 /** Returns the builder for the settings used for calls to getLocation. */ getLocationSettings()360 public UnaryCallSettings.Builder<GetLocationRequest, Location> getLocationSettings() { 361 return getStubSettingsBuilder().getLocationSettings(); 362 } 363 364 @Override build()365 public AgentsSettings build() throws IOException { 366 return new AgentsSettings(this); 367 } 368 } 369 } 370