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