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