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