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.AnswerRecordsClient.ListAnswerRecordsPagedResponse; 20 import static com.google.cloud.dialogflow.v2.AnswerRecordsClient.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.dialogflow.v2.stub.AnswerRecordsStubSettings; 35 import com.google.cloud.location.GetLocationRequest; 36 import com.google.cloud.location.ListLocationsRequest; 37 import com.google.cloud.location.ListLocationsResponse; 38 import com.google.cloud.location.Location; 39 import java.io.IOException; 40 import java.util.List; 41 import javax.annotation.Generated; 42 43 // AUTO-GENERATED DOCUMENTATION AND CLASS. 44 /** 45 * Settings class to configure an instance of {@link AnswerRecordsClient}. 46 * 47 * <p>The default instance has everything set to sensible defaults: 48 * 49 * <ul> 50 * <li>The default service address (dialogflow.googleapis.com) and default port (443) are used. 51 * <li>Credentials are acquired automatically through Application Default Credentials. 52 * <li>Retries are configured for idempotent methods but not for non-idempotent methods. 53 * </ul> 54 * 55 * <p>The builder of this class is recursive, so contained classes are themselves builders. When 56 * build() is called, the tree of builders is called to create the complete settings object. 57 * 58 * <p>For example, to set the total timeout of updateAnswerRecord to 30 seconds: 59 * 60 * <pre>{@code 61 * // This snippet has been automatically generated and should be regarded as a code template only. 62 * // It will require modifications to work: 63 * // - It may require correct/in-range values for request initialization. 64 * // - It may require specifying regional endpoints when creating the service client as shown in 65 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 66 * AnswerRecordsSettings.Builder answerRecordsSettingsBuilder = AnswerRecordsSettings.newBuilder(); 67 * answerRecordsSettingsBuilder 68 * .updateAnswerRecordSettings() 69 * .setRetrySettings( 70 * answerRecordsSettingsBuilder 71 * .updateAnswerRecordSettings() 72 * .getRetrySettings() 73 * .toBuilder() 74 * .setTotalTimeout(Duration.ofSeconds(30)) 75 * .build()); 76 * AnswerRecordsSettings answerRecordsSettings = answerRecordsSettingsBuilder.build(); 77 * }</pre> 78 */ 79 @Generated("by gapic-generator-java") 80 public class AnswerRecordsSettings extends ClientSettings<AnswerRecordsSettings> { 81 82 /** Returns the object with the settings used for calls to listAnswerRecords. */ 83 public PagedCallSettings< 84 ListAnswerRecordsRequest, ListAnswerRecordsResponse, ListAnswerRecordsPagedResponse> listAnswerRecordsSettings()85 listAnswerRecordsSettings() { 86 return ((AnswerRecordsStubSettings) getStubSettings()).listAnswerRecordsSettings(); 87 } 88 89 /** Returns the object with the settings used for calls to updateAnswerRecord. */ updateAnswerRecordSettings()90 public UnaryCallSettings<UpdateAnswerRecordRequest, AnswerRecord> updateAnswerRecordSettings() { 91 return ((AnswerRecordsStubSettings) getStubSettings()).updateAnswerRecordSettings(); 92 } 93 94 /** Returns the object with the settings used for calls to listLocations. */ 95 public PagedCallSettings<ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> listLocationsSettings()96 listLocationsSettings() { 97 return ((AnswerRecordsStubSettings) getStubSettings()).listLocationsSettings(); 98 } 99 100 /** Returns the object with the settings used for calls to getLocation. */ getLocationSettings()101 public UnaryCallSettings<GetLocationRequest, Location> getLocationSettings() { 102 return ((AnswerRecordsStubSettings) getStubSettings()).getLocationSettings(); 103 } 104 create(AnswerRecordsStubSettings stub)105 public static final AnswerRecordsSettings create(AnswerRecordsStubSettings stub) 106 throws IOException { 107 return new AnswerRecordsSettings.Builder(stub.toBuilder()).build(); 108 } 109 110 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()111 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 112 return AnswerRecordsStubSettings.defaultExecutorProviderBuilder(); 113 } 114 115 /** Returns the default service endpoint. */ getDefaultEndpoint()116 public static String getDefaultEndpoint() { 117 return AnswerRecordsStubSettings.getDefaultEndpoint(); 118 } 119 120 /** Returns the default service scopes. */ getDefaultServiceScopes()121 public static List<String> getDefaultServiceScopes() { 122 return AnswerRecordsStubSettings.getDefaultServiceScopes(); 123 } 124 125 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()126 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 127 return AnswerRecordsStubSettings.defaultCredentialsProviderBuilder(); 128 } 129 130 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()131 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 132 return AnswerRecordsStubSettings.defaultGrpcTransportProviderBuilder(); 133 } 134 135 /** Returns a builder for the default REST ChannelProvider for this service. */ 136 @BetaApi 137 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()138 defaultHttpJsonTransportProviderBuilder() { 139 return AnswerRecordsStubSettings.defaultHttpJsonTransportProviderBuilder(); 140 } 141 defaultTransportChannelProvider()142 public static TransportChannelProvider defaultTransportChannelProvider() { 143 return AnswerRecordsStubSettings.defaultTransportChannelProvider(); 144 } 145 146 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()147 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 148 return AnswerRecordsStubSettings.defaultApiClientHeaderProviderBuilder(); 149 } 150 151 /** Returns a new gRPC builder for this class. */ newBuilder()152 public static Builder newBuilder() { 153 return Builder.createDefault(); 154 } 155 156 /** Returns a new REST builder for this class. */ 157 @BetaApi newHttpJsonBuilder()158 public static Builder newHttpJsonBuilder() { 159 return Builder.createHttpJsonDefault(); 160 } 161 162 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)163 public static Builder newBuilder(ClientContext clientContext) { 164 return new Builder(clientContext); 165 } 166 167 /** Returns a builder containing all the values of this settings class. */ toBuilder()168 public Builder toBuilder() { 169 return new Builder(this); 170 } 171 AnswerRecordsSettings(Builder settingsBuilder)172 protected AnswerRecordsSettings(Builder settingsBuilder) throws IOException { 173 super(settingsBuilder); 174 } 175 176 /** Builder for AnswerRecordsSettings. */ 177 public static class Builder extends ClientSettings.Builder<AnswerRecordsSettings, Builder> { 178 Builder()179 protected Builder() throws IOException { 180 this(((ClientContext) null)); 181 } 182 Builder(ClientContext clientContext)183 protected Builder(ClientContext clientContext) { 184 super(AnswerRecordsStubSettings.newBuilder(clientContext)); 185 } 186 Builder(AnswerRecordsSettings settings)187 protected Builder(AnswerRecordsSettings settings) { 188 super(settings.getStubSettings().toBuilder()); 189 } 190 Builder(AnswerRecordsStubSettings.Builder stubSettings)191 protected Builder(AnswerRecordsStubSettings.Builder stubSettings) { 192 super(stubSettings); 193 } 194 createDefault()195 private static Builder createDefault() { 196 return new Builder(AnswerRecordsStubSettings.newBuilder()); 197 } 198 199 @BetaApi createHttpJsonDefault()200 private static Builder createHttpJsonDefault() { 201 return new Builder(AnswerRecordsStubSettings.newHttpJsonBuilder()); 202 } 203 getStubSettingsBuilder()204 public AnswerRecordsStubSettings.Builder getStubSettingsBuilder() { 205 return ((AnswerRecordsStubSettings.Builder) getStubSettings()); 206 } 207 208 /** 209 * Applies the given settings updater function to all of the unary API methods in this service. 210 * 211 * <p>Note: This method does not support applying settings to streaming methods. 212 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)213 public Builder applyToAllUnaryMethods( 214 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 215 super.applyToAllUnaryMethods( 216 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 217 return this; 218 } 219 220 /** Returns the builder for the settings used for calls to listAnswerRecords. */ 221 public PagedCallSettings.Builder< 222 ListAnswerRecordsRequest, ListAnswerRecordsResponse, ListAnswerRecordsPagedResponse> listAnswerRecordsSettings()223 listAnswerRecordsSettings() { 224 return getStubSettingsBuilder().listAnswerRecordsSettings(); 225 } 226 227 /** Returns the builder for the settings used for calls to updateAnswerRecord. */ 228 public UnaryCallSettings.Builder<UpdateAnswerRecordRequest, AnswerRecord> updateAnswerRecordSettings()229 updateAnswerRecordSettings() { 230 return getStubSettingsBuilder().updateAnswerRecordSettings(); 231 } 232 233 /** Returns the builder for the settings used for calls to listLocations. */ 234 public PagedCallSettings.Builder< 235 ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> listLocationsSettings()236 listLocationsSettings() { 237 return getStubSettingsBuilder().listLocationsSettings(); 238 } 239 240 /** Returns the builder for the settings used for calls to getLocation. */ getLocationSettings()241 public UnaryCallSettings.Builder<GetLocationRequest, Location> getLocationSettings() { 242 return getStubSettingsBuilder().getLocationSettings(); 243 } 244 245 @Override build()246 public AnswerRecordsSettings build() throws IOException { 247 return new AnswerRecordsSettings(this); 248 } 249 } 250 } 251