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.GlobalAddressesClient.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.GlobalAddressesStubSettings; 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 GlobalAddressesClient}. 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 * GlobalAddressesSettings.Builder globalAddressesSettingsBuilder = 62 * GlobalAddressesSettings.newBuilder(); 63 * globalAddressesSettingsBuilder 64 * .getSettings() 65 * .setRetrySettings( 66 * globalAddressesSettingsBuilder 67 * .getSettings() 68 * .getRetrySettings() 69 * .toBuilder() 70 * .setTotalTimeout(Duration.ofSeconds(30)) 71 * .build()); 72 * GlobalAddressesSettings globalAddressesSettings = globalAddressesSettingsBuilder.build(); 73 * }</pre> 74 */ 75 @Generated("by gapic-generator-java") 76 public class GlobalAddressesSettings extends ClientSettings<GlobalAddressesSettings> { 77 78 /** Returns the object with the settings used for calls to delete. */ deleteSettings()79 public UnaryCallSettings<DeleteGlobalAddressRequest, Operation> deleteSettings() { 80 return ((GlobalAddressesStubSettings) getStubSettings()).deleteSettings(); 81 } 82 83 /** Returns the object with the settings used for calls to delete. */ 84 public OperationCallSettings<DeleteGlobalAddressRequest, Operation, Operation> deleteOperationSettings()85 deleteOperationSettings() { 86 return ((GlobalAddressesStubSettings) getStubSettings()).deleteOperationSettings(); 87 } 88 89 /** Returns the object with the settings used for calls to get. */ getSettings()90 public UnaryCallSettings<GetGlobalAddressRequest, Address> getSettings() { 91 return ((GlobalAddressesStubSettings) getStubSettings()).getSettings(); 92 } 93 94 /** Returns the object with the settings used for calls to insert. */ insertSettings()95 public UnaryCallSettings<InsertGlobalAddressRequest, Operation> insertSettings() { 96 return ((GlobalAddressesStubSettings) getStubSettings()).insertSettings(); 97 } 98 99 /** Returns the object with the settings used for calls to insert. */ 100 public OperationCallSettings<InsertGlobalAddressRequest, Operation, Operation> insertOperationSettings()101 insertOperationSettings() { 102 return ((GlobalAddressesStubSettings) getStubSettings()).insertOperationSettings(); 103 } 104 105 /** Returns the object with the settings used for calls to list. */ 106 public PagedCallSettings<ListGlobalAddressesRequest, AddressList, ListPagedResponse> listSettings()107 listSettings() { 108 return ((GlobalAddressesStubSettings) getStubSettings()).listSettings(); 109 } 110 111 /** Returns the object with the settings used for calls to setLabels. */ setLabelsSettings()112 public UnaryCallSettings<SetLabelsGlobalAddressRequest, Operation> setLabelsSettings() { 113 return ((GlobalAddressesStubSettings) getStubSettings()).setLabelsSettings(); 114 } 115 116 /** Returns the object with the settings used for calls to setLabels. */ 117 public OperationCallSettings<SetLabelsGlobalAddressRequest, Operation, Operation> setLabelsOperationSettings()118 setLabelsOperationSettings() { 119 return ((GlobalAddressesStubSettings) getStubSettings()).setLabelsOperationSettings(); 120 } 121 create(GlobalAddressesStubSettings stub)122 public static final GlobalAddressesSettings create(GlobalAddressesStubSettings stub) 123 throws IOException { 124 return new GlobalAddressesSettings.Builder(stub.toBuilder()).build(); 125 } 126 127 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()128 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 129 return GlobalAddressesStubSettings.defaultExecutorProviderBuilder(); 130 } 131 132 /** Returns the default service endpoint. */ getDefaultEndpoint()133 public static String getDefaultEndpoint() { 134 return GlobalAddressesStubSettings.getDefaultEndpoint(); 135 } 136 137 /** Returns the default service scopes. */ getDefaultServiceScopes()138 public static List<String> getDefaultServiceScopes() { 139 return GlobalAddressesStubSettings.getDefaultServiceScopes(); 140 } 141 142 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()143 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 144 return GlobalAddressesStubSettings.defaultCredentialsProviderBuilder(); 145 } 146 147 /** Returns a builder for the default ChannelProvider for this service. */ 148 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()149 defaultHttpJsonTransportProviderBuilder() { 150 return GlobalAddressesStubSettings.defaultHttpJsonTransportProviderBuilder(); 151 } 152 defaultTransportChannelProvider()153 public static TransportChannelProvider defaultTransportChannelProvider() { 154 return GlobalAddressesStubSettings.defaultTransportChannelProvider(); 155 } 156 157 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()158 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 159 return GlobalAddressesStubSettings.defaultApiClientHeaderProviderBuilder(); 160 } 161 162 /** Returns a new builder for this class. */ newBuilder()163 public static Builder newBuilder() { 164 return Builder.createDefault(); 165 } 166 167 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)168 public static Builder newBuilder(ClientContext clientContext) { 169 return new Builder(clientContext); 170 } 171 172 /** Returns a builder containing all the values of this settings class. */ toBuilder()173 public Builder toBuilder() { 174 return new Builder(this); 175 } 176 GlobalAddressesSettings(Builder settingsBuilder)177 protected GlobalAddressesSettings(Builder settingsBuilder) throws IOException { 178 super(settingsBuilder); 179 } 180 181 /** Builder for GlobalAddressesSettings. */ 182 public static class Builder extends ClientSettings.Builder<GlobalAddressesSettings, Builder> { 183 Builder()184 protected Builder() throws IOException { 185 this(((ClientContext) null)); 186 } 187 Builder(ClientContext clientContext)188 protected Builder(ClientContext clientContext) { 189 super(GlobalAddressesStubSettings.newBuilder(clientContext)); 190 } 191 Builder(GlobalAddressesSettings settings)192 protected Builder(GlobalAddressesSettings settings) { 193 super(settings.getStubSettings().toBuilder()); 194 } 195 Builder(GlobalAddressesStubSettings.Builder stubSettings)196 protected Builder(GlobalAddressesStubSettings.Builder stubSettings) { 197 super(stubSettings); 198 } 199 createDefault()200 private static Builder createDefault() { 201 return new Builder(GlobalAddressesStubSettings.newBuilder()); 202 } 203 getStubSettingsBuilder()204 public GlobalAddressesStubSettings.Builder getStubSettingsBuilder() { 205 return ((GlobalAddressesStubSettings.Builder) getStubSettings()); 206 } 207 208 /** 209 * Applies the given settings updater function to all of the unary API methods in this service. 210 * 211 * <p>Note: This method does not support applying settings to streaming methods. 212 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)213 public Builder applyToAllUnaryMethods( 214 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 215 super.applyToAllUnaryMethods( 216 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 217 return this; 218 } 219 220 /** Returns the builder for the settings used for calls to delete. */ deleteSettings()221 public UnaryCallSettings.Builder<DeleteGlobalAddressRequest, Operation> deleteSettings() { 222 return getStubSettingsBuilder().deleteSettings(); 223 } 224 225 /** Returns the builder for the settings used for calls to delete. */ 226 public OperationCallSettings.Builder<DeleteGlobalAddressRequest, Operation, Operation> deleteOperationSettings()227 deleteOperationSettings() { 228 return getStubSettingsBuilder().deleteOperationSettings(); 229 } 230 231 /** Returns the builder for the settings used for calls to get. */ getSettings()232 public UnaryCallSettings.Builder<GetGlobalAddressRequest, Address> getSettings() { 233 return getStubSettingsBuilder().getSettings(); 234 } 235 236 /** Returns the builder for the settings used for calls to insert. */ insertSettings()237 public UnaryCallSettings.Builder<InsertGlobalAddressRequest, Operation> insertSettings() { 238 return getStubSettingsBuilder().insertSettings(); 239 } 240 241 /** Returns the builder for the settings used for calls to insert. */ 242 public OperationCallSettings.Builder<InsertGlobalAddressRequest, Operation, Operation> insertOperationSettings()243 insertOperationSettings() { 244 return getStubSettingsBuilder().insertOperationSettings(); 245 } 246 247 /** Returns the builder for the settings used for calls to list. */ 248 public PagedCallSettings.Builder<ListGlobalAddressesRequest, AddressList, ListPagedResponse> listSettings()249 listSettings() { 250 return getStubSettingsBuilder().listSettings(); 251 } 252 253 /** Returns the builder for the settings used for calls to setLabels. */ setLabelsSettings()254 public UnaryCallSettings.Builder<SetLabelsGlobalAddressRequest, Operation> setLabelsSettings() { 255 return getStubSettingsBuilder().setLabelsSettings(); 256 } 257 258 /** Returns the builder for the settings used for calls to setLabels. */ 259 public OperationCallSettings.Builder<SetLabelsGlobalAddressRequest, Operation, Operation> setLabelsOperationSettings()260 setLabelsOperationSettings() { 261 return getStubSettingsBuilder().setLabelsOperationSettings(); 262 } 263 264 @Override build()265 public GlobalAddressesSettings build() throws IOException { 266 return new GlobalAddressesSettings(this); 267 } 268 } 269 } 270