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