|
| 1 | +/* |
| 2 | + * Copyright 2025 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.modelarmor.v1beta; |
| 18 | + |
| 19 | +import static com.google.cloud.modelarmor.v1beta.ModelArmorClient.ListLocationsPagedResponse; |
| 20 | +import static com.google.cloud.modelarmor.v1beta.ModelArmorClient.ListTemplatesPagedResponse; |
| 21 | + |
| 22 | +import com.google.api.core.ApiFunction; |
| 23 | +import com.google.api.core.BetaApi; |
| 24 | +import com.google.api.gax.core.GoogleCredentialsProvider; |
| 25 | +import com.google.api.gax.core.InstantiatingExecutorProvider; |
| 26 | +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; |
| 27 | +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; |
| 28 | +import com.google.api.gax.rpc.ApiClientHeaderProvider; |
| 29 | +import com.google.api.gax.rpc.ClientContext; |
| 30 | +import com.google.api.gax.rpc.ClientSettings; |
| 31 | +import com.google.api.gax.rpc.PagedCallSettings; |
| 32 | +import com.google.api.gax.rpc.TransportChannelProvider; |
| 33 | +import com.google.api.gax.rpc.UnaryCallSettings; |
| 34 | +import com.google.cloud.location.GetLocationRequest; |
| 35 | +import com.google.cloud.location.ListLocationsRequest; |
| 36 | +import com.google.cloud.location.ListLocationsResponse; |
| 37 | +import com.google.cloud.location.Location; |
| 38 | +import com.google.cloud.modelarmor.v1beta.stub.ModelArmorStubSettings; |
| 39 | +import com.google.protobuf.Empty; |
| 40 | +import java.io.IOException; |
| 41 | +import java.util.List; |
| 42 | +import javax.annotation.Generated; |
| 43 | + |
| 44 | +// AUTO-GENERATED DOCUMENTATION AND CLASS. |
| 45 | +/** |
| 46 | + * Settings class to configure an instance of {@link ModelArmorClient}. |
| 47 | + * |
| 48 | + * <p>The default instance has everything set to sensible defaults: |
| 49 | + * |
| 50 | + * <ul> |
| 51 | + * <li>The default service address (modelarmor.googleapis.com) and default port (443) are used. |
| 52 | + * <li>Credentials are acquired automatically through Application Default Credentials. |
| 53 | + * <li>Retries are configured for idempotent methods but not for non-idempotent methods. |
| 54 | + * </ul> |
| 55 | + * |
| 56 | + * <p>The builder of this class is recursive, so contained classes are themselves builders. When |
| 57 | + * build() is called, the tree of builders is called to create the complete settings object. |
| 58 | + * |
| 59 | + * <p>For example, to set the |
| 60 | + * [RetrySettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings) |
| 61 | + * of getTemplate: |
| 62 | + * |
| 63 | + * <pre>{@code |
| 64 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 65 | + * // It will require modifications to work: |
| 66 | + * // - It may require correct/in-range values for request initialization. |
| 67 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 68 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 69 | + * ModelArmorSettings.Builder modelArmorSettingsBuilder = ModelArmorSettings.newBuilder(); |
| 70 | + * modelArmorSettingsBuilder |
| 71 | + * .getTemplateSettings() |
| 72 | + * .setRetrySettings( |
| 73 | + * modelArmorSettingsBuilder |
| 74 | + * .getTemplateSettings() |
| 75 | + * .getRetrySettings() |
| 76 | + * .toBuilder() |
| 77 | + * .setInitialRetryDelayDuration(Duration.ofSeconds(1)) |
| 78 | + * .setInitialRpcTimeoutDuration(Duration.ofSeconds(5)) |
| 79 | + * .setMaxAttempts(5) |
| 80 | + * .setMaxRetryDelayDuration(Duration.ofSeconds(30)) |
| 81 | + * .setMaxRpcTimeoutDuration(Duration.ofSeconds(60)) |
| 82 | + * .setRetryDelayMultiplier(1.3) |
| 83 | + * .setRpcTimeoutMultiplier(1.5) |
| 84 | + * .setTotalTimeoutDuration(Duration.ofSeconds(300)) |
| 85 | + * .build()); |
| 86 | + * ModelArmorSettings modelArmorSettings = modelArmorSettingsBuilder.build(); |
| 87 | + * }</pre> |
| 88 | + * |
| 89 | + * Please refer to the [Client Side Retry |
| 90 | + * Guide](https://github.com/googleapis/google-cloud-java/blob/main/docs/client_retries.md) for |
| 91 | + * additional support in setting retries. |
| 92 | + */ |
| 93 | +@BetaApi |
| 94 | +@Generated("by gapic-generator-java") |
| 95 | +public class ModelArmorSettings extends ClientSettings<ModelArmorSettings> { |
| 96 | + |
| 97 | + /** Returns the object with the settings used for calls to listTemplates. */ |
| 98 | + public PagedCallSettings<ListTemplatesRequest, ListTemplatesResponse, ListTemplatesPagedResponse> |
| 99 | + listTemplatesSettings() { |
| 100 | + return ((ModelArmorStubSettings) getStubSettings()).listTemplatesSettings(); |
| 101 | + } |
| 102 | + |
| 103 | + /** Returns the object with the settings used for calls to getTemplate. */ |
| 104 | + public UnaryCallSettings<GetTemplateRequest, Template> getTemplateSettings() { |
| 105 | + return ((ModelArmorStubSettings) getStubSettings()).getTemplateSettings(); |
| 106 | + } |
| 107 | + |
| 108 | + /** Returns the object with the settings used for calls to createTemplate. */ |
| 109 | + public UnaryCallSettings<CreateTemplateRequest, Template> createTemplateSettings() { |
| 110 | + return ((ModelArmorStubSettings) getStubSettings()).createTemplateSettings(); |
| 111 | + } |
| 112 | + |
| 113 | + /** Returns the object with the settings used for calls to updateTemplate. */ |
| 114 | + public UnaryCallSettings<UpdateTemplateRequest, Template> updateTemplateSettings() { |
| 115 | + return ((ModelArmorStubSettings) getStubSettings()).updateTemplateSettings(); |
| 116 | + } |
| 117 | + |
| 118 | + /** Returns the object with the settings used for calls to deleteTemplate. */ |
| 119 | + public UnaryCallSettings<DeleteTemplateRequest, Empty> deleteTemplateSettings() { |
| 120 | + return ((ModelArmorStubSettings) getStubSettings()).deleteTemplateSettings(); |
| 121 | + } |
| 122 | + |
| 123 | + /** Returns the object with the settings used for calls to getFloorSetting. */ |
| 124 | + public UnaryCallSettings<GetFloorSettingRequest, FloorSetting> getFloorSettingSettings() { |
| 125 | + return ((ModelArmorStubSettings) getStubSettings()).getFloorSettingSettings(); |
| 126 | + } |
| 127 | + |
| 128 | + /** Returns the object with the settings used for calls to updateFloorSetting. */ |
| 129 | + public UnaryCallSettings<UpdateFloorSettingRequest, FloorSetting> updateFloorSettingSettings() { |
| 130 | + return ((ModelArmorStubSettings) getStubSettings()).updateFloorSettingSettings(); |
| 131 | + } |
| 132 | + |
| 133 | + /** Returns the object with the settings used for calls to sanitizeUserPrompt. */ |
| 134 | + public UnaryCallSettings<SanitizeUserPromptRequest, SanitizeUserPromptResponse> |
| 135 | + sanitizeUserPromptSettings() { |
| 136 | + return ((ModelArmorStubSettings) getStubSettings()).sanitizeUserPromptSettings(); |
| 137 | + } |
| 138 | + |
| 139 | + /** Returns the object with the settings used for calls to sanitizeModelResponse. */ |
| 140 | + public UnaryCallSettings<SanitizeModelResponseRequest, SanitizeModelResponseResponse> |
| 141 | + sanitizeModelResponseSettings() { |
| 142 | + return ((ModelArmorStubSettings) getStubSettings()).sanitizeModelResponseSettings(); |
| 143 | + } |
| 144 | + |
| 145 | + /** Returns the object with the settings used for calls to listLocations. */ |
| 146 | + public PagedCallSettings<ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> |
| 147 | + listLocationsSettings() { |
| 148 | + return ((ModelArmorStubSettings) getStubSettings()).listLocationsSettings(); |
| 149 | + } |
| 150 | + |
| 151 | + /** Returns the object with the settings used for calls to getLocation. */ |
| 152 | + public UnaryCallSettings<GetLocationRequest, Location> getLocationSettings() { |
| 153 | + return ((ModelArmorStubSettings) getStubSettings()).getLocationSettings(); |
| 154 | + } |
| 155 | + |
| 156 | + public static final ModelArmorSettings create(ModelArmorStubSettings stub) throws IOException { |
| 157 | + return new ModelArmorSettings.Builder(stub.toBuilder()).build(); |
| 158 | + } |
| 159 | + |
| 160 | + /** Returns a builder for the default ExecutorProvider for this service. */ |
| 161 | + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { |
| 162 | + return ModelArmorStubSettings.defaultExecutorProviderBuilder(); |
| 163 | + } |
| 164 | + |
| 165 | + /** Returns the default service endpoint. */ |
| 166 | + public static String getDefaultEndpoint() { |
| 167 | + return ModelArmorStubSettings.getDefaultEndpoint(); |
| 168 | + } |
| 169 | + |
| 170 | + /** Returns the default service scopes. */ |
| 171 | + public static List<String> getDefaultServiceScopes() { |
| 172 | + return ModelArmorStubSettings.getDefaultServiceScopes(); |
| 173 | + } |
| 174 | + |
| 175 | + /** Returns a builder for the default credentials for this service. */ |
| 176 | + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { |
| 177 | + return ModelArmorStubSettings.defaultCredentialsProviderBuilder(); |
| 178 | + } |
| 179 | + |
| 180 | + /** Returns a builder for the default gRPC ChannelProvider for this service. */ |
| 181 | + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { |
| 182 | + return ModelArmorStubSettings.defaultGrpcTransportProviderBuilder(); |
| 183 | + } |
| 184 | + |
| 185 | + /** Returns a builder for the default REST ChannelProvider for this service. */ |
| 186 | + @BetaApi |
| 187 | + public static InstantiatingHttpJsonChannelProvider.Builder |
| 188 | + defaultHttpJsonTransportProviderBuilder() { |
| 189 | + return ModelArmorStubSettings.defaultHttpJsonTransportProviderBuilder(); |
| 190 | + } |
| 191 | + |
| 192 | + public static TransportChannelProvider defaultTransportChannelProvider() { |
| 193 | + return ModelArmorStubSettings.defaultTransportChannelProvider(); |
| 194 | + } |
| 195 | + |
| 196 | + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { |
| 197 | + return ModelArmorStubSettings.defaultApiClientHeaderProviderBuilder(); |
| 198 | + } |
| 199 | + |
| 200 | + /** Returns a new gRPC builder for this class. */ |
| 201 | + public static Builder newBuilder() { |
| 202 | + return Builder.createDefault(); |
| 203 | + } |
| 204 | + |
| 205 | + /** Returns a new REST builder for this class. */ |
| 206 | + public static Builder newHttpJsonBuilder() { |
| 207 | + return Builder.createHttpJsonDefault(); |
| 208 | + } |
| 209 | + |
| 210 | + /** Returns a new builder for this class. */ |
| 211 | + public static Builder newBuilder(ClientContext clientContext) { |
| 212 | + return new Builder(clientContext); |
| 213 | + } |
| 214 | + |
| 215 | + /** Returns a builder containing all the values of this settings class. */ |
| 216 | + public Builder toBuilder() { |
| 217 | + return new Builder(this); |
| 218 | + } |
| 219 | + |
| 220 | + protected ModelArmorSettings(Builder settingsBuilder) throws IOException { |
| 221 | + super(settingsBuilder); |
| 222 | + } |
| 223 | + |
| 224 | + /** Builder for ModelArmorSettings. */ |
| 225 | + public static class Builder extends ClientSettings.Builder<ModelArmorSettings, Builder> { |
| 226 | + |
| 227 | + protected Builder() throws IOException { |
| 228 | + this(((ClientContext) null)); |
| 229 | + } |
| 230 | + |
| 231 | + protected Builder(ClientContext clientContext) { |
| 232 | + super(ModelArmorStubSettings.newBuilder(clientContext)); |
| 233 | + } |
| 234 | + |
| 235 | + protected Builder(ModelArmorSettings settings) { |
| 236 | + super(settings.getStubSettings().toBuilder()); |
| 237 | + } |
| 238 | + |
| 239 | + protected Builder(ModelArmorStubSettings.Builder stubSettings) { |
| 240 | + super(stubSettings); |
| 241 | + } |
| 242 | + |
| 243 | + private static Builder createDefault() { |
| 244 | + return new Builder(ModelArmorStubSettings.newBuilder()); |
| 245 | + } |
| 246 | + |
| 247 | + private static Builder createHttpJsonDefault() { |
| 248 | + return new Builder(ModelArmorStubSettings.newHttpJsonBuilder()); |
| 249 | + } |
| 250 | + |
| 251 | + public ModelArmorStubSettings.Builder getStubSettingsBuilder() { |
| 252 | + return ((ModelArmorStubSettings.Builder) getStubSettings()); |
| 253 | + } |
| 254 | + |
| 255 | + /** |
| 256 | + * Applies the given settings updater function to all of the unary API methods in this service. |
| 257 | + * |
| 258 | + * <p>Note: This method does not support applying settings to streaming methods. |
| 259 | + */ |
| 260 | + public Builder applyToAllUnaryMethods( |
| 261 | + ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { |
| 262 | + super.applyToAllUnaryMethods( |
| 263 | + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); |
| 264 | + return this; |
| 265 | + } |
| 266 | + |
| 267 | + /** Returns the builder for the settings used for calls to listTemplates. */ |
| 268 | + public PagedCallSettings.Builder< |
| 269 | + ListTemplatesRequest, ListTemplatesResponse, ListTemplatesPagedResponse> |
| 270 | + listTemplatesSettings() { |
| 271 | + return getStubSettingsBuilder().listTemplatesSettings(); |
| 272 | + } |
| 273 | + |
| 274 | + /** Returns the builder for the settings used for calls to getTemplate. */ |
| 275 | + public UnaryCallSettings.Builder<GetTemplateRequest, Template> getTemplateSettings() { |
| 276 | + return getStubSettingsBuilder().getTemplateSettings(); |
| 277 | + } |
| 278 | + |
| 279 | + /** Returns the builder for the settings used for calls to createTemplate. */ |
| 280 | + public UnaryCallSettings.Builder<CreateTemplateRequest, Template> createTemplateSettings() { |
| 281 | + return getStubSettingsBuilder().createTemplateSettings(); |
| 282 | + } |
| 283 | + |
| 284 | + /** Returns the builder for the settings used for calls to updateTemplate. */ |
| 285 | + public UnaryCallSettings.Builder<UpdateTemplateRequest, Template> updateTemplateSettings() { |
| 286 | + return getStubSettingsBuilder().updateTemplateSettings(); |
| 287 | + } |
| 288 | + |
| 289 | + /** Returns the builder for the settings used for calls to deleteTemplate. */ |
| 290 | + public UnaryCallSettings.Builder<DeleteTemplateRequest, Empty> deleteTemplateSettings() { |
| 291 | + return getStubSettingsBuilder().deleteTemplateSettings(); |
| 292 | + } |
| 293 | + |
| 294 | + /** Returns the builder for the settings used for calls to getFloorSetting. */ |
| 295 | + public UnaryCallSettings.Builder<GetFloorSettingRequest, FloorSetting> |
| 296 | + getFloorSettingSettings() { |
| 297 | + return getStubSettingsBuilder().getFloorSettingSettings(); |
| 298 | + } |
| 299 | + |
| 300 | + /** Returns the builder for the settings used for calls to updateFloorSetting. */ |
| 301 | + public UnaryCallSettings.Builder<UpdateFloorSettingRequest, FloorSetting> |
| 302 | + updateFloorSettingSettings() { |
| 303 | + return getStubSettingsBuilder().updateFloorSettingSettings(); |
| 304 | + } |
| 305 | + |
| 306 | + /** Returns the builder for the settings used for calls to sanitizeUserPrompt. */ |
| 307 | + public UnaryCallSettings.Builder<SanitizeUserPromptRequest, SanitizeUserPromptResponse> |
| 308 | + sanitizeUserPromptSettings() { |
| 309 | + return getStubSettingsBuilder().sanitizeUserPromptSettings(); |
| 310 | + } |
| 311 | + |
| 312 | + /** Returns the builder for the settings used for calls to sanitizeModelResponse. */ |
| 313 | + public UnaryCallSettings.Builder<SanitizeModelResponseRequest, SanitizeModelResponseResponse> |
| 314 | + sanitizeModelResponseSettings() { |
| 315 | + return getStubSettingsBuilder().sanitizeModelResponseSettings(); |
| 316 | + } |
| 317 | + |
| 318 | + /** Returns the builder for the settings used for calls to listLocations. */ |
| 319 | + public PagedCallSettings.Builder< |
| 320 | + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> |
| 321 | + listLocationsSettings() { |
| 322 | + return getStubSettingsBuilder().listLocationsSettings(); |
| 323 | + } |
| 324 | + |
| 325 | + /** Returns the builder for the settings used for calls to getLocation. */ |
| 326 | + public UnaryCallSettings.Builder<GetLocationRequest, Location> getLocationSettings() { |
| 327 | + return getStubSettingsBuilder().getLocationSettings(); |
| 328 | + } |
| 329 | + |
| 330 | + @Override |
| 331 | + public ModelArmorSettings build() throws IOException { |
| 332 | + return new ModelArmorSettings(this); |
| 333 | + } |
| 334 | + } |
| 335 | +} |
0 commit comments