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