|
| 1 | +/* |
| 2 | +* Copyright 2021 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.storage.v2; |
| 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.rpc.ApiClientHeaderProvider; |
| 25 | +import com.google.api.gax.rpc.ClientContext; |
| 26 | +import com.google.api.gax.rpc.ClientSettings; |
| 27 | +import com.google.api.gax.rpc.ServerCallSettings; |
| 28 | +import com.google.api.gax.rpc.CallSettings; |
| 29 | +import com.google.api.gax.rpc.TransportChannelProvider; |
| 30 | +import com.google.api.gax.rpc.UnaryCallSettings; |
| 31 | +import com.google.storage.v2.stub.StorageStubSettings; |
| 32 | +import java.io.IOException; |
| 33 | +import java.util.List; |
| 34 | +import javax.annotation.Generated; |
| 35 | + |
| 36 | +// AUTO-GENERATED DOCUMENTATION AND CLASS. |
| 37 | +/** |
| 38 | +* Settings class to configure an instance of {@link StorageClient}. |
| 39 | +* |
| 40 | +* <p>The default instance has everything set to sensible defaults: |
| 41 | +* |
| 42 | +* <ul> |
| 43 | +* <li>The default service address (storage.googleapis.com) and default port (443) are used. |
| 44 | +* <li>Credentials are acquired automatically through Application Default Credentials. |
| 45 | +* <li>Retries are configured for idempotent methods but not for non-idempotent methods. |
| 46 | +* </ul> |
| 47 | +* |
| 48 | +* <p>The builder of this class is recursive, so contained classes are themselves builders. When |
| 49 | +* build() is called, the tree of builders is called to create the complete settings object. |
| 50 | +* |
| 51 | +* <p>For example, to set the total timeout of startResumableWrite to 30 seconds: |
| 52 | +* |
| 53 | +* <pre>{@code |
| 54 | +* StorageSettings.Builder storageSettingsBuilder = StorageSettings.newBuilder(); |
| 55 | +* storageSettingsBuilder |
| 56 | +* .startResumableWriteSettings() |
| 57 | +* .setRetrySettings( |
| 58 | +* storageSettingsBuilder |
| 59 | +* .startResumableWriteSettings() |
| 60 | +* .getRetrySettings() |
| 61 | +* .toBuilder() |
| 62 | +* .setTotalTimeout(Duration.ofSeconds(30)) |
| 63 | +* .build()); |
| 64 | +* StorageSettings storageSettings = storageSettingsBuilder.build(); |
| 65 | +* }</pre> |
| 66 | +*/ |
| 67 | +@Generated("by gapic-generator-java") |
| 68 | +public class StorageSettings extends ClientSettings<StorageSettings> { |
| 69 | + |
| 70 | +/** Returns the object with the settings used for calls to readObject. */ |
| 71 | +public ServerCallSettings<ReadObjectRequest, ReadObjectResponse> readObjectSettings() { |
| 72 | +return ((StorageStubSettings) getStubSettings()).readObjectSettings(); |
| 73 | +} |
| 74 | + |
| 75 | +/** Returns the object with the settings used for calls to writeObject. */ |
| 76 | +public CallSettings<WriteObjectRequest, WriteObjectResponse> writeObjectSettings() { |
| 77 | +return ((StorageStubSettings) getStubSettings()).writeObjectSettings(); |
| 78 | +} |
| 79 | + |
| 80 | +/** Returns the object with the settings used for calls to startResumableWrite. */ |
| 81 | +public UnaryCallSettings<StartResumableWriteRequest, StartResumableWriteResponse> |
| 82 | +startResumableWriteSettings() { |
| 83 | +return ((StorageStubSettings) getStubSettings()).startResumableWriteSettings(); |
| 84 | +} |
| 85 | + |
| 86 | +/** Returns the object with the settings used for calls to queryWriteStatus. */ |
| 87 | +public UnaryCallSettings<QueryWriteStatusRequest, QueryWriteStatusResponse> |
| 88 | +queryWriteStatusSettings() { |
| 89 | +return ((StorageStubSettings) getStubSettings()).queryWriteStatusSettings(); |
| 90 | +} |
| 91 | + |
| 92 | +public static final StorageSettings create(StorageStubSettings stub) throws IOException { |
| 93 | +return new StorageSettings.Builder(stub.toBuilder()).build(); |
| 94 | +} |
| 95 | + |
| 96 | +/** Returns a builder for the default ExecutorProvider for this service. */ |
| 97 | +public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { |
| 98 | +return StorageStubSettings.defaultExecutorProviderBuilder(); |
| 99 | +} |
| 100 | + |
| 101 | +/** Returns the default service endpoint. */ |
| 102 | +public static String getDefaultEndpoint() { |
| 103 | +return StorageStubSettings.getDefaultEndpoint(); |
| 104 | +} |
| 105 | + |
| 106 | +/** Returns the default service scopes. */ |
| 107 | +public static List<String> getDefaultServiceScopes() { |
| 108 | +return StorageStubSettings.getDefaultServiceScopes(); |
| 109 | +} |
| 110 | + |
| 111 | +/** Returns a builder for the default credentials for this service. */ |
| 112 | +public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { |
| 113 | +return StorageStubSettings.defaultCredentialsProviderBuilder(); |
| 114 | +} |
| 115 | + |
| 116 | +/** Returns a builder for the default ChannelProvider for this service. */ |
| 117 | +public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { |
| 118 | +return StorageStubSettings.defaultGrpcTransportProviderBuilder(); |
| 119 | +} |
| 120 | + |
| 121 | +public static TransportChannelProvider defaultTransportChannelProvider() { |
| 122 | +return StorageStubSettings.defaultTransportChannelProvider(); |
| 123 | +} |
| 124 | + |
| 125 | +@BetaApi("The surface for customizing headers is not stable yet and may change in the future.") |
| 126 | +public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { |
| 127 | +return StorageStubSettings.defaultApiClientHeaderProviderBuilder(); |
| 128 | +} |
| 129 | + |
| 130 | +/** Returns a new builder for this class. */ |
| 131 | +public static Builder newBuilder() { |
| 132 | +return Builder.createDefault(); |
| 133 | +} |
| 134 | + |
| 135 | +/** Returns a new builder for this class. */ |
| 136 | +public static Builder newBuilder(ClientContext clientContext) { |
| 137 | +return new Builder(clientContext); |
| 138 | +} |
| 139 | + |
| 140 | +/** Returns a builder containing all the values of this settings class. */ |
| 141 | +public Builder toBuilder() { |
| 142 | +return new Builder(this); |
| 143 | +} |
| 144 | + |
| 145 | +protected StorageSettings(Builder settingsBuilder) throws IOException { |
| 146 | +super(settingsBuilder); |
| 147 | +} |
| 148 | + |
| 149 | +/** Builder for StorageSettings. */ |
| 150 | +public static class Builder extends ClientSettings.Builder<StorageSettings, Builder> { |
| 151 | + |
| 152 | +protected Builder() throws IOException { |
| 153 | +this(((ClientContext) null)); |
| 154 | +} |
| 155 | + |
| 156 | +protected Builder(ClientContext clientContext) { |
| 157 | +super(StorageStubSettings.newBuilder(clientContext)); |
| 158 | +} |
| 159 | + |
| 160 | +protected Builder(StorageSettings settings) { |
| 161 | +super(settings.getStubSettings().toBuilder()); |
| 162 | +} |
| 163 | + |
| 164 | +protected Builder(StorageStubSettings.Builder stubSettings) { |
| 165 | +super(stubSettings); |
| 166 | +} |
| 167 | + |
| 168 | +private static Builder createDefault() { |
| 169 | +return new Builder(StorageStubSettings.newBuilder()); |
| 170 | +} |
| 171 | + |
| 172 | +public StorageStubSettings.Builder getStubSettingsBuilder() { |
| 173 | +return ((StorageStubSettings.Builder) getStubSettings()); |
| 174 | +} |
| 175 | + |
| 176 | +/** |
| 177 | +* Applies the given settings updater function to all of the unary API methods in this service. |
| 178 | +* |
| 179 | +* <p>Note: This method does not support applying settings to methods. |
| 180 | +*/ |
| 181 | +public Builder applyToAllUnaryMethods( |
| 182 | +ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { |
| 183 | +super.applyToAllUnaryMethods( |
| 184 | +getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); |
| 185 | +return this; |
| 186 | +} |
| 187 | + |
| 188 | +/** Returns the builder for the settings used for calls to readObject. */ |
| 189 | +public ServerCallSettings.Builder<ReadObjectRequest, ReadObjectResponse> |
| 190 | +readObjectSettings() { |
| 191 | +return getStubSettingsBuilder().readObjectSettings(); |
| 192 | +} |
| 193 | + |
| 194 | +/** Returns the builder for the settings used for calls to writeObject. */ |
| 195 | +public CallSettings.Builder<WriteObjectRequest, WriteObjectResponse> |
| 196 | +writeObjectSettings() { |
| 197 | +return getStubSettingsBuilder().writeObjectSettings(); |
| 198 | +} |
| 199 | + |
| 200 | +/** Returns the builder for the settings used for calls to startResumableWrite. */ |
| 201 | +public UnaryCallSettings.Builder<StartResumableWriteRequest, StartResumableWriteResponse> |
| 202 | +startResumableWriteSettings() { |
| 203 | +return getStubSettingsBuilder().startResumableWriteSettings(); |
| 204 | +} |
| 205 | + |
| 206 | +/** Returns the builder for the settings used for calls to queryWriteStatus. */ |
| 207 | +public UnaryCallSettings.Builder<QueryWriteStatusRequest, QueryWriteStatusResponse> |
| 208 | +queryWriteStatusSettings() { |
| 209 | +return getStubSettingsBuilder().queryWriteStatusSettings(); |
| 210 | +} |
| 211 | + |
| 212 | +@Override |
| 213 | +public StorageSettings build() throws IOException { |
| 214 | +return new StorageSettings(this); |
| 215 | +} |
| 216 | +} |
| 217 | +} |
0 commit comments