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