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.SessionsClient.ListLocationsPagedResponse; 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.PagedCallSettings; 31 import com.google.api.gax.rpc.StreamingCallSettings; 32 import com.google.api.gax.rpc.TransportChannelProvider; 33 import com.google.api.gax.rpc.UnaryCallSettings; 34 import com.google.cloud.dialogflow.v2beta1.stub.SessionsStubSettings; 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 SessionsClient}. 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 detectIntent 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 * SessionsSettings.Builder sessionsSettingsBuilder = SessionsSettings.newBuilder(); 67 * sessionsSettingsBuilder 68 * .detectIntentSettings() 69 * .setRetrySettings( 70 * sessionsSettingsBuilder 71 * .detectIntentSettings() 72 * .getRetrySettings() 73 * .toBuilder() 74 * .setTotalTimeout(Duration.ofSeconds(30)) 75 * .build()); 76 * SessionsSettings sessionsSettings = sessionsSettingsBuilder.build(); 77 * }</pre> 78 */ 79 @BetaApi 80 @Generated("by gapic-generator-java") 81 public class SessionsSettings extends ClientSettings<SessionsSettings> { 82 83 /** Returns the object with the settings used for calls to detectIntent. */ detectIntentSettings()84 public UnaryCallSettings<DetectIntentRequest, DetectIntentResponse> detectIntentSettings() { 85 return ((SessionsStubSettings) getStubSettings()).detectIntentSettings(); 86 } 87 88 /** Returns the object with the settings used for calls to streamingDetectIntent. */ 89 public StreamingCallSettings<StreamingDetectIntentRequest, StreamingDetectIntentResponse> streamingDetectIntentSettings()90 streamingDetectIntentSettings() { 91 return ((SessionsStubSettings) getStubSettings()).streamingDetectIntentSettings(); 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 ((SessionsStubSettings) 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 ((SessionsStubSettings) getStubSettings()).getLocationSettings(); 103 } 104 create(SessionsStubSettings stub)105 public static final SessionsSettings create(SessionsStubSettings stub) throws IOException { 106 return new SessionsSettings.Builder(stub.toBuilder()).build(); 107 } 108 109 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()110 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 111 return SessionsStubSettings.defaultExecutorProviderBuilder(); 112 } 113 114 /** Returns the default service endpoint. */ getDefaultEndpoint()115 public static String getDefaultEndpoint() { 116 return SessionsStubSettings.getDefaultEndpoint(); 117 } 118 119 /** Returns the default service scopes. */ getDefaultServiceScopes()120 public static List<String> getDefaultServiceScopes() { 121 return SessionsStubSettings.getDefaultServiceScopes(); 122 } 123 124 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()125 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 126 return SessionsStubSettings.defaultCredentialsProviderBuilder(); 127 } 128 129 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()130 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 131 return SessionsStubSettings.defaultGrpcTransportProviderBuilder(); 132 } 133 134 /** Returns a builder for the default REST ChannelProvider for this service. */ 135 @BetaApi 136 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()137 defaultHttpJsonTransportProviderBuilder() { 138 return SessionsStubSettings.defaultHttpJsonTransportProviderBuilder(); 139 } 140 defaultTransportChannelProvider()141 public static TransportChannelProvider defaultTransportChannelProvider() { 142 return SessionsStubSettings.defaultTransportChannelProvider(); 143 } 144 145 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()146 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 147 return SessionsStubSettings.defaultApiClientHeaderProviderBuilder(); 148 } 149 150 /** Returns a new gRPC builder for this class. */ newBuilder()151 public static Builder newBuilder() { 152 return Builder.createDefault(); 153 } 154 155 /** Returns a new REST builder for this class. */ 156 @BetaApi newHttpJsonBuilder()157 public static Builder newHttpJsonBuilder() { 158 return Builder.createHttpJsonDefault(); 159 } 160 161 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)162 public static Builder newBuilder(ClientContext clientContext) { 163 return new Builder(clientContext); 164 } 165 166 /** Returns a builder containing all the values of this settings class. */ toBuilder()167 public Builder toBuilder() { 168 return new Builder(this); 169 } 170 SessionsSettings(Builder settingsBuilder)171 protected SessionsSettings(Builder settingsBuilder) throws IOException { 172 super(settingsBuilder); 173 } 174 175 /** Builder for SessionsSettings. */ 176 public static class Builder extends ClientSettings.Builder<SessionsSettings, Builder> { 177 Builder()178 protected Builder() throws IOException { 179 this(((ClientContext) null)); 180 } 181 Builder(ClientContext clientContext)182 protected Builder(ClientContext clientContext) { 183 super(SessionsStubSettings.newBuilder(clientContext)); 184 } 185 Builder(SessionsSettings settings)186 protected Builder(SessionsSettings settings) { 187 super(settings.getStubSettings().toBuilder()); 188 } 189 Builder(SessionsStubSettings.Builder stubSettings)190 protected Builder(SessionsStubSettings.Builder stubSettings) { 191 super(stubSettings); 192 } 193 createDefault()194 private static Builder createDefault() { 195 return new Builder(SessionsStubSettings.newBuilder()); 196 } 197 198 @BetaApi createHttpJsonDefault()199 private static Builder createHttpJsonDefault() { 200 return new Builder(SessionsStubSettings.newHttpJsonBuilder()); 201 } 202 getStubSettingsBuilder()203 public SessionsStubSettings.Builder getStubSettingsBuilder() { 204 return ((SessionsStubSettings.Builder) getStubSettings()); 205 } 206 207 /** 208 * Applies the given settings updater function to all of the unary API methods in this service. 209 * 210 * <p>Note: This method does not support applying settings to streaming methods. 211 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)212 public Builder applyToAllUnaryMethods( 213 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 214 super.applyToAllUnaryMethods( 215 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 216 return this; 217 } 218 219 /** Returns the builder for the settings used for calls to detectIntent. */ 220 public UnaryCallSettings.Builder<DetectIntentRequest, DetectIntentResponse> detectIntentSettings()221 detectIntentSettings() { 222 return getStubSettingsBuilder().detectIntentSettings(); 223 } 224 225 /** Returns the builder for the settings used for calls to streamingDetectIntent. */ 226 public StreamingCallSettings.Builder< 227 StreamingDetectIntentRequest, StreamingDetectIntentResponse> streamingDetectIntentSettings()228 streamingDetectIntentSettings() { 229 return getStubSettingsBuilder().streamingDetectIntentSettings(); 230 } 231 232 /** Returns the builder for the settings used for calls to listLocations. */ 233 public PagedCallSettings.Builder< 234 ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> listLocationsSettings()235 listLocationsSettings() { 236 return getStubSettingsBuilder().listLocationsSettings(); 237 } 238 239 /** Returns the builder for the settings used for calls to getLocation. */ getLocationSettings()240 public UnaryCallSettings.Builder<GetLocationRequest, Location> getLocationSettings() { 241 return getStubSettingsBuilder().getLocationSettings(); 242 } 243 244 @Override build()245 public SessionsSettings build() throws IOException { 246 return new SessionsSettings(this); 247 } 248 } 249 } 250