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