|
| 1 | +/* |
| 2 | + * Copyright 2019 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 | +package com.google.cloud.translate.v3; |
| 17 | + |
| 18 | +import static com.google.cloud.translate.v3.TranslationServiceClient.ListGlossariesPagedResponse; |
| 19 | + |
| 20 | +import com.google.api.core.ApiFunction; |
| 21 | +import com.google.api.core.BetaApi; |
| 22 | +import com.google.api.gax.core.GoogleCredentialsProvider; |
| 23 | +import com.google.api.gax.core.InstantiatingExecutorProvider; |
| 24 | +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; |
| 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.PagedCallSettings; |
| 30 | +import com.google.api.gax.rpc.TransportChannelProvider; |
| 31 | +import com.google.api.gax.rpc.UnaryCallSettings; |
| 32 | +import com.google.cloud.translate.v3.stub.TranslationServiceStubSettings; |
| 33 | +import com.google.longrunning.Operation; |
| 34 | +import java.io.IOException; |
| 35 | +import java.util.List; |
| 36 | +import javax.annotation.Generated; |
| 37 | + |
| 38 | +// AUTO-GENERATED DOCUMENTATION AND CLASS |
| 39 | +/** |
| 40 | + * Settings class to configure an instance of {@link TranslationServiceClient}. |
| 41 | + * |
| 42 | + * <p>The default instance has everything set to sensible defaults: |
| 43 | + * |
| 44 | + * <ul> |
| 45 | + * <li>The default service address (translate.googleapis.com) and default port (443) are used. |
| 46 | + * <li>Credentials are acquired automatically through Application Default Credentials. |
| 47 | + * <li>Retries are configured for idempotent methods but not for non-idempotent methods. |
| 48 | + * </ul> |
| 49 | + * |
| 50 | + * <p>The builder of this class is recursive, so contained classes are themselves builders. When |
| 51 | + * build() is called, the tree of builders is called to create the complete settings object. |
| 52 | + * |
| 53 | + * <p>For example, to set the total timeout of translateText to 30 seconds: |
| 54 | + * |
| 55 | + * <pre> |
| 56 | + * <code> |
| 57 | + * TranslationServiceSettings.Builder translationServiceSettingsBuilder = |
| 58 | + * TranslationServiceSettings.newBuilder(); |
| 59 | + * translationServiceSettingsBuilder.translateTextSettings().getRetrySettings().toBuilder() |
| 60 | + * .setTotalTimeout(Duration.ofSeconds(30)); |
| 61 | + * TranslationServiceSettings translationServiceSettings = translationServiceSettingsBuilder.build(); |
| 62 | + * </code> |
| 63 | + * </pre> |
| 64 | + */ |
| 65 | +@Generated("by gapic-generator") |
| 66 | +@BetaApi |
| 67 | +public class TranslationServiceSettings extends ClientSettings<TranslationServiceSettings> { |
| 68 | + /** Returns the object with the settings used for calls to translateText. */ |
| 69 | + public UnaryCallSettings<TranslateTextRequest, TranslateTextResponse> translateTextSettings() { |
| 70 | + return ((TranslationServiceStubSettings) getStubSettings()).translateTextSettings(); |
| 71 | + } |
| 72 | + |
| 73 | + /** Returns the object with the settings used for calls to detectLanguage. */ |
| 74 | + public UnaryCallSettings<DetectLanguageRequest, DetectLanguageResponse> detectLanguageSettings() { |
| 75 | + return ((TranslationServiceStubSettings) getStubSettings()).detectLanguageSettings(); |
| 76 | + } |
| 77 | + |
| 78 | + /** Returns the object with the settings used for calls to getSupportedLanguages. */ |
| 79 | + public UnaryCallSettings<GetSupportedLanguagesRequest, SupportedLanguages> |
| 80 | + getSupportedLanguagesSettings() { |
| 81 | + return ((TranslationServiceStubSettings) getStubSettings()).getSupportedLanguagesSettings(); |
| 82 | + } |
| 83 | + |
| 84 | + /** Returns the object with the settings used for calls to batchTranslateText. */ |
| 85 | + public UnaryCallSettings<BatchTranslateTextRequest, Operation> batchTranslateTextSettings() { |
| 86 | + return ((TranslationServiceStubSettings) getStubSettings()).batchTranslateTextSettings(); |
| 87 | + } |
| 88 | + |
| 89 | + /** Returns the object with the settings used for calls to batchTranslateText. */ |
| 90 | + @BetaApi( |
| 91 | + "The surface for long-running operations is not stable yet and may change in the future.") |
| 92 | + public OperationCallSettings< |
| 93 | + BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata> |
| 94 | + batchTranslateTextOperationSettings() { |
| 95 | + return ((TranslationServiceStubSettings) getStubSettings()) |
| 96 | + .batchTranslateTextOperationSettings(); |
| 97 | + } |
| 98 | + |
| 99 | + /** Returns the object with the settings used for calls to createGlossary. */ |
| 100 | + public UnaryCallSettings<CreateGlossaryRequest, Operation> createGlossarySettings() { |
| 101 | + return ((TranslationServiceStubSettings) getStubSettings()).createGlossarySettings(); |
| 102 | + } |
| 103 | + |
| 104 | + /** Returns the object with the settings used for calls to createGlossary. */ |
| 105 | + @BetaApi( |
| 106 | + "The surface for long-running operations is not stable yet and may change in the future.") |
| 107 | + public OperationCallSettings<CreateGlossaryRequest, Glossary, CreateGlossaryMetadata> |
| 108 | + createGlossaryOperationSettings() { |
| 109 | + return ((TranslationServiceStubSettings) getStubSettings()).createGlossaryOperationSettings(); |
| 110 | + } |
| 111 | + |
| 112 | + /** Returns the object with the settings used for calls to listGlossaries. */ |
| 113 | + public PagedCallSettings< |
| 114 | + ListGlossariesRequest, ListGlossariesResponse, ListGlossariesPagedResponse> |
| 115 | + listGlossariesSettings() { |
| 116 | + return ((TranslationServiceStubSettings) getStubSettings()).listGlossariesSettings(); |
| 117 | + } |
| 118 | + |
| 119 | + /** Returns the object with the settings used for calls to getGlossary. */ |
| 120 | + public UnaryCallSettings<GetGlossaryRequest, Glossary> getGlossarySettings() { |
| 121 | + return ((TranslationServiceStubSettings) getStubSettings()).getGlossarySettings(); |
| 122 | + } |
| 123 | + |
| 124 | + /** Returns the object with the settings used for calls to deleteGlossary. */ |
| 125 | + public UnaryCallSettings<DeleteGlossaryRequest, Operation> deleteGlossarySettings() { |
| 126 | + return ((TranslationServiceStubSettings) getStubSettings()).deleteGlossarySettings(); |
| 127 | + } |
| 128 | + |
| 129 | + /** Returns the object with the settings used for calls to deleteGlossary. */ |
| 130 | + @BetaApi( |
| 131 | + "The surface for long-running operations is not stable yet and may change in the future.") |
| 132 | + public OperationCallSettings< |
| 133 | + DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata> |
| 134 | + deleteGlossaryOperationSettings() { |
| 135 | + return ((TranslationServiceStubSettings) getStubSettings()).deleteGlossaryOperationSettings(); |
| 136 | + } |
| 137 | + |
| 138 | + public static final TranslationServiceSettings create(TranslationServiceStubSettings stub) |
| 139 | + throws IOException { |
| 140 | + return new TranslationServiceSettings.Builder(stub.toBuilder()).build(); |
| 141 | + } |
| 142 | + |
| 143 | + /** Returns a builder for the default ExecutorProvider for this service. */ |
| 144 | + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { |
| 145 | + return TranslationServiceStubSettings.defaultExecutorProviderBuilder(); |
| 146 | + } |
| 147 | + |
| 148 | + /** Returns the default service endpoint. */ |
| 149 | + public static String getDefaultEndpoint() { |
| 150 | + return TranslationServiceStubSettings.getDefaultEndpoint(); |
| 151 | + } |
| 152 | + |
| 153 | + /** Returns the default service scopes. */ |
| 154 | + public static List<String> getDefaultServiceScopes() { |
| 155 | + return TranslationServiceStubSettings.getDefaultServiceScopes(); |
| 156 | + } |
| 157 | + |
| 158 | + /** Returns a builder for the default credentials for this service. */ |
| 159 | + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { |
| 160 | + return TranslationServiceStubSettings.defaultCredentialsProviderBuilder(); |
| 161 | + } |
| 162 | + |
| 163 | + /** Returns a builder for the default ChannelProvider for this service. */ |
| 164 | + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { |
| 165 | + return TranslationServiceStubSettings.defaultGrpcTransportProviderBuilder(); |
| 166 | + } |
| 167 | + |
| 168 | + public static TransportChannelProvider defaultTransportChannelProvider() { |
| 169 | + return TranslationServiceStubSettings.defaultTransportChannelProvider(); |
| 170 | + } |
| 171 | + |
| 172 | + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") |
| 173 | + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { |
| 174 | + return TranslationServiceStubSettings.defaultApiClientHeaderProviderBuilder(); |
| 175 | + } |
| 176 | + |
| 177 | + /** Returns a new builder for this class. */ |
| 178 | + public static Builder newBuilder() { |
| 179 | + return Builder.createDefault(); |
| 180 | + } |
| 181 | + |
| 182 | + /** Returns a new builder for this class. */ |
| 183 | + public static Builder newBuilder(ClientContext clientContext) { |
| 184 | + return new Builder(clientContext); |
| 185 | + } |
| 186 | + |
| 187 | + /** Returns a builder containing all the values of this settings class. */ |
| 188 | + public Builder toBuilder() { |
| 189 | + return new Builder(this); |
| 190 | + } |
| 191 | + |
| 192 | + protected TranslationServiceSettings(Builder settingsBuilder) throws IOException { |
| 193 | + super(settingsBuilder); |
| 194 | + } |
| 195 | + |
| 196 | + /** Builder for TranslationServiceSettings. */ |
| 197 | + public static class Builder extends ClientSettings.Builder<TranslationServiceSettings, Builder> { |
| 198 | + protected Builder() throws IOException { |
| 199 | + this((ClientContext) null); |
| 200 | + } |
| 201 | + |
| 202 | + protected Builder(ClientContext clientContext) { |
| 203 | + super(TranslationServiceStubSettings.newBuilder(clientContext)); |
| 204 | + } |
| 205 | + |
| 206 | + private static Builder createDefault() { |
| 207 | + return new Builder(TranslationServiceStubSettings.newBuilder()); |
| 208 | + } |
| 209 | + |
| 210 | + protected Builder(TranslationServiceSettings settings) { |
| 211 | + super(settings.getStubSettings().toBuilder()); |
| 212 | + } |
| 213 | + |
| 214 | + protected Builder(TranslationServiceStubSettings.Builder stubSettings) { |
| 215 | + super(stubSettings); |
| 216 | + } |
| 217 | + |
| 218 | + public TranslationServiceStubSettings.Builder getStubSettingsBuilder() { |
| 219 | + return ((TranslationServiceStubSettings.Builder) getStubSettings()); |
| 220 | + } |
| 221 | + |
| 222 | + // NEXT_MAJOR_VER: remove 'throws Exception' |
| 223 | + /** |
| 224 | + * Applies the given settings updater function to all of the unary API methods in this service. |
| 225 | + * |
| 226 | + * <p>Note: This method does not support applying settings to streaming methods. |
| 227 | + */ |
| 228 | + public Builder applyToAllUnaryMethods( |
| 229 | + ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) throws Exception { |
| 230 | + super.applyToAllUnaryMethods( |
| 231 | + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); |
| 232 | + return this; |
| 233 | + } |
| 234 | + |
| 235 | + /** Returns the builder for the settings used for calls to translateText. */ |
| 236 | + public UnaryCallSettings.Builder<TranslateTextRequest, TranslateTextResponse> |
| 237 | + translateTextSettings() { |
| 238 | + return getStubSettingsBuilder().translateTextSettings(); |
| 239 | + } |
| 240 | + |
| 241 | + /** Returns the builder for the settings used for calls to detectLanguage. */ |
| 242 | + public UnaryCallSettings.Builder<DetectLanguageRequest, DetectLanguageResponse> |
| 243 | + detectLanguageSettings() { |
| 244 | + return getStubSettingsBuilder().detectLanguageSettings(); |
| 245 | + } |
| 246 | + |
| 247 | + /** Returns the builder for the settings used for calls to getSupportedLanguages. */ |
| 248 | + public UnaryCallSettings.Builder<GetSupportedLanguagesRequest, SupportedLanguages> |
| 249 | + getSupportedLanguagesSettings() { |
| 250 | + return getStubSettingsBuilder().getSupportedLanguagesSettings(); |
| 251 | + } |
| 252 | + |
| 253 | + /** Returns the builder for the settings used for calls to batchTranslateText. */ |
| 254 | + public UnaryCallSettings.Builder<BatchTranslateTextRequest, Operation> |
| 255 | + batchTranslateTextSettings() { |
| 256 | + return getStubSettingsBuilder().batchTranslateTextSettings(); |
| 257 | + } |
| 258 | + |
| 259 | + /** Returns the builder for the settings used for calls to batchTranslateText. */ |
| 260 | + @BetaApi( |
| 261 | + "The surface for long-running operations is not stable yet and may change in the future.") |
| 262 | + public OperationCallSettings.Builder< |
| 263 | + BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata> |
| 264 | + batchTranslateTextOperationSettings() { |
| 265 | + return getStubSettingsBuilder().batchTranslateTextOperationSettings(); |
| 266 | + } |
| 267 | + |
| 268 | + /** Returns the builder for the settings used for calls to createGlossary. */ |
| 269 | + public UnaryCallSettings.Builder<CreateGlossaryRequest, Operation> createGlossarySettings() { |
| 270 | + return getStubSettingsBuilder().createGlossarySettings(); |
| 271 | + } |
| 272 | + |
| 273 | + /** Returns the builder for the settings used for calls to createGlossary. */ |
| 274 | + @BetaApi( |
| 275 | + "The surface for long-running operations is not stable yet and may change in the future.") |
| 276 | + public OperationCallSettings.Builder<CreateGlossaryRequest, Glossary, CreateGlossaryMetadata> |
| 277 | + createGlossaryOperationSettings() { |
| 278 | + return getStubSettingsBuilder().createGlossaryOperationSettings(); |
| 279 | + } |
| 280 | + |
| 281 | + /** Returns the builder for the settings used for calls to listGlossaries. */ |
| 282 | + public PagedCallSettings.Builder< |
| 283 | + ListGlossariesRequest, ListGlossariesResponse, ListGlossariesPagedResponse> |
| 284 | + listGlossariesSettings() { |
| 285 | + return getStubSettingsBuilder().listGlossariesSettings(); |
| 286 | + } |
| 287 | + |
| 288 | + /** Returns the builder for the settings used for calls to getGlossary. */ |
| 289 | + public UnaryCallSettings.Builder<GetGlossaryRequest, Glossary> getGlossarySettings() { |
| 290 | + return getStubSettingsBuilder().getGlossarySettings(); |
| 291 | + } |
| 292 | + |
| 293 | + /** Returns the builder for the settings used for calls to deleteGlossary. */ |
| 294 | + public UnaryCallSettings.Builder<DeleteGlossaryRequest, Operation> deleteGlossarySettings() { |
| 295 | + return getStubSettingsBuilder().deleteGlossarySettings(); |
| 296 | + } |
| 297 | + |
| 298 | + /** Returns the builder for the settings used for calls to deleteGlossary. */ |
| 299 | + @BetaApi( |
| 300 | + "The surface for long-running operations is not stable yet and may change in the future.") |
| 301 | + public OperationCallSettings.Builder< |
| 302 | + DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata> |
| 303 | + deleteGlossaryOperationSettings() { |
| 304 | + return getStubSettingsBuilder().deleteGlossaryOperationSettings(); |
| 305 | + } |
| 306 | + |
| 307 | + @Override |
| 308 | + public TranslationServiceSettings build() throws IOException { |
| 309 | + return new TranslationServiceSettings(this); |
| 310 | + } |
| 311 | + } |
| 312 | +} |
0 commit comments