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.compute.v1; 18 19 import static com.google.cloud.compute.v1.SnapshotsClient.ListPagedResponse; 20 21 import com.google.api.core.ApiFunction; 22 import com.google.api.core.BetaApi; 23 import com.google.api.gax.core.GoogleCredentialsProvider; 24 import com.google.api.gax.core.InstantiatingExecutorProvider; 25 import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; 26 import com.google.api.gax.rpc.ApiClientHeaderProvider; 27 import com.google.api.gax.rpc.ClientContext; 28 import com.google.api.gax.rpc.ClientSettings; 29 import com.google.api.gax.rpc.OperationCallSettings; 30 import com.google.api.gax.rpc.PagedCallSettings; 31 import com.google.api.gax.rpc.TransportChannelProvider; 32 import com.google.api.gax.rpc.UnaryCallSettings; 33 import com.google.cloud.compute.v1.stub.SnapshotsStubSettings; 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 SnapshotsClient}. 41 * 42 * <p>The default instance has everything set to sensible defaults: 43 * 44 * <ul> 45 * <li>The default service address (compute.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 get to 30 seconds: 54 * 55 * <pre>{@code 56 * // This snippet has been automatically generated and should be regarded as a code template only. 57 * // It will require modifications to work: 58 * // - It may require correct/in-range values for request initialization. 59 * // - It may require specifying regional endpoints when creating the service client as shown in 60 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 61 * SnapshotsSettings.Builder snapshotsSettingsBuilder = SnapshotsSettings.newBuilder(); 62 * snapshotsSettingsBuilder 63 * .getSettings() 64 * .setRetrySettings( 65 * snapshotsSettingsBuilder 66 * .getSettings() 67 * .getRetrySettings() 68 * .toBuilder() 69 * .setTotalTimeout(Duration.ofSeconds(30)) 70 * .build()); 71 * SnapshotsSettings snapshotsSettings = snapshotsSettingsBuilder.build(); 72 * }</pre> 73 */ 74 @Generated("by gapic-generator-java") 75 public class SnapshotsSettings extends ClientSettings<SnapshotsSettings> { 76 77 /** Returns the object with the settings used for calls to delete. */ deleteSettings()78 public UnaryCallSettings<DeleteSnapshotRequest, Operation> deleteSettings() { 79 return ((SnapshotsStubSettings) getStubSettings()).deleteSettings(); 80 } 81 82 /** Returns the object with the settings used for calls to delete. */ 83 public OperationCallSettings<DeleteSnapshotRequest, Operation, Operation> deleteOperationSettings()84 deleteOperationSettings() { 85 return ((SnapshotsStubSettings) getStubSettings()).deleteOperationSettings(); 86 } 87 88 /** Returns the object with the settings used for calls to get. */ getSettings()89 public UnaryCallSettings<GetSnapshotRequest, Snapshot> getSettings() { 90 return ((SnapshotsStubSettings) getStubSettings()).getSettings(); 91 } 92 93 /** Returns the object with the settings used for calls to getIamPolicy. */ getIamPolicySettings()94 public UnaryCallSettings<GetIamPolicySnapshotRequest, Policy> getIamPolicySettings() { 95 return ((SnapshotsStubSettings) getStubSettings()).getIamPolicySettings(); 96 } 97 98 /** Returns the object with the settings used for calls to insert. */ insertSettings()99 public UnaryCallSettings<InsertSnapshotRequest, Operation> insertSettings() { 100 return ((SnapshotsStubSettings) getStubSettings()).insertSettings(); 101 } 102 103 /** Returns the object with the settings used for calls to insert. */ 104 public OperationCallSettings<InsertSnapshotRequest, Operation, Operation> insertOperationSettings()105 insertOperationSettings() { 106 return ((SnapshotsStubSettings) getStubSettings()).insertOperationSettings(); 107 } 108 109 /** Returns the object with the settings used for calls to list. */ listSettings()110 public PagedCallSettings<ListSnapshotsRequest, SnapshotList, ListPagedResponse> listSettings() { 111 return ((SnapshotsStubSettings) getStubSettings()).listSettings(); 112 } 113 114 /** Returns the object with the settings used for calls to setIamPolicy. */ setIamPolicySettings()115 public UnaryCallSettings<SetIamPolicySnapshotRequest, Policy> setIamPolicySettings() { 116 return ((SnapshotsStubSettings) getStubSettings()).setIamPolicySettings(); 117 } 118 119 /** Returns the object with the settings used for calls to setLabels. */ setLabelsSettings()120 public UnaryCallSettings<SetLabelsSnapshotRequest, Operation> setLabelsSettings() { 121 return ((SnapshotsStubSettings) getStubSettings()).setLabelsSettings(); 122 } 123 124 /** Returns the object with the settings used for calls to setLabels. */ 125 public OperationCallSettings<SetLabelsSnapshotRequest, Operation, Operation> setLabelsOperationSettings()126 setLabelsOperationSettings() { 127 return ((SnapshotsStubSettings) getStubSettings()).setLabelsOperationSettings(); 128 } 129 130 /** Returns the object with the settings used for calls to testIamPermissions. */ 131 public UnaryCallSettings<TestIamPermissionsSnapshotRequest, TestPermissionsResponse> testIamPermissionsSettings()132 testIamPermissionsSettings() { 133 return ((SnapshotsStubSettings) getStubSettings()).testIamPermissionsSettings(); 134 } 135 create(SnapshotsStubSettings stub)136 public static final SnapshotsSettings create(SnapshotsStubSettings stub) throws IOException { 137 return new SnapshotsSettings.Builder(stub.toBuilder()).build(); 138 } 139 140 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()141 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 142 return SnapshotsStubSettings.defaultExecutorProviderBuilder(); 143 } 144 145 /** Returns the default service endpoint. */ getDefaultEndpoint()146 public static String getDefaultEndpoint() { 147 return SnapshotsStubSettings.getDefaultEndpoint(); 148 } 149 150 /** Returns the default service scopes. */ getDefaultServiceScopes()151 public static List<String> getDefaultServiceScopes() { 152 return SnapshotsStubSettings.getDefaultServiceScopes(); 153 } 154 155 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()156 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 157 return SnapshotsStubSettings.defaultCredentialsProviderBuilder(); 158 } 159 160 /** Returns a builder for the default ChannelProvider for this service. */ 161 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()162 defaultHttpJsonTransportProviderBuilder() { 163 return SnapshotsStubSettings.defaultHttpJsonTransportProviderBuilder(); 164 } 165 defaultTransportChannelProvider()166 public static TransportChannelProvider defaultTransportChannelProvider() { 167 return SnapshotsStubSettings.defaultTransportChannelProvider(); 168 } 169 170 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()171 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 172 return SnapshotsStubSettings.defaultApiClientHeaderProviderBuilder(); 173 } 174 175 /** Returns a new builder for this class. */ newBuilder()176 public static Builder newBuilder() { 177 return Builder.createDefault(); 178 } 179 180 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)181 public static Builder newBuilder(ClientContext clientContext) { 182 return new Builder(clientContext); 183 } 184 185 /** Returns a builder containing all the values of this settings class. */ toBuilder()186 public Builder toBuilder() { 187 return new Builder(this); 188 } 189 SnapshotsSettings(Builder settingsBuilder)190 protected SnapshotsSettings(Builder settingsBuilder) throws IOException { 191 super(settingsBuilder); 192 } 193 194 /** Builder for SnapshotsSettings. */ 195 public static class Builder extends ClientSettings.Builder<SnapshotsSettings, Builder> { 196 Builder()197 protected Builder() throws IOException { 198 this(((ClientContext) null)); 199 } 200 Builder(ClientContext clientContext)201 protected Builder(ClientContext clientContext) { 202 super(SnapshotsStubSettings.newBuilder(clientContext)); 203 } 204 Builder(SnapshotsSettings settings)205 protected Builder(SnapshotsSettings settings) { 206 super(settings.getStubSettings().toBuilder()); 207 } 208 Builder(SnapshotsStubSettings.Builder stubSettings)209 protected Builder(SnapshotsStubSettings.Builder stubSettings) { 210 super(stubSettings); 211 } 212 createDefault()213 private static Builder createDefault() { 214 return new Builder(SnapshotsStubSettings.newBuilder()); 215 } 216 getStubSettingsBuilder()217 public SnapshotsStubSettings.Builder getStubSettingsBuilder() { 218 return ((SnapshotsStubSettings.Builder) getStubSettings()); 219 } 220 221 /** 222 * Applies the given settings updater function to all of the unary API methods in this service. 223 * 224 * <p>Note: This method does not support applying settings to streaming methods. 225 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)226 public Builder applyToAllUnaryMethods( 227 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 228 super.applyToAllUnaryMethods( 229 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 230 return this; 231 } 232 233 /** Returns the builder for the settings used for calls to delete. */ deleteSettings()234 public UnaryCallSettings.Builder<DeleteSnapshotRequest, Operation> deleteSettings() { 235 return getStubSettingsBuilder().deleteSettings(); 236 } 237 238 /** Returns the builder for the settings used for calls to delete. */ 239 public OperationCallSettings.Builder<DeleteSnapshotRequest, Operation, Operation> deleteOperationSettings()240 deleteOperationSettings() { 241 return getStubSettingsBuilder().deleteOperationSettings(); 242 } 243 244 /** Returns the builder for the settings used for calls to get. */ getSettings()245 public UnaryCallSettings.Builder<GetSnapshotRequest, Snapshot> getSettings() { 246 return getStubSettingsBuilder().getSettings(); 247 } 248 249 /** Returns the builder for the settings used for calls to getIamPolicy. */ getIamPolicySettings()250 public UnaryCallSettings.Builder<GetIamPolicySnapshotRequest, Policy> getIamPolicySettings() { 251 return getStubSettingsBuilder().getIamPolicySettings(); 252 } 253 254 /** Returns the builder for the settings used for calls to insert. */ insertSettings()255 public UnaryCallSettings.Builder<InsertSnapshotRequest, Operation> insertSettings() { 256 return getStubSettingsBuilder().insertSettings(); 257 } 258 259 /** Returns the builder for the settings used for calls to insert. */ 260 public OperationCallSettings.Builder<InsertSnapshotRequest, Operation, Operation> insertOperationSettings()261 insertOperationSettings() { 262 return getStubSettingsBuilder().insertOperationSettings(); 263 } 264 265 /** Returns the builder for the settings used for calls to list. */ 266 public PagedCallSettings.Builder<ListSnapshotsRequest, SnapshotList, ListPagedResponse> listSettings()267 listSettings() { 268 return getStubSettingsBuilder().listSettings(); 269 } 270 271 /** Returns the builder for the settings used for calls to setIamPolicy. */ setIamPolicySettings()272 public UnaryCallSettings.Builder<SetIamPolicySnapshotRequest, Policy> setIamPolicySettings() { 273 return getStubSettingsBuilder().setIamPolicySettings(); 274 } 275 276 /** Returns the builder for the settings used for calls to setLabels. */ setLabelsSettings()277 public UnaryCallSettings.Builder<SetLabelsSnapshotRequest, Operation> setLabelsSettings() { 278 return getStubSettingsBuilder().setLabelsSettings(); 279 } 280 281 /** Returns the builder for the settings used for calls to setLabels. */ 282 public OperationCallSettings.Builder<SetLabelsSnapshotRequest, Operation, Operation> setLabelsOperationSettings()283 setLabelsOperationSettings() { 284 return getStubSettingsBuilder().setLabelsOperationSettings(); 285 } 286 287 /** Returns the builder for the settings used for calls to testIamPermissions. */ 288 public UnaryCallSettings.Builder<TestIamPermissionsSnapshotRequest, TestPermissionsResponse> testIamPermissionsSettings()289 testIamPermissionsSettings() { 290 return getStubSettingsBuilder().testIamPermissionsSettings(); 291 } 292 293 @Override build()294 public SnapshotsSettings build() throws IOException { 295 return new SnapshotsSettings(this); 296 } 297 } 298 } 299