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.billing.v1; 18 19 import static com.google.cloud.billing.v1.CloudBillingClient.ListBillingAccountsPagedResponse; 20 import static com.google.cloud.billing.v1.CloudBillingClient.ListProjectBillingInfoPagedResponse; 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.billing.v1.stub.CloudBillingStubSettings; 35 import com.google.iam.v1.GetIamPolicyRequest; 36 import com.google.iam.v1.Policy; 37 import com.google.iam.v1.SetIamPolicyRequest; 38 import com.google.iam.v1.TestIamPermissionsRequest; 39 import com.google.iam.v1.TestIamPermissionsResponse; 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 CloudBillingClient}. 47 * 48 * <p>The default instance has everything set to sensible defaults: 49 * 50 * <ul> 51 * <li>The default service address (cloudbilling.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 total timeout of getBillingAccount to 30 seconds: 60 * 61 * <pre>{@code 62 * // This snippet has been automatically generated and should be regarded as a code template only. 63 * // It will require modifications to work: 64 * // - It may require correct/in-range values for request initialization. 65 * // - It may require specifying regional endpoints when creating the service client as shown in 66 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 67 * CloudBillingSettings.Builder cloudBillingSettingsBuilder = CloudBillingSettings.newBuilder(); 68 * cloudBillingSettingsBuilder 69 * .getBillingAccountSettings() 70 * .setRetrySettings( 71 * cloudBillingSettingsBuilder 72 * .getBillingAccountSettings() 73 * .getRetrySettings() 74 * .toBuilder() 75 * .setTotalTimeout(Duration.ofSeconds(30)) 76 * .build()); 77 * CloudBillingSettings cloudBillingSettings = cloudBillingSettingsBuilder.build(); 78 * }</pre> 79 */ 80 @Generated("by gapic-generator-java") 81 public class CloudBillingSettings extends ClientSettings<CloudBillingSettings> { 82 83 /** Returns the object with the settings used for calls to getBillingAccount. */ getBillingAccountSettings()84 public UnaryCallSettings<GetBillingAccountRequest, BillingAccount> getBillingAccountSettings() { 85 return ((CloudBillingStubSettings) getStubSettings()).getBillingAccountSettings(); 86 } 87 88 /** Returns the object with the settings used for calls to listBillingAccounts. */ 89 public PagedCallSettings< 90 ListBillingAccountsRequest, ListBillingAccountsResponse, ListBillingAccountsPagedResponse> listBillingAccountsSettings()91 listBillingAccountsSettings() { 92 return ((CloudBillingStubSettings) getStubSettings()).listBillingAccountsSettings(); 93 } 94 95 /** Returns the object with the settings used for calls to updateBillingAccount. */ 96 public UnaryCallSettings<UpdateBillingAccountRequest, BillingAccount> updateBillingAccountSettings()97 updateBillingAccountSettings() { 98 return ((CloudBillingStubSettings) getStubSettings()).updateBillingAccountSettings(); 99 } 100 101 /** Returns the object with the settings used for calls to createBillingAccount. */ 102 public UnaryCallSettings<CreateBillingAccountRequest, BillingAccount> createBillingAccountSettings()103 createBillingAccountSettings() { 104 return ((CloudBillingStubSettings) getStubSettings()).createBillingAccountSettings(); 105 } 106 107 /** Returns the object with the settings used for calls to listProjectBillingInfo. */ 108 public PagedCallSettings< 109 ListProjectBillingInfoRequest, 110 ListProjectBillingInfoResponse, 111 ListProjectBillingInfoPagedResponse> listProjectBillingInfoSettings()112 listProjectBillingInfoSettings() { 113 return ((CloudBillingStubSettings) getStubSettings()).listProjectBillingInfoSettings(); 114 } 115 116 /** Returns the object with the settings used for calls to getProjectBillingInfo. */ 117 public UnaryCallSettings<GetProjectBillingInfoRequest, ProjectBillingInfo> getProjectBillingInfoSettings()118 getProjectBillingInfoSettings() { 119 return ((CloudBillingStubSettings) getStubSettings()).getProjectBillingInfoSettings(); 120 } 121 122 /** Returns the object with the settings used for calls to updateProjectBillingInfo. */ 123 public UnaryCallSettings<UpdateProjectBillingInfoRequest, ProjectBillingInfo> updateProjectBillingInfoSettings()124 updateProjectBillingInfoSettings() { 125 return ((CloudBillingStubSettings) getStubSettings()).updateProjectBillingInfoSettings(); 126 } 127 128 /** Returns the object with the settings used for calls to getIamPolicy. */ getIamPolicySettings()129 public UnaryCallSettings<GetIamPolicyRequest, Policy> getIamPolicySettings() { 130 return ((CloudBillingStubSettings) getStubSettings()).getIamPolicySettings(); 131 } 132 133 /** Returns the object with the settings used for calls to setIamPolicy. */ setIamPolicySettings()134 public UnaryCallSettings<SetIamPolicyRequest, Policy> setIamPolicySettings() { 135 return ((CloudBillingStubSettings) getStubSettings()).setIamPolicySettings(); 136 } 137 138 /** Returns the object with the settings used for calls to testIamPermissions. */ 139 public UnaryCallSettings<TestIamPermissionsRequest, TestIamPermissionsResponse> testIamPermissionsSettings()140 testIamPermissionsSettings() { 141 return ((CloudBillingStubSettings) getStubSettings()).testIamPermissionsSettings(); 142 } 143 create(CloudBillingStubSettings stub)144 public static final CloudBillingSettings create(CloudBillingStubSettings stub) 145 throws IOException { 146 return new CloudBillingSettings.Builder(stub.toBuilder()).build(); 147 } 148 149 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()150 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 151 return CloudBillingStubSettings.defaultExecutorProviderBuilder(); 152 } 153 154 /** Returns the default service endpoint. */ getDefaultEndpoint()155 public static String getDefaultEndpoint() { 156 return CloudBillingStubSettings.getDefaultEndpoint(); 157 } 158 159 /** Returns the default service scopes. */ getDefaultServiceScopes()160 public static List<String> getDefaultServiceScopes() { 161 return CloudBillingStubSettings.getDefaultServiceScopes(); 162 } 163 164 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()165 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 166 return CloudBillingStubSettings.defaultCredentialsProviderBuilder(); 167 } 168 169 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()170 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 171 return CloudBillingStubSettings.defaultGrpcTransportProviderBuilder(); 172 } 173 174 /** Returns a builder for the default REST ChannelProvider for this service. */ 175 @BetaApi 176 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()177 defaultHttpJsonTransportProviderBuilder() { 178 return CloudBillingStubSettings.defaultHttpJsonTransportProviderBuilder(); 179 } 180 defaultTransportChannelProvider()181 public static TransportChannelProvider defaultTransportChannelProvider() { 182 return CloudBillingStubSettings.defaultTransportChannelProvider(); 183 } 184 185 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()186 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 187 return CloudBillingStubSettings.defaultApiClientHeaderProviderBuilder(); 188 } 189 190 /** Returns a new gRPC builder for this class. */ newBuilder()191 public static Builder newBuilder() { 192 return Builder.createDefault(); 193 } 194 195 /** Returns a new REST builder for this class. */ 196 @BetaApi newHttpJsonBuilder()197 public static Builder newHttpJsonBuilder() { 198 return Builder.createHttpJsonDefault(); 199 } 200 201 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)202 public static Builder newBuilder(ClientContext clientContext) { 203 return new Builder(clientContext); 204 } 205 206 /** Returns a builder containing all the values of this settings class. */ toBuilder()207 public Builder toBuilder() { 208 return new Builder(this); 209 } 210 CloudBillingSettings(Builder settingsBuilder)211 protected CloudBillingSettings(Builder settingsBuilder) throws IOException { 212 super(settingsBuilder); 213 } 214 215 /** Builder for CloudBillingSettings. */ 216 public static class Builder extends ClientSettings.Builder<CloudBillingSettings, Builder> { 217 Builder()218 protected Builder() throws IOException { 219 this(((ClientContext) null)); 220 } 221 Builder(ClientContext clientContext)222 protected Builder(ClientContext clientContext) { 223 super(CloudBillingStubSettings.newBuilder(clientContext)); 224 } 225 Builder(CloudBillingSettings settings)226 protected Builder(CloudBillingSettings settings) { 227 super(settings.getStubSettings().toBuilder()); 228 } 229 Builder(CloudBillingStubSettings.Builder stubSettings)230 protected Builder(CloudBillingStubSettings.Builder stubSettings) { 231 super(stubSettings); 232 } 233 createDefault()234 private static Builder createDefault() { 235 return new Builder(CloudBillingStubSettings.newBuilder()); 236 } 237 238 @BetaApi createHttpJsonDefault()239 private static Builder createHttpJsonDefault() { 240 return new Builder(CloudBillingStubSettings.newHttpJsonBuilder()); 241 } 242 getStubSettingsBuilder()243 public CloudBillingStubSettings.Builder getStubSettingsBuilder() { 244 return ((CloudBillingStubSettings.Builder) getStubSettings()); 245 } 246 247 /** 248 * Applies the given settings updater function to all of the unary API methods in this service. 249 * 250 * <p>Note: This method does not support applying settings to streaming methods. 251 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)252 public Builder applyToAllUnaryMethods( 253 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 254 super.applyToAllUnaryMethods( 255 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 256 return this; 257 } 258 259 /** Returns the builder for the settings used for calls to getBillingAccount. */ 260 public UnaryCallSettings.Builder<GetBillingAccountRequest, BillingAccount> getBillingAccountSettings()261 getBillingAccountSettings() { 262 return getStubSettingsBuilder().getBillingAccountSettings(); 263 } 264 265 /** Returns the builder for the settings used for calls to listBillingAccounts. */ 266 public PagedCallSettings.Builder< 267 ListBillingAccountsRequest, 268 ListBillingAccountsResponse, 269 ListBillingAccountsPagedResponse> listBillingAccountsSettings()270 listBillingAccountsSettings() { 271 return getStubSettingsBuilder().listBillingAccountsSettings(); 272 } 273 274 /** Returns the builder for the settings used for calls to updateBillingAccount. */ 275 public UnaryCallSettings.Builder<UpdateBillingAccountRequest, BillingAccount> updateBillingAccountSettings()276 updateBillingAccountSettings() { 277 return getStubSettingsBuilder().updateBillingAccountSettings(); 278 } 279 280 /** Returns the builder for the settings used for calls to createBillingAccount. */ 281 public UnaryCallSettings.Builder<CreateBillingAccountRequest, BillingAccount> createBillingAccountSettings()282 createBillingAccountSettings() { 283 return getStubSettingsBuilder().createBillingAccountSettings(); 284 } 285 286 /** Returns the builder for the settings used for calls to listProjectBillingInfo. */ 287 public PagedCallSettings.Builder< 288 ListProjectBillingInfoRequest, 289 ListProjectBillingInfoResponse, 290 ListProjectBillingInfoPagedResponse> listProjectBillingInfoSettings()291 listProjectBillingInfoSettings() { 292 return getStubSettingsBuilder().listProjectBillingInfoSettings(); 293 } 294 295 /** Returns the builder for the settings used for calls to getProjectBillingInfo. */ 296 public UnaryCallSettings.Builder<GetProjectBillingInfoRequest, ProjectBillingInfo> getProjectBillingInfoSettings()297 getProjectBillingInfoSettings() { 298 return getStubSettingsBuilder().getProjectBillingInfoSettings(); 299 } 300 301 /** Returns the builder for the settings used for calls to updateProjectBillingInfo. */ 302 public UnaryCallSettings.Builder<UpdateProjectBillingInfoRequest, ProjectBillingInfo> updateProjectBillingInfoSettings()303 updateProjectBillingInfoSettings() { 304 return getStubSettingsBuilder().updateProjectBillingInfoSettings(); 305 } 306 307 /** Returns the builder for the settings used for calls to getIamPolicy. */ getIamPolicySettings()308 public UnaryCallSettings.Builder<GetIamPolicyRequest, Policy> getIamPolicySettings() { 309 return getStubSettingsBuilder().getIamPolicySettings(); 310 } 311 312 /** Returns the builder for the settings used for calls to setIamPolicy. */ setIamPolicySettings()313 public UnaryCallSettings.Builder<SetIamPolicyRequest, Policy> setIamPolicySettings() { 314 return getStubSettingsBuilder().setIamPolicySettings(); 315 } 316 317 /** Returns the builder for the settings used for calls to testIamPermissions. */ 318 public UnaryCallSettings.Builder<TestIamPermissionsRequest, TestIamPermissionsResponse> testIamPermissionsSettings()319 testIamPermissionsSettings() { 320 return getStubSettingsBuilder().testIamPermissionsSettings(); 321 } 322 323 @Override build()324 public CloudBillingSettings build() throws IOException { 325 return new CloudBillingSettings(this); 326 } 327 } 328 } 329