• 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.vision.v1p4beta1;
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.vision.v1p4beta1.stub.ImageAnnotatorStubSettings;
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 ImageAnnotatorClient}.
40  *
41  * <p>The default instance has everything set to sensible defaults:
42  *
43  * <ul>
44  *   <li>The default service address (vision.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 batchAnnotateImages 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  * ImageAnnotatorSettings.Builder imageAnnotatorSettingsBuilder =
61  *     ImageAnnotatorSettings.newBuilder();
62  * imageAnnotatorSettingsBuilder
63  *     .batchAnnotateImagesSettings()
64  *     .setRetrySettings(
65  *         imageAnnotatorSettingsBuilder
66  *             .batchAnnotateImagesSettings()
67  *             .getRetrySettings()
68  *             .toBuilder()
69  *             .setTotalTimeout(Duration.ofSeconds(30))
70  *             .build());
71  * ImageAnnotatorSettings imageAnnotatorSettings = imageAnnotatorSettingsBuilder.build();
72  * }</pre>
73  */
74 @BetaApi
75 @Generated("by gapic-generator-java")
76 public class ImageAnnotatorSettings extends ClientSettings<ImageAnnotatorSettings> {
77 
78   /** Returns the object with the settings used for calls to batchAnnotateImages. */
79   public UnaryCallSettings<BatchAnnotateImagesRequest, BatchAnnotateImagesResponse>
batchAnnotateImagesSettings()80       batchAnnotateImagesSettings() {
81     return ((ImageAnnotatorStubSettings) getStubSettings()).batchAnnotateImagesSettings();
82   }
83 
84   /** Returns the object with the settings used for calls to batchAnnotateFiles. */
85   public UnaryCallSettings<BatchAnnotateFilesRequest, BatchAnnotateFilesResponse>
batchAnnotateFilesSettings()86       batchAnnotateFilesSettings() {
87     return ((ImageAnnotatorStubSettings) getStubSettings()).batchAnnotateFilesSettings();
88   }
89 
90   /** Returns the object with the settings used for calls to asyncBatchAnnotateImages. */
91   public UnaryCallSettings<AsyncBatchAnnotateImagesRequest, Operation>
asyncBatchAnnotateImagesSettings()92       asyncBatchAnnotateImagesSettings() {
93     return ((ImageAnnotatorStubSettings) getStubSettings()).asyncBatchAnnotateImagesSettings();
94   }
95 
96   /** Returns the object with the settings used for calls to asyncBatchAnnotateImages. */
97   public OperationCallSettings<
98           AsyncBatchAnnotateImagesRequest, AsyncBatchAnnotateImagesResponse, OperationMetadata>
asyncBatchAnnotateImagesOperationSettings()99       asyncBatchAnnotateImagesOperationSettings() {
100     return ((ImageAnnotatorStubSettings) getStubSettings())
101         .asyncBatchAnnotateImagesOperationSettings();
102   }
103 
104   /** Returns the object with the settings used for calls to asyncBatchAnnotateFiles. */
105   public UnaryCallSettings<AsyncBatchAnnotateFilesRequest, Operation>
asyncBatchAnnotateFilesSettings()106       asyncBatchAnnotateFilesSettings() {
107     return ((ImageAnnotatorStubSettings) getStubSettings()).asyncBatchAnnotateFilesSettings();
108   }
109 
110   /** Returns the object with the settings used for calls to asyncBatchAnnotateFiles. */
111   public OperationCallSettings<
112           AsyncBatchAnnotateFilesRequest, AsyncBatchAnnotateFilesResponse, OperationMetadata>
asyncBatchAnnotateFilesOperationSettings()113       asyncBatchAnnotateFilesOperationSettings() {
114     return ((ImageAnnotatorStubSettings) getStubSettings())
115         .asyncBatchAnnotateFilesOperationSettings();
116   }
117 
create(ImageAnnotatorStubSettings stub)118   public static final ImageAnnotatorSettings create(ImageAnnotatorStubSettings stub)
119       throws IOException {
120     return new ImageAnnotatorSettings.Builder(stub.toBuilder()).build();
121   }
122 
123   /** Returns a builder for the default ExecutorProvider for this service. */
defaultExecutorProviderBuilder()124   public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
125     return ImageAnnotatorStubSettings.defaultExecutorProviderBuilder();
126   }
127 
128   /** Returns the default service endpoint. */
getDefaultEndpoint()129   public static String getDefaultEndpoint() {
130     return ImageAnnotatorStubSettings.getDefaultEndpoint();
131   }
132 
133   /** Returns the default service scopes. */
getDefaultServiceScopes()134   public static List<String> getDefaultServiceScopes() {
135     return ImageAnnotatorStubSettings.getDefaultServiceScopes();
136   }
137 
138   /** Returns a builder for the default credentials for this service. */
defaultCredentialsProviderBuilder()139   public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
140     return ImageAnnotatorStubSettings.defaultCredentialsProviderBuilder();
141   }
142 
143   /** Returns a builder for the default gRPC ChannelProvider for this service. */
defaultGrpcTransportProviderBuilder()144   public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
145     return ImageAnnotatorStubSettings.defaultGrpcTransportProviderBuilder();
146   }
147 
148   /** Returns a builder for the default REST ChannelProvider for this service. */
149   @BetaApi
150   public static InstantiatingHttpJsonChannelProvider.Builder
defaultHttpJsonTransportProviderBuilder()151       defaultHttpJsonTransportProviderBuilder() {
152     return ImageAnnotatorStubSettings.defaultHttpJsonTransportProviderBuilder();
153   }
154 
defaultTransportChannelProvider()155   public static TransportChannelProvider defaultTransportChannelProvider() {
156     return ImageAnnotatorStubSettings.defaultTransportChannelProvider();
157   }
158 
159   @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
defaultApiClientHeaderProviderBuilder()160   public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
161     return ImageAnnotatorStubSettings.defaultApiClientHeaderProviderBuilder();
162   }
163 
164   /** Returns a new gRPC builder for this class. */
newBuilder()165   public static Builder newBuilder() {
166     return Builder.createDefault();
167   }
168 
169   /** Returns a new REST builder for this class. */
170   @BetaApi
newHttpJsonBuilder()171   public static Builder newHttpJsonBuilder() {
172     return Builder.createHttpJsonDefault();
173   }
174 
175   /** Returns a new builder for this class. */
newBuilder(ClientContext clientContext)176   public static Builder newBuilder(ClientContext clientContext) {
177     return new Builder(clientContext);
178   }
179 
180   /** Returns a builder containing all the values of this settings class. */
toBuilder()181   public Builder toBuilder() {
182     return new Builder(this);
183   }
184 
ImageAnnotatorSettings(Builder settingsBuilder)185   protected ImageAnnotatorSettings(Builder settingsBuilder) throws IOException {
186     super(settingsBuilder);
187   }
188 
189   /** Builder for ImageAnnotatorSettings. */
190   public static class Builder extends ClientSettings.Builder<ImageAnnotatorSettings, Builder> {
191 
Builder()192     protected Builder() throws IOException {
193       this(((ClientContext) null));
194     }
195 
Builder(ClientContext clientContext)196     protected Builder(ClientContext clientContext) {
197       super(ImageAnnotatorStubSettings.newBuilder(clientContext));
198     }
199 
Builder(ImageAnnotatorSettings settings)200     protected Builder(ImageAnnotatorSettings settings) {
201       super(settings.getStubSettings().toBuilder());
202     }
203 
Builder(ImageAnnotatorStubSettings.Builder stubSettings)204     protected Builder(ImageAnnotatorStubSettings.Builder stubSettings) {
205       super(stubSettings);
206     }
207 
createDefault()208     private static Builder createDefault() {
209       return new Builder(ImageAnnotatorStubSettings.newBuilder());
210     }
211 
212     @BetaApi
createHttpJsonDefault()213     private static Builder createHttpJsonDefault() {
214       return new Builder(ImageAnnotatorStubSettings.newHttpJsonBuilder());
215     }
216 
getStubSettingsBuilder()217     public ImageAnnotatorStubSettings.Builder getStubSettingsBuilder() {
218       return ((ImageAnnotatorStubSettings.Builder) getStubSettings());
219     }
220 
221     /**
222      * Applies the given settings updater function to all of the unary API methods in this service.
223      *
224      * <p>Note: This method does not support applying settings to streaming methods.
225      */
applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)226     public Builder applyToAllUnaryMethods(
227         ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) {
228       super.applyToAllUnaryMethods(
229           getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater);
230       return this;
231     }
232 
233     /** Returns the builder for the settings used for calls to batchAnnotateImages. */
234     public UnaryCallSettings.Builder<BatchAnnotateImagesRequest, BatchAnnotateImagesResponse>
batchAnnotateImagesSettings()235         batchAnnotateImagesSettings() {
236       return getStubSettingsBuilder().batchAnnotateImagesSettings();
237     }
238 
239     /** Returns the builder for the settings used for calls to batchAnnotateFiles. */
240     public UnaryCallSettings.Builder<BatchAnnotateFilesRequest, BatchAnnotateFilesResponse>
batchAnnotateFilesSettings()241         batchAnnotateFilesSettings() {
242       return getStubSettingsBuilder().batchAnnotateFilesSettings();
243     }
244 
245     /** Returns the builder for the settings used for calls to asyncBatchAnnotateImages. */
246     public UnaryCallSettings.Builder<AsyncBatchAnnotateImagesRequest, Operation>
asyncBatchAnnotateImagesSettings()247         asyncBatchAnnotateImagesSettings() {
248       return getStubSettingsBuilder().asyncBatchAnnotateImagesSettings();
249     }
250 
251     /** Returns the builder for the settings used for calls to asyncBatchAnnotateImages. */
252     public OperationCallSettings.Builder<
253             AsyncBatchAnnotateImagesRequest, AsyncBatchAnnotateImagesResponse, OperationMetadata>
asyncBatchAnnotateImagesOperationSettings()254         asyncBatchAnnotateImagesOperationSettings() {
255       return getStubSettingsBuilder().asyncBatchAnnotateImagesOperationSettings();
256     }
257 
258     /** Returns the builder for the settings used for calls to asyncBatchAnnotateFiles. */
259     public UnaryCallSettings.Builder<AsyncBatchAnnotateFilesRequest, Operation>
asyncBatchAnnotateFilesSettings()260         asyncBatchAnnotateFilesSettings() {
261       return getStubSettingsBuilder().asyncBatchAnnotateFilesSettings();
262     }
263 
264     /** Returns the builder for the settings used for calls to asyncBatchAnnotateFiles. */
265     public OperationCallSettings.Builder<
266             AsyncBatchAnnotateFilesRequest, AsyncBatchAnnotateFilesResponse, OperationMetadata>
asyncBatchAnnotateFilesOperationSettings()267         asyncBatchAnnotateFilesOperationSettings() {
268       return getStubSettingsBuilder().asyncBatchAnnotateFilesOperationSettings();
269     }
270 
271     @Override
build()272     public ImageAnnotatorSettings build() throws IOException {
273       return new ImageAnnotatorSettings(this);
274     }
275   }
276 }
277