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