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