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 com.google.api.core.ApiFuture; 20 import com.google.api.core.ApiFutures; 21 import com.google.api.gax.core.BackgroundResource; 22 import com.google.api.gax.paging.AbstractFixedSizeCollection; 23 import com.google.api.gax.paging.AbstractPage; 24 import com.google.api.gax.paging.AbstractPagedListResponse; 25 import com.google.api.gax.rpc.PageContext; 26 import com.google.api.gax.rpc.UnaryCallable; 27 import com.google.api.resourcenames.ResourceName; 28 import com.google.cloud.billing.v1.stub.CloudBillingStub; 29 import com.google.cloud.billing.v1.stub.CloudBillingStubSettings; 30 import com.google.common.util.concurrent.MoreExecutors; 31 import com.google.iam.v1.GetIamPolicyRequest; 32 import com.google.iam.v1.Policy; 33 import com.google.iam.v1.SetIamPolicyRequest; 34 import com.google.iam.v1.TestIamPermissionsRequest; 35 import com.google.iam.v1.TestIamPermissionsResponse; 36 import java.io.IOException; 37 import java.util.List; 38 import java.util.concurrent.TimeUnit; 39 import javax.annotation.Generated; 40 41 // AUTO-GENERATED DOCUMENTATION AND CLASS. 42 /** 43 * Service Description: Retrieves the Google Cloud Console billing accounts and associates them with 44 * projects. 45 * 46 * <p>This class provides the ability to make remote calls to the backing service through method 47 * calls that map to API methods. Sample code to get started: 48 * 49 * <pre>{@code 50 * // This snippet has been automatically generated and should be regarded as a code template only. 51 * // It will require modifications to work: 52 * // - It may require correct/in-range values for request initialization. 53 * // - It may require specifying regional endpoints when creating the service client as shown in 54 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 55 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 56 * BillingAccountName name = BillingAccountName.of("[BILLING_ACCOUNT]"); 57 * BillingAccount response = cloudBillingClient.getBillingAccount(name); 58 * } 59 * }</pre> 60 * 61 * <p>Note: close() needs to be called on the CloudBillingClient object to clean up resources such 62 * as threads. In the example above, try-with-resources is used, which automatically calls close(). 63 * 64 * <p>The surface of this class includes several types of Java methods for each of the API's 65 * methods: 66 * 67 * <ol> 68 * <li>A "flattened" method. With this type of method, the fields of the request type have been 69 * converted into function parameters. It may be the case that not all fields are available as 70 * parameters, and not every API method will have a flattened method entry point. 71 * <li>A "request object" method. This type of method only takes one parameter, a request object, 72 * which must be constructed before the call. Not every API method will have a request object 73 * method. 74 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 75 * callable object, which can be used to initiate calls to the service. 76 * </ol> 77 * 78 * <p>See the individual methods for example code. 79 * 80 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 81 * these names, this class includes a format method for each type of name, and additionally a parse 82 * method to extract the individual identifiers contained within names that are returned. 83 * 84 * <p>This class can be customized by passing in a custom instance of CloudBillingSettings to 85 * create(). For example: 86 * 87 * <p>To customize credentials: 88 * 89 * <pre>{@code 90 * // This snippet has been automatically generated and should be regarded as a code template only. 91 * // It will require modifications to work: 92 * // - It may require correct/in-range values for request initialization. 93 * // - It may require specifying regional endpoints when creating the service client as shown in 94 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 95 * CloudBillingSettings cloudBillingSettings = 96 * CloudBillingSettings.newBuilder() 97 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 98 * .build(); 99 * CloudBillingClient cloudBillingClient = CloudBillingClient.create(cloudBillingSettings); 100 * }</pre> 101 * 102 * <p>To customize the endpoint: 103 * 104 * <pre>{@code 105 * // This snippet has been automatically generated and should be regarded as a code template only. 106 * // It will require modifications to work: 107 * // - It may require correct/in-range values for request initialization. 108 * // - It may require specifying regional endpoints when creating the service client as shown in 109 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 110 * CloudBillingSettings cloudBillingSettings = 111 * CloudBillingSettings.newBuilder().setEndpoint(myEndpoint).build(); 112 * CloudBillingClient cloudBillingClient = CloudBillingClient.create(cloudBillingSettings); 113 * }</pre> 114 * 115 * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over 116 * the wire: 117 * 118 * <pre>{@code 119 * // This snippet has been automatically generated and should be regarded as a code template only. 120 * // It will require modifications to work: 121 * // - It may require correct/in-range values for request initialization. 122 * // - It may require specifying regional endpoints when creating the service client as shown in 123 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 124 * CloudBillingSettings cloudBillingSettings = CloudBillingSettings.newHttpJsonBuilder().build(); 125 * CloudBillingClient cloudBillingClient = CloudBillingClient.create(cloudBillingSettings); 126 * }</pre> 127 * 128 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 129 */ 130 @Generated("by gapic-generator-java") 131 public class CloudBillingClient implements BackgroundResource { 132 private final CloudBillingSettings settings; 133 private final CloudBillingStub stub; 134 135 /** Constructs an instance of CloudBillingClient with default settings. */ create()136 public static final CloudBillingClient create() throws IOException { 137 return create(CloudBillingSettings.newBuilder().build()); 138 } 139 140 /** 141 * Constructs an instance of CloudBillingClient, using the given settings. The channels are 142 * created based on the settings passed in, or defaults for any settings that are not set. 143 */ create(CloudBillingSettings settings)144 public static final CloudBillingClient create(CloudBillingSettings settings) throws IOException { 145 return new CloudBillingClient(settings); 146 } 147 148 /** 149 * Constructs an instance of CloudBillingClient, using the given stub for making calls. This is 150 * for advanced usage - prefer using create(CloudBillingSettings). 151 */ create(CloudBillingStub stub)152 public static final CloudBillingClient create(CloudBillingStub stub) { 153 return new CloudBillingClient(stub); 154 } 155 156 /** 157 * Constructs an instance of CloudBillingClient, using the given settings. This is protected so 158 * that it is easy to make a subclass, but otherwise, the static factory methods should be 159 * preferred. 160 */ CloudBillingClient(CloudBillingSettings settings)161 protected CloudBillingClient(CloudBillingSettings settings) throws IOException { 162 this.settings = settings; 163 this.stub = ((CloudBillingStubSettings) settings.getStubSettings()).createStub(); 164 } 165 CloudBillingClient(CloudBillingStub stub)166 protected CloudBillingClient(CloudBillingStub stub) { 167 this.settings = null; 168 this.stub = stub; 169 } 170 getSettings()171 public final CloudBillingSettings getSettings() { 172 return settings; 173 } 174 getStub()175 public CloudBillingStub getStub() { 176 return stub; 177 } 178 179 // AUTO-GENERATED DOCUMENTATION AND METHOD. 180 /** 181 * Gets information about a billing account. The current authenticated user must be a [viewer of 182 * the billing account](https://cloud.google.com/billing/docs/how-to/billing-access). 183 * 184 * <p>Sample code: 185 * 186 * <pre>{@code 187 * // This snippet has been automatically generated and should be regarded as a code template only. 188 * // It will require modifications to work: 189 * // - It may require correct/in-range values for request initialization. 190 * // - It may require specifying regional endpoints when creating the service client as shown in 191 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 192 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 193 * BillingAccountName name = BillingAccountName.of("[BILLING_ACCOUNT]"); 194 * BillingAccount response = cloudBillingClient.getBillingAccount(name); 195 * } 196 * }</pre> 197 * 198 * @param name Required. The resource name of the billing account to retrieve. For example, 199 * `billingAccounts/012345-567890-ABCDEF`. 200 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 201 */ getBillingAccount(BillingAccountName name)202 public final BillingAccount getBillingAccount(BillingAccountName name) { 203 GetBillingAccountRequest request = 204 GetBillingAccountRequest.newBuilder() 205 .setName(name == null ? null : name.toString()) 206 .build(); 207 return getBillingAccount(request); 208 } 209 210 // AUTO-GENERATED DOCUMENTATION AND METHOD. 211 /** 212 * Gets information about a billing account. The current authenticated user must be a [viewer of 213 * the billing account](https://cloud.google.com/billing/docs/how-to/billing-access). 214 * 215 * <p>Sample code: 216 * 217 * <pre>{@code 218 * // This snippet has been automatically generated and should be regarded as a code template only. 219 * // It will require modifications to work: 220 * // - It may require correct/in-range values for request initialization. 221 * // - It may require specifying regional endpoints when creating the service client as shown in 222 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 223 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 224 * String name = BillingAccountName.of("[BILLING_ACCOUNT]").toString(); 225 * BillingAccount response = cloudBillingClient.getBillingAccount(name); 226 * } 227 * }</pre> 228 * 229 * @param name Required. The resource name of the billing account to retrieve. For example, 230 * `billingAccounts/012345-567890-ABCDEF`. 231 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 232 */ getBillingAccount(String name)233 public final BillingAccount getBillingAccount(String name) { 234 GetBillingAccountRequest request = GetBillingAccountRequest.newBuilder().setName(name).build(); 235 return getBillingAccount(request); 236 } 237 238 // AUTO-GENERATED DOCUMENTATION AND METHOD. 239 /** 240 * Gets information about a billing account. The current authenticated user must be a [viewer of 241 * the billing account](https://cloud.google.com/billing/docs/how-to/billing-access). 242 * 243 * <p>Sample code: 244 * 245 * <pre>{@code 246 * // This snippet has been automatically generated and should be regarded as a code template only. 247 * // It will require modifications to work: 248 * // - It may require correct/in-range values for request initialization. 249 * // - It may require specifying regional endpoints when creating the service client as shown in 250 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 251 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 252 * GetBillingAccountRequest request = 253 * GetBillingAccountRequest.newBuilder() 254 * .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) 255 * .build(); 256 * BillingAccount response = cloudBillingClient.getBillingAccount(request); 257 * } 258 * }</pre> 259 * 260 * @param request The request object containing all of the parameters for the API call. 261 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 262 */ getBillingAccount(GetBillingAccountRequest request)263 public final BillingAccount getBillingAccount(GetBillingAccountRequest request) { 264 return getBillingAccountCallable().call(request); 265 } 266 267 // AUTO-GENERATED DOCUMENTATION AND METHOD. 268 /** 269 * Gets information about a billing account. The current authenticated user must be a [viewer of 270 * the billing account](https://cloud.google.com/billing/docs/how-to/billing-access). 271 * 272 * <p>Sample code: 273 * 274 * <pre>{@code 275 * // This snippet has been automatically generated and should be regarded as a code template only. 276 * // It will require modifications to work: 277 * // - It may require correct/in-range values for request initialization. 278 * // - It may require specifying regional endpoints when creating the service client as shown in 279 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 280 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 281 * GetBillingAccountRequest request = 282 * GetBillingAccountRequest.newBuilder() 283 * .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) 284 * .build(); 285 * ApiFuture<BillingAccount> future = 286 * cloudBillingClient.getBillingAccountCallable().futureCall(request); 287 * // Do something. 288 * BillingAccount response = future.get(); 289 * } 290 * }</pre> 291 */ getBillingAccountCallable()292 public final UnaryCallable<GetBillingAccountRequest, BillingAccount> getBillingAccountCallable() { 293 return stub.getBillingAccountCallable(); 294 } 295 296 // AUTO-GENERATED DOCUMENTATION AND METHOD. 297 /** 298 * Lists the billing accounts that the current authenticated user has permission to 299 * [view](https://cloud.google.com/billing/docs/how-to/billing-access). 300 * 301 * <p>Sample code: 302 * 303 * <pre>{@code 304 * // This snippet has been automatically generated and should be regarded as a code template only. 305 * // It will require modifications to work: 306 * // - It may require correct/in-range values for request initialization. 307 * // - It may require specifying regional endpoints when creating the service client as shown in 308 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 309 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 310 * for (BillingAccount element : cloudBillingClient.listBillingAccounts().iterateAll()) { 311 * // doThingsWith(element); 312 * } 313 * } 314 * }</pre> 315 * 316 * @param request The request object containing all of the parameters for the API call. 317 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 318 */ listBillingAccounts()319 public final ListBillingAccountsPagedResponse listBillingAccounts() { 320 ListBillingAccountsRequest request = ListBillingAccountsRequest.newBuilder().build(); 321 return listBillingAccounts(request); 322 } 323 324 // AUTO-GENERATED DOCUMENTATION AND METHOD. 325 /** 326 * Lists the billing accounts that the current authenticated user has permission to 327 * [view](https://cloud.google.com/billing/docs/how-to/billing-access). 328 * 329 * <p>Sample code: 330 * 331 * <pre>{@code 332 * // This snippet has been automatically generated and should be regarded as a code template only. 333 * // It will require modifications to work: 334 * // - It may require correct/in-range values for request initialization. 335 * // - It may require specifying regional endpoints when creating the service client as shown in 336 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 337 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 338 * ListBillingAccountsRequest request = 339 * ListBillingAccountsRequest.newBuilder() 340 * .setPageSize(883849137) 341 * .setPageToken("pageToken873572522") 342 * .setFilter("filter-1274492040") 343 * .build(); 344 * for (BillingAccount element : cloudBillingClient.listBillingAccounts(request).iterateAll()) { 345 * // doThingsWith(element); 346 * } 347 * } 348 * }</pre> 349 * 350 * @param request The request object containing all of the parameters for the API call. 351 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 352 */ listBillingAccounts( ListBillingAccountsRequest request)353 public final ListBillingAccountsPagedResponse listBillingAccounts( 354 ListBillingAccountsRequest request) { 355 return listBillingAccountsPagedCallable().call(request); 356 } 357 358 // AUTO-GENERATED DOCUMENTATION AND METHOD. 359 /** 360 * Lists the billing accounts that the current authenticated user has permission to 361 * [view](https://cloud.google.com/billing/docs/how-to/billing-access). 362 * 363 * <p>Sample code: 364 * 365 * <pre>{@code 366 * // This snippet has been automatically generated and should be regarded as a code template only. 367 * // It will require modifications to work: 368 * // - It may require correct/in-range values for request initialization. 369 * // - It may require specifying regional endpoints when creating the service client as shown in 370 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 371 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 372 * ListBillingAccountsRequest request = 373 * ListBillingAccountsRequest.newBuilder() 374 * .setPageSize(883849137) 375 * .setPageToken("pageToken873572522") 376 * .setFilter("filter-1274492040") 377 * .build(); 378 * ApiFuture<BillingAccount> future = 379 * cloudBillingClient.listBillingAccountsPagedCallable().futureCall(request); 380 * // Do something. 381 * for (BillingAccount element : future.get().iterateAll()) { 382 * // doThingsWith(element); 383 * } 384 * } 385 * }</pre> 386 */ 387 public final UnaryCallable<ListBillingAccountsRequest, ListBillingAccountsPagedResponse> listBillingAccountsPagedCallable()388 listBillingAccountsPagedCallable() { 389 return stub.listBillingAccountsPagedCallable(); 390 } 391 392 // AUTO-GENERATED DOCUMENTATION AND METHOD. 393 /** 394 * Lists the billing accounts that the current authenticated user has permission to 395 * [view](https://cloud.google.com/billing/docs/how-to/billing-access). 396 * 397 * <p>Sample code: 398 * 399 * <pre>{@code 400 * // This snippet has been automatically generated and should be regarded as a code template only. 401 * // It will require modifications to work: 402 * // - It may require correct/in-range values for request initialization. 403 * // - It may require specifying regional endpoints when creating the service client as shown in 404 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 405 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 406 * ListBillingAccountsRequest request = 407 * ListBillingAccountsRequest.newBuilder() 408 * .setPageSize(883849137) 409 * .setPageToken("pageToken873572522") 410 * .setFilter("filter-1274492040") 411 * .build(); 412 * while (true) { 413 * ListBillingAccountsResponse response = 414 * cloudBillingClient.listBillingAccountsCallable().call(request); 415 * for (BillingAccount element : response.getBillingAccountsList()) { 416 * // doThingsWith(element); 417 * } 418 * String nextPageToken = response.getNextPageToken(); 419 * if (!Strings.isNullOrEmpty(nextPageToken)) { 420 * request = request.toBuilder().setPageToken(nextPageToken).build(); 421 * } else { 422 * break; 423 * } 424 * } 425 * } 426 * }</pre> 427 */ 428 public final UnaryCallable<ListBillingAccountsRequest, ListBillingAccountsResponse> listBillingAccountsCallable()429 listBillingAccountsCallable() { 430 return stub.listBillingAccountsCallable(); 431 } 432 433 // AUTO-GENERATED DOCUMENTATION AND METHOD. 434 /** 435 * Updates a billing account's fields. Currently the only field that can be edited is 436 * `display_name`. The current authenticated user must have the `billing.accounts.update` IAM 437 * permission, which is typically given to the 438 * [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) of the billing 439 * account. 440 * 441 * <p>Sample code: 442 * 443 * <pre>{@code 444 * // This snippet has been automatically generated and should be regarded as a code template only. 445 * // It will require modifications to work: 446 * // - It may require correct/in-range values for request initialization. 447 * // - It may require specifying regional endpoints when creating the service client as shown in 448 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 449 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 450 * BillingAccountName name = BillingAccountName.of("[BILLING_ACCOUNT]"); 451 * BillingAccount account = BillingAccount.newBuilder().build(); 452 * BillingAccount response = cloudBillingClient.updateBillingAccount(name, account); 453 * } 454 * }</pre> 455 * 456 * @param name Required. The name of the billing account resource to be updated. 457 * @param account Required. The billing account resource to replace the resource on the server. 458 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 459 */ updateBillingAccount( BillingAccountName name, BillingAccount account)460 public final BillingAccount updateBillingAccount( 461 BillingAccountName name, BillingAccount account) { 462 UpdateBillingAccountRequest request = 463 UpdateBillingAccountRequest.newBuilder() 464 .setName(name == null ? null : name.toString()) 465 .setAccount(account) 466 .build(); 467 return updateBillingAccount(request); 468 } 469 470 // AUTO-GENERATED DOCUMENTATION AND METHOD. 471 /** 472 * Updates a billing account's fields. Currently the only field that can be edited is 473 * `display_name`. The current authenticated user must have the `billing.accounts.update` IAM 474 * permission, which is typically given to the 475 * [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) of the billing 476 * account. 477 * 478 * <p>Sample code: 479 * 480 * <pre>{@code 481 * // This snippet has been automatically generated and should be regarded as a code template only. 482 * // It will require modifications to work: 483 * // - It may require correct/in-range values for request initialization. 484 * // - It may require specifying regional endpoints when creating the service client as shown in 485 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 486 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 487 * String name = BillingAccountName.of("[BILLING_ACCOUNT]").toString(); 488 * BillingAccount account = BillingAccount.newBuilder().build(); 489 * BillingAccount response = cloudBillingClient.updateBillingAccount(name, account); 490 * } 491 * }</pre> 492 * 493 * @param name Required. The name of the billing account resource to be updated. 494 * @param account Required. The billing account resource to replace the resource on the server. 495 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 496 */ updateBillingAccount(String name, BillingAccount account)497 public final BillingAccount updateBillingAccount(String name, BillingAccount account) { 498 UpdateBillingAccountRequest request = 499 UpdateBillingAccountRequest.newBuilder().setName(name).setAccount(account).build(); 500 return updateBillingAccount(request); 501 } 502 503 // AUTO-GENERATED DOCUMENTATION AND METHOD. 504 /** 505 * Updates a billing account's fields. Currently the only field that can be edited is 506 * `display_name`. The current authenticated user must have the `billing.accounts.update` IAM 507 * permission, which is typically given to the 508 * [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) of the billing 509 * account. 510 * 511 * <p>Sample code: 512 * 513 * <pre>{@code 514 * // This snippet has been automatically generated and should be regarded as a code template only. 515 * // It will require modifications to work: 516 * // - It may require correct/in-range values for request initialization. 517 * // - It may require specifying regional endpoints when creating the service client as shown in 518 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 519 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 520 * UpdateBillingAccountRequest request = 521 * UpdateBillingAccountRequest.newBuilder() 522 * .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) 523 * .setAccount(BillingAccount.newBuilder().build()) 524 * .setUpdateMask(FieldMask.newBuilder().build()) 525 * .build(); 526 * BillingAccount response = cloudBillingClient.updateBillingAccount(request); 527 * } 528 * }</pre> 529 * 530 * @param request The request object containing all of the parameters for the API call. 531 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 532 */ updateBillingAccount(UpdateBillingAccountRequest request)533 public final BillingAccount updateBillingAccount(UpdateBillingAccountRequest request) { 534 return updateBillingAccountCallable().call(request); 535 } 536 537 // AUTO-GENERATED DOCUMENTATION AND METHOD. 538 /** 539 * Updates a billing account's fields. Currently the only field that can be edited is 540 * `display_name`. The current authenticated user must have the `billing.accounts.update` IAM 541 * permission, which is typically given to the 542 * [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) of the billing 543 * account. 544 * 545 * <p>Sample code: 546 * 547 * <pre>{@code 548 * // This snippet has been automatically generated and should be regarded as a code template only. 549 * // It will require modifications to work: 550 * // - It may require correct/in-range values for request initialization. 551 * // - It may require specifying regional endpoints when creating the service client as shown in 552 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 553 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 554 * UpdateBillingAccountRequest request = 555 * UpdateBillingAccountRequest.newBuilder() 556 * .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) 557 * .setAccount(BillingAccount.newBuilder().build()) 558 * .setUpdateMask(FieldMask.newBuilder().build()) 559 * .build(); 560 * ApiFuture<BillingAccount> future = 561 * cloudBillingClient.updateBillingAccountCallable().futureCall(request); 562 * // Do something. 563 * BillingAccount response = future.get(); 564 * } 565 * }</pre> 566 */ 567 public final UnaryCallable<UpdateBillingAccountRequest, BillingAccount> updateBillingAccountCallable()568 updateBillingAccountCallable() { 569 return stub.updateBillingAccountCallable(); 570 } 571 572 // AUTO-GENERATED DOCUMENTATION AND METHOD. 573 /** 574 * This method creates [billing 575 * subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). 576 * 577 * <p>Google Cloud resellers should use the Channel Services APIs, 578 * [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) 579 * and 580 * [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). 581 * 582 * <p>When creating a subaccount, the current authenticated user must have the 583 * `billing.accounts.update` IAM permission on the parent account, which is typically given to 584 * billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). 585 * This method will return an error if the parent account has not been provisioned as a reseller 586 * account. 587 * 588 * <p>Sample code: 589 * 590 * <pre>{@code 591 * // This snippet has been automatically generated and should be regarded as a code template only. 592 * // It will require modifications to work: 593 * // - It may require correct/in-range values for request initialization. 594 * // - It may require specifying regional endpoints when creating the service client as shown in 595 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 596 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 597 * BillingAccount billingAccount = BillingAccount.newBuilder().build(); 598 * BillingAccount response = cloudBillingClient.createBillingAccount(billingAccount); 599 * } 600 * }</pre> 601 * 602 * @param billingAccount Required. The billing account resource to create. Currently 603 * CreateBillingAccount only supports subaccount creation, so any created billing accounts 604 * must be under a provided parent billing account. 605 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 606 */ createBillingAccount(BillingAccount billingAccount)607 public final BillingAccount createBillingAccount(BillingAccount billingAccount) { 608 CreateBillingAccountRequest request = 609 CreateBillingAccountRequest.newBuilder().setBillingAccount(billingAccount).build(); 610 return createBillingAccount(request); 611 } 612 613 // AUTO-GENERATED DOCUMENTATION AND METHOD. 614 /** 615 * This method creates [billing 616 * subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). 617 * 618 * <p>Google Cloud resellers should use the Channel Services APIs, 619 * [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) 620 * and 621 * [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). 622 * 623 * <p>When creating a subaccount, the current authenticated user must have the 624 * `billing.accounts.update` IAM permission on the parent account, which is typically given to 625 * billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). 626 * This method will return an error if the parent account has not been provisioned as a reseller 627 * account. 628 * 629 * <p>Sample code: 630 * 631 * <pre>{@code 632 * // This snippet has been automatically generated and should be regarded as a code template only. 633 * // It will require modifications to work: 634 * // - It may require correct/in-range values for request initialization. 635 * // - It may require specifying regional endpoints when creating the service client as shown in 636 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 637 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 638 * CreateBillingAccountRequest request = 639 * CreateBillingAccountRequest.newBuilder() 640 * .setBillingAccount(BillingAccount.newBuilder().build()) 641 * .build(); 642 * BillingAccount response = cloudBillingClient.createBillingAccount(request); 643 * } 644 * }</pre> 645 * 646 * @param request The request object containing all of the parameters for the API call. 647 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 648 */ createBillingAccount(CreateBillingAccountRequest request)649 public final BillingAccount createBillingAccount(CreateBillingAccountRequest request) { 650 return createBillingAccountCallable().call(request); 651 } 652 653 // AUTO-GENERATED DOCUMENTATION AND METHOD. 654 /** 655 * This method creates [billing 656 * subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). 657 * 658 * <p>Google Cloud resellers should use the Channel Services APIs, 659 * [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) 660 * and 661 * [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). 662 * 663 * <p>When creating a subaccount, the current authenticated user must have the 664 * `billing.accounts.update` IAM permission on the parent account, which is typically given to 665 * billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). 666 * This method will return an error if the parent account has not been provisioned as a reseller 667 * account. 668 * 669 * <p>Sample code: 670 * 671 * <pre>{@code 672 * // This snippet has been automatically generated and should be regarded as a code template only. 673 * // It will require modifications to work: 674 * // - It may require correct/in-range values for request initialization. 675 * // - It may require specifying regional endpoints when creating the service client as shown in 676 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 677 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 678 * CreateBillingAccountRequest request = 679 * CreateBillingAccountRequest.newBuilder() 680 * .setBillingAccount(BillingAccount.newBuilder().build()) 681 * .build(); 682 * ApiFuture<BillingAccount> future = 683 * cloudBillingClient.createBillingAccountCallable().futureCall(request); 684 * // Do something. 685 * BillingAccount response = future.get(); 686 * } 687 * }</pre> 688 */ 689 public final UnaryCallable<CreateBillingAccountRequest, BillingAccount> createBillingAccountCallable()690 createBillingAccountCallable() { 691 return stub.createBillingAccountCallable(); 692 } 693 694 // AUTO-GENERATED DOCUMENTATION AND METHOD. 695 /** 696 * Lists the projects associated with a billing account. The current authenticated user must have 697 * the `billing.resourceAssociations.list` IAM permission, which is often given to billing account 698 * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). 699 * 700 * <p>Sample code: 701 * 702 * <pre>{@code 703 * // This snippet has been automatically generated and should be regarded as a code template only. 704 * // It will require modifications to work: 705 * // - It may require correct/in-range values for request initialization. 706 * // - It may require specifying regional endpoints when creating the service client as shown in 707 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 708 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 709 * BillingAccountName name = BillingAccountName.of("[BILLING_ACCOUNT]"); 710 * for (ProjectBillingInfo element : 711 * cloudBillingClient.listProjectBillingInfo(name).iterateAll()) { 712 * // doThingsWith(element); 713 * } 714 * } 715 * }</pre> 716 * 717 * @param name Required. The resource name of the billing account associated with the projects 718 * that you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. 719 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 720 */ listProjectBillingInfo(BillingAccountName name)721 public final ListProjectBillingInfoPagedResponse listProjectBillingInfo(BillingAccountName name) { 722 ListProjectBillingInfoRequest request = 723 ListProjectBillingInfoRequest.newBuilder() 724 .setName(name == null ? null : name.toString()) 725 .build(); 726 return listProjectBillingInfo(request); 727 } 728 729 // AUTO-GENERATED DOCUMENTATION AND METHOD. 730 /** 731 * Lists the projects associated with a billing account. The current authenticated user must have 732 * the `billing.resourceAssociations.list` IAM permission, which is often given to billing account 733 * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). 734 * 735 * <p>Sample code: 736 * 737 * <pre>{@code 738 * // This snippet has been automatically generated and should be regarded as a code template only. 739 * // It will require modifications to work: 740 * // - It may require correct/in-range values for request initialization. 741 * // - It may require specifying regional endpoints when creating the service client as shown in 742 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 743 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 744 * String name = BillingAccountName.of("[BILLING_ACCOUNT]").toString(); 745 * for (ProjectBillingInfo element : 746 * cloudBillingClient.listProjectBillingInfo(name).iterateAll()) { 747 * // doThingsWith(element); 748 * } 749 * } 750 * }</pre> 751 * 752 * @param name Required. The resource name of the billing account associated with the projects 753 * that you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. 754 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 755 */ listProjectBillingInfo(String name)756 public final ListProjectBillingInfoPagedResponse listProjectBillingInfo(String name) { 757 ListProjectBillingInfoRequest request = 758 ListProjectBillingInfoRequest.newBuilder().setName(name).build(); 759 return listProjectBillingInfo(request); 760 } 761 762 // AUTO-GENERATED DOCUMENTATION AND METHOD. 763 /** 764 * Lists the projects associated with a billing account. The current authenticated user must have 765 * the `billing.resourceAssociations.list` IAM permission, which is often given to billing account 766 * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). 767 * 768 * <p>Sample code: 769 * 770 * <pre>{@code 771 * // This snippet has been automatically generated and should be regarded as a code template only. 772 * // It will require modifications to work: 773 * // - It may require correct/in-range values for request initialization. 774 * // - It may require specifying regional endpoints when creating the service client as shown in 775 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 776 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 777 * ListProjectBillingInfoRequest request = 778 * ListProjectBillingInfoRequest.newBuilder() 779 * .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) 780 * .setPageSize(883849137) 781 * .setPageToken("pageToken873572522") 782 * .build(); 783 * for (ProjectBillingInfo element : 784 * cloudBillingClient.listProjectBillingInfo(request).iterateAll()) { 785 * // doThingsWith(element); 786 * } 787 * } 788 * }</pre> 789 * 790 * @param request The request object containing all of the parameters for the API call. 791 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 792 */ listProjectBillingInfo( ListProjectBillingInfoRequest request)793 public final ListProjectBillingInfoPagedResponse listProjectBillingInfo( 794 ListProjectBillingInfoRequest request) { 795 return listProjectBillingInfoPagedCallable().call(request); 796 } 797 798 // AUTO-GENERATED DOCUMENTATION AND METHOD. 799 /** 800 * Lists the projects associated with a billing account. The current authenticated user must have 801 * the `billing.resourceAssociations.list` IAM permission, which is often given to billing account 802 * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). 803 * 804 * <p>Sample code: 805 * 806 * <pre>{@code 807 * // This snippet has been automatically generated and should be regarded as a code template only. 808 * // It will require modifications to work: 809 * // - It may require correct/in-range values for request initialization. 810 * // - It may require specifying regional endpoints when creating the service client as shown in 811 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 812 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 813 * ListProjectBillingInfoRequest request = 814 * ListProjectBillingInfoRequest.newBuilder() 815 * .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) 816 * .setPageSize(883849137) 817 * .setPageToken("pageToken873572522") 818 * .build(); 819 * ApiFuture<ProjectBillingInfo> future = 820 * cloudBillingClient.listProjectBillingInfoPagedCallable().futureCall(request); 821 * // Do something. 822 * for (ProjectBillingInfo element : future.get().iterateAll()) { 823 * // doThingsWith(element); 824 * } 825 * } 826 * }</pre> 827 */ 828 public final UnaryCallable<ListProjectBillingInfoRequest, ListProjectBillingInfoPagedResponse> listProjectBillingInfoPagedCallable()829 listProjectBillingInfoPagedCallable() { 830 return stub.listProjectBillingInfoPagedCallable(); 831 } 832 833 // AUTO-GENERATED DOCUMENTATION AND METHOD. 834 /** 835 * Lists the projects associated with a billing account. The current authenticated user must have 836 * the `billing.resourceAssociations.list` IAM permission, which is often given to billing account 837 * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). 838 * 839 * <p>Sample code: 840 * 841 * <pre>{@code 842 * // This snippet has been automatically generated and should be regarded as a code template only. 843 * // It will require modifications to work: 844 * // - It may require correct/in-range values for request initialization. 845 * // - It may require specifying regional endpoints when creating the service client as shown in 846 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 847 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 848 * ListProjectBillingInfoRequest request = 849 * ListProjectBillingInfoRequest.newBuilder() 850 * .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) 851 * .setPageSize(883849137) 852 * .setPageToken("pageToken873572522") 853 * .build(); 854 * while (true) { 855 * ListProjectBillingInfoResponse response = 856 * cloudBillingClient.listProjectBillingInfoCallable().call(request); 857 * for (ProjectBillingInfo element : response.getProjectBillingInfoList()) { 858 * // doThingsWith(element); 859 * } 860 * String nextPageToken = response.getNextPageToken(); 861 * if (!Strings.isNullOrEmpty(nextPageToken)) { 862 * request = request.toBuilder().setPageToken(nextPageToken).build(); 863 * } else { 864 * break; 865 * } 866 * } 867 * } 868 * }</pre> 869 */ 870 public final UnaryCallable<ListProjectBillingInfoRequest, ListProjectBillingInfoResponse> listProjectBillingInfoCallable()871 listProjectBillingInfoCallable() { 872 return stub.listProjectBillingInfoCallable(); 873 } 874 875 // AUTO-GENERATED DOCUMENTATION AND METHOD. 876 /** 877 * Gets the billing information for a project. The current authenticated user must have the 878 * `resourcemanager.projects.get` permission for the project, which can be granted by assigning 879 * the [Project Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) 880 * role. 881 * 882 * <p>Sample code: 883 * 884 * <pre>{@code 885 * // This snippet has been automatically generated and should be regarded as a code template only. 886 * // It will require modifications to work: 887 * // - It may require correct/in-range values for request initialization. 888 * // - It may require specifying regional endpoints when creating the service client as shown in 889 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 890 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 891 * String name = "name3373707"; 892 * ProjectBillingInfo response = cloudBillingClient.getProjectBillingInfo(name); 893 * } 894 * }</pre> 895 * 896 * @param name Required. The resource name of the project for which billing information is 897 * retrieved. For example, `projects/tokyo-rain-123`. 898 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 899 */ getProjectBillingInfo(String name)900 public final ProjectBillingInfo getProjectBillingInfo(String name) { 901 GetProjectBillingInfoRequest request = 902 GetProjectBillingInfoRequest.newBuilder().setName(name).build(); 903 return getProjectBillingInfo(request); 904 } 905 906 // AUTO-GENERATED DOCUMENTATION AND METHOD. 907 /** 908 * Gets the billing information for a project. The current authenticated user must have the 909 * `resourcemanager.projects.get` permission for the project, which can be granted by assigning 910 * the [Project Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) 911 * role. 912 * 913 * <p>Sample code: 914 * 915 * <pre>{@code 916 * // This snippet has been automatically generated and should be regarded as a code template only. 917 * // It will require modifications to work: 918 * // - It may require correct/in-range values for request initialization. 919 * // - It may require specifying regional endpoints when creating the service client as shown in 920 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 921 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 922 * GetProjectBillingInfoRequest request = 923 * GetProjectBillingInfoRequest.newBuilder().setName("name3373707").build(); 924 * ProjectBillingInfo response = cloudBillingClient.getProjectBillingInfo(request); 925 * } 926 * }</pre> 927 * 928 * @param request The request object containing all of the parameters for the API call. 929 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 930 */ getProjectBillingInfo(GetProjectBillingInfoRequest request)931 public final ProjectBillingInfo getProjectBillingInfo(GetProjectBillingInfoRequest request) { 932 return getProjectBillingInfoCallable().call(request); 933 } 934 935 // AUTO-GENERATED DOCUMENTATION AND METHOD. 936 /** 937 * Gets the billing information for a project. The current authenticated user must have the 938 * `resourcemanager.projects.get` permission for the project, which can be granted by assigning 939 * the [Project Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) 940 * role. 941 * 942 * <p>Sample code: 943 * 944 * <pre>{@code 945 * // This snippet has been automatically generated and should be regarded as a code template only. 946 * // It will require modifications to work: 947 * // - It may require correct/in-range values for request initialization. 948 * // - It may require specifying regional endpoints when creating the service client as shown in 949 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 950 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 951 * GetProjectBillingInfoRequest request = 952 * GetProjectBillingInfoRequest.newBuilder().setName("name3373707").build(); 953 * ApiFuture<ProjectBillingInfo> future = 954 * cloudBillingClient.getProjectBillingInfoCallable().futureCall(request); 955 * // Do something. 956 * ProjectBillingInfo response = future.get(); 957 * } 958 * }</pre> 959 */ 960 public final UnaryCallable<GetProjectBillingInfoRequest, ProjectBillingInfo> getProjectBillingInfoCallable()961 getProjectBillingInfoCallable() { 962 return stub.getProjectBillingInfoCallable(); 963 } 964 965 // AUTO-GENERATED DOCUMENTATION AND METHOD. 966 /** 967 * Sets or updates the billing account associated with a project. You specify the new billing 968 * account by setting the `billing_account_name` in the `ProjectBillingInfo` resource to the 969 * resource name of a billing account. Associating a project with an open billing account enables 970 * billing on the project and allows charges for resource usage. If the project already had a 971 * billing account, this method changes the billing account used for resource usage charges. 972 * 973 * <p>*Note:* Incurred charges that have not yet been reported in the transaction history 974 * of the Google Cloud Console might be billed to the new billing account, even if the charge 975 * occurred before the new billing account was assigned to the project. 976 * 977 * <p>The current authenticated user must have ownership privileges for both the 978 * [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing 979 * account](https://cloud.google.com/billing/docs/how-to/billing-access). 980 * 981 * <p>You can disable billing on the project by setting the `billing_account_name` field to empty. 982 * This action disassociates the current billing account from the project. Any billable activity 983 * of your in-use services will stop, and your application could stop functioning as expected. Any 984 * unbilled charges to date will be billed to the previously associated account. The current 985 * authenticated user must be either an owner of the project or an owner of the billing account 986 * for the project. 987 * 988 * <p>Note that associating a project with a *closed* billing account will have much the 989 * same effect as disabling billing on the project: any paid resources used by the project will be 990 * shut down. Thus, unless you wish to disable billing, you should always call this method with 991 * the name of an 992 * 993 * <ul> 994 * <li>open* billing account. 995 * </ul> 996 * 997 * <p>Sample code: 998 * 999 * <pre>{@code 1000 * // This snippet has been automatically generated and should be regarded as a code template only. 1001 * // It will require modifications to work: 1002 * // - It may require correct/in-range values for request initialization. 1003 * // - It may require specifying regional endpoints when creating the service client as shown in 1004 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1005 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 1006 * String name = "name3373707"; 1007 * ProjectBillingInfo projectBillingInfo = ProjectBillingInfo.newBuilder().build(); 1008 * ProjectBillingInfo response = 1009 * cloudBillingClient.updateProjectBillingInfo(name, projectBillingInfo); 1010 * } 1011 * }</pre> 1012 * 1013 * @param name Required. The resource name of the project associated with the billing information 1014 * that you want to update. For example, `projects/tokyo-rain-123`. 1015 * @param projectBillingInfo The new billing information for the project. Read-only fields are 1016 * ignored; thus, you can leave empty all fields except `billing_account_name`. 1017 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1018 */ updateProjectBillingInfo( String name, ProjectBillingInfo projectBillingInfo)1019 public final ProjectBillingInfo updateProjectBillingInfo( 1020 String name, ProjectBillingInfo projectBillingInfo) { 1021 UpdateProjectBillingInfoRequest request = 1022 UpdateProjectBillingInfoRequest.newBuilder() 1023 .setName(name) 1024 .setProjectBillingInfo(projectBillingInfo) 1025 .build(); 1026 return updateProjectBillingInfo(request); 1027 } 1028 1029 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1030 /** 1031 * Sets or updates the billing account associated with a project. You specify the new billing 1032 * account by setting the `billing_account_name` in the `ProjectBillingInfo` resource to the 1033 * resource name of a billing account. Associating a project with an open billing account enables 1034 * billing on the project and allows charges for resource usage. If the project already had a 1035 * billing account, this method changes the billing account used for resource usage charges. 1036 * 1037 * <p>*Note:* Incurred charges that have not yet been reported in the transaction history 1038 * of the Google Cloud Console might be billed to the new billing account, even if the charge 1039 * occurred before the new billing account was assigned to the project. 1040 * 1041 * <p>The current authenticated user must have ownership privileges for both the 1042 * [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing 1043 * account](https://cloud.google.com/billing/docs/how-to/billing-access). 1044 * 1045 * <p>You can disable billing on the project by setting the `billing_account_name` field to empty. 1046 * This action disassociates the current billing account from the project. Any billable activity 1047 * of your in-use services will stop, and your application could stop functioning as expected. Any 1048 * unbilled charges to date will be billed to the previously associated account. The current 1049 * authenticated user must be either an owner of the project or an owner of the billing account 1050 * for the project. 1051 * 1052 * <p>Note that associating a project with a *closed* billing account will have much the 1053 * same effect as disabling billing on the project: any paid resources used by the project will be 1054 * shut down. Thus, unless you wish to disable billing, you should always call this method with 1055 * the name of an 1056 * 1057 * <ul> 1058 * <li>open* billing account. 1059 * </ul> 1060 * 1061 * <p>Sample code: 1062 * 1063 * <pre>{@code 1064 * // This snippet has been automatically generated and should be regarded as a code template only. 1065 * // It will require modifications to work: 1066 * // - It may require correct/in-range values for request initialization. 1067 * // - It may require specifying regional endpoints when creating the service client as shown in 1068 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1069 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 1070 * UpdateProjectBillingInfoRequest request = 1071 * UpdateProjectBillingInfoRequest.newBuilder() 1072 * .setName("name3373707") 1073 * .setProjectBillingInfo(ProjectBillingInfo.newBuilder().build()) 1074 * .build(); 1075 * ProjectBillingInfo response = cloudBillingClient.updateProjectBillingInfo(request); 1076 * } 1077 * }</pre> 1078 * 1079 * @param request The request object containing all of the parameters for the API call. 1080 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1081 */ updateProjectBillingInfo( UpdateProjectBillingInfoRequest request)1082 public final ProjectBillingInfo updateProjectBillingInfo( 1083 UpdateProjectBillingInfoRequest request) { 1084 return updateProjectBillingInfoCallable().call(request); 1085 } 1086 1087 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1088 /** 1089 * Sets or updates the billing account associated with a project. You specify the new billing 1090 * account by setting the `billing_account_name` in the `ProjectBillingInfo` resource to the 1091 * resource name of a billing account. Associating a project with an open billing account enables 1092 * billing on the project and allows charges for resource usage. If the project already had a 1093 * billing account, this method changes the billing account used for resource usage charges. 1094 * 1095 * <p>*Note:* Incurred charges that have not yet been reported in the transaction history 1096 * of the Google Cloud Console might be billed to the new billing account, even if the charge 1097 * occurred before the new billing account was assigned to the project. 1098 * 1099 * <p>The current authenticated user must have ownership privileges for both the 1100 * [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing 1101 * account](https://cloud.google.com/billing/docs/how-to/billing-access). 1102 * 1103 * <p>You can disable billing on the project by setting the `billing_account_name` field to empty. 1104 * This action disassociates the current billing account from the project. Any billable activity 1105 * of your in-use services will stop, and your application could stop functioning as expected. Any 1106 * unbilled charges to date will be billed to the previously associated account. The current 1107 * authenticated user must be either an owner of the project or an owner of the billing account 1108 * for the project. 1109 * 1110 * <p>Note that associating a project with a *closed* billing account will have much the 1111 * same effect as disabling billing on the project: any paid resources used by the project will be 1112 * shut down. Thus, unless you wish to disable billing, you should always call this method with 1113 * the name of an 1114 * 1115 * <ul> 1116 * <li>open* billing account. 1117 * </ul> 1118 * 1119 * <p>Sample code: 1120 * 1121 * <pre>{@code 1122 * // This snippet has been automatically generated and should be regarded as a code template only. 1123 * // It will require modifications to work: 1124 * // - It may require correct/in-range values for request initialization. 1125 * // - It may require specifying regional endpoints when creating the service client as shown in 1126 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1127 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 1128 * UpdateProjectBillingInfoRequest request = 1129 * UpdateProjectBillingInfoRequest.newBuilder() 1130 * .setName("name3373707") 1131 * .setProjectBillingInfo(ProjectBillingInfo.newBuilder().build()) 1132 * .build(); 1133 * ApiFuture<ProjectBillingInfo> future = 1134 * cloudBillingClient.updateProjectBillingInfoCallable().futureCall(request); 1135 * // Do something. 1136 * ProjectBillingInfo response = future.get(); 1137 * } 1138 * }</pre> 1139 */ 1140 public final UnaryCallable<UpdateProjectBillingInfoRequest, ProjectBillingInfo> updateProjectBillingInfoCallable()1141 updateProjectBillingInfoCallable() { 1142 return stub.updateProjectBillingInfoCallable(); 1143 } 1144 1145 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1146 /** 1147 * Gets the access control policy for a billing account. The caller must have the 1148 * `billing.accounts.getIamPolicy` permission on the account, which is often given to billing 1149 * account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). 1150 * 1151 * <p>Sample code: 1152 * 1153 * <pre>{@code 1154 * // This snippet has been automatically generated and should be regarded as a code template only. 1155 * // It will require modifications to work: 1156 * // - It may require correct/in-range values for request initialization. 1157 * // - It may require specifying regional endpoints when creating the service client as shown in 1158 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1159 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 1160 * ResourceName resource = BillingAccountName.of("[BILLING_ACCOUNT]"); 1161 * Policy response = cloudBillingClient.getIamPolicy(resource); 1162 * } 1163 * }</pre> 1164 * 1165 * @param resource REQUIRED: The resource for which the policy is being requested. See the 1166 * operation documentation for the appropriate value for this field. 1167 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1168 */ getIamPolicy(ResourceName resource)1169 public final Policy getIamPolicy(ResourceName resource) { 1170 GetIamPolicyRequest request = 1171 GetIamPolicyRequest.newBuilder() 1172 .setResource(resource == null ? null : resource.toString()) 1173 .build(); 1174 return getIamPolicy(request); 1175 } 1176 1177 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1178 /** 1179 * Gets the access control policy for a billing account. The caller must have the 1180 * `billing.accounts.getIamPolicy` permission on the account, which is often given to billing 1181 * account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). 1182 * 1183 * <p>Sample code: 1184 * 1185 * <pre>{@code 1186 * // This snippet has been automatically generated and should be regarded as a code template only. 1187 * // It will require modifications to work: 1188 * // - It may require correct/in-range values for request initialization. 1189 * // - It may require specifying regional endpoints when creating the service client as shown in 1190 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1191 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 1192 * String resource = BillingAccountName.of("[BILLING_ACCOUNT]").toString(); 1193 * Policy response = cloudBillingClient.getIamPolicy(resource); 1194 * } 1195 * }</pre> 1196 * 1197 * @param resource REQUIRED: The resource for which the policy is being requested. See the 1198 * operation documentation for the appropriate value for this field. 1199 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1200 */ getIamPolicy(String resource)1201 public final Policy getIamPolicy(String resource) { 1202 GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder().setResource(resource).build(); 1203 return getIamPolicy(request); 1204 } 1205 1206 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1207 /** 1208 * Gets the access control policy for a billing account. The caller must have the 1209 * `billing.accounts.getIamPolicy` permission on the account, which is often given to billing 1210 * account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). 1211 * 1212 * <p>Sample code: 1213 * 1214 * <pre>{@code 1215 * // This snippet has been automatically generated and should be regarded as a code template only. 1216 * // It will require modifications to work: 1217 * // - It may require correct/in-range values for request initialization. 1218 * // - It may require specifying regional endpoints when creating the service client as shown in 1219 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1220 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 1221 * GetIamPolicyRequest request = 1222 * GetIamPolicyRequest.newBuilder() 1223 * .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) 1224 * .setOptions(GetPolicyOptions.newBuilder().build()) 1225 * .build(); 1226 * Policy response = cloudBillingClient.getIamPolicy(request); 1227 * } 1228 * }</pre> 1229 * 1230 * @param request The request object containing all of the parameters for the API call. 1231 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1232 */ getIamPolicy(GetIamPolicyRequest request)1233 public final Policy getIamPolicy(GetIamPolicyRequest request) { 1234 return getIamPolicyCallable().call(request); 1235 } 1236 1237 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1238 /** 1239 * Gets the access control policy for a billing account. The caller must have the 1240 * `billing.accounts.getIamPolicy` permission on the account, which is often given to billing 1241 * account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). 1242 * 1243 * <p>Sample code: 1244 * 1245 * <pre>{@code 1246 * // This snippet has been automatically generated and should be regarded as a code template only. 1247 * // It will require modifications to work: 1248 * // - It may require correct/in-range values for request initialization. 1249 * // - It may require specifying regional endpoints when creating the service client as shown in 1250 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1251 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 1252 * GetIamPolicyRequest request = 1253 * GetIamPolicyRequest.newBuilder() 1254 * .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) 1255 * .setOptions(GetPolicyOptions.newBuilder().build()) 1256 * .build(); 1257 * ApiFuture<Policy> future = cloudBillingClient.getIamPolicyCallable().futureCall(request); 1258 * // Do something. 1259 * Policy response = future.get(); 1260 * } 1261 * }</pre> 1262 */ getIamPolicyCallable()1263 public final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() { 1264 return stub.getIamPolicyCallable(); 1265 } 1266 1267 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1268 /** 1269 * Sets the access control policy for a billing account. Replaces any existing policy. The caller 1270 * must have the `billing.accounts.setIamPolicy` permission on the account, which is often given 1271 * to billing account 1272 * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). 1273 * 1274 * <p>Sample code: 1275 * 1276 * <pre>{@code 1277 * // This snippet has been automatically generated and should be regarded as a code template only. 1278 * // It will require modifications to work: 1279 * // - It may require correct/in-range values for request initialization. 1280 * // - It may require specifying regional endpoints when creating the service client as shown in 1281 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1282 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 1283 * ResourceName resource = BillingAccountName.of("[BILLING_ACCOUNT]"); 1284 * Policy policy = Policy.newBuilder().build(); 1285 * Policy response = cloudBillingClient.setIamPolicy(resource, policy); 1286 * } 1287 * }</pre> 1288 * 1289 * @param resource REQUIRED: The resource for which the policy is being specified. See the 1290 * operation documentation for the appropriate value for this field. 1291 * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the 1292 * policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud 1293 * Platform services (such as Projects) might reject them. 1294 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1295 */ setIamPolicy(ResourceName resource, Policy policy)1296 public final Policy setIamPolicy(ResourceName resource, Policy policy) { 1297 SetIamPolicyRequest request = 1298 SetIamPolicyRequest.newBuilder() 1299 .setResource(resource == null ? null : resource.toString()) 1300 .setPolicy(policy) 1301 .build(); 1302 return setIamPolicy(request); 1303 } 1304 1305 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1306 /** 1307 * Sets the access control policy for a billing account. Replaces any existing policy. The caller 1308 * must have the `billing.accounts.setIamPolicy` permission on the account, which is often given 1309 * to billing account 1310 * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). 1311 * 1312 * <p>Sample code: 1313 * 1314 * <pre>{@code 1315 * // This snippet has been automatically generated and should be regarded as a code template only. 1316 * // It will require modifications to work: 1317 * // - It may require correct/in-range values for request initialization. 1318 * // - It may require specifying regional endpoints when creating the service client as shown in 1319 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1320 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 1321 * String resource = BillingAccountName.of("[BILLING_ACCOUNT]").toString(); 1322 * Policy policy = Policy.newBuilder().build(); 1323 * Policy response = cloudBillingClient.setIamPolicy(resource, policy); 1324 * } 1325 * }</pre> 1326 * 1327 * @param resource REQUIRED: The resource for which the policy is being specified. See the 1328 * operation documentation for the appropriate value for this field. 1329 * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the 1330 * policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud 1331 * Platform services (such as Projects) might reject them. 1332 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1333 */ setIamPolicy(String resource, Policy policy)1334 public final Policy setIamPolicy(String resource, Policy policy) { 1335 SetIamPolicyRequest request = 1336 SetIamPolicyRequest.newBuilder().setResource(resource).setPolicy(policy).build(); 1337 return setIamPolicy(request); 1338 } 1339 1340 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1341 /** 1342 * Sets the access control policy for a billing account. Replaces any existing policy. The caller 1343 * must have the `billing.accounts.setIamPolicy` permission on the account, which is often given 1344 * to billing account 1345 * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). 1346 * 1347 * <p>Sample code: 1348 * 1349 * <pre>{@code 1350 * // This snippet has been automatically generated and should be regarded as a code template only. 1351 * // It will require modifications to work: 1352 * // - It may require correct/in-range values for request initialization. 1353 * // - It may require specifying regional endpoints when creating the service client as shown in 1354 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1355 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 1356 * SetIamPolicyRequest request = 1357 * SetIamPolicyRequest.newBuilder() 1358 * .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) 1359 * .setPolicy(Policy.newBuilder().build()) 1360 * .setUpdateMask(FieldMask.newBuilder().build()) 1361 * .build(); 1362 * Policy response = cloudBillingClient.setIamPolicy(request); 1363 * } 1364 * }</pre> 1365 * 1366 * @param request The request object containing all of the parameters for the API call. 1367 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1368 */ setIamPolicy(SetIamPolicyRequest request)1369 public final Policy setIamPolicy(SetIamPolicyRequest request) { 1370 return setIamPolicyCallable().call(request); 1371 } 1372 1373 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1374 /** 1375 * Sets the access control policy for a billing account. Replaces any existing policy. The caller 1376 * must have the `billing.accounts.setIamPolicy` permission on the account, which is often given 1377 * to billing account 1378 * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). 1379 * 1380 * <p>Sample code: 1381 * 1382 * <pre>{@code 1383 * // This snippet has been automatically generated and should be regarded as a code template only. 1384 * // It will require modifications to work: 1385 * // - It may require correct/in-range values for request initialization. 1386 * // - It may require specifying regional endpoints when creating the service client as shown in 1387 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1388 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 1389 * SetIamPolicyRequest request = 1390 * SetIamPolicyRequest.newBuilder() 1391 * .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) 1392 * .setPolicy(Policy.newBuilder().build()) 1393 * .setUpdateMask(FieldMask.newBuilder().build()) 1394 * .build(); 1395 * ApiFuture<Policy> future = cloudBillingClient.setIamPolicyCallable().futureCall(request); 1396 * // Do something. 1397 * Policy response = future.get(); 1398 * } 1399 * }</pre> 1400 */ setIamPolicyCallable()1401 public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() { 1402 return stub.setIamPolicyCallable(); 1403 } 1404 1405 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1406 /** 1407 * Tests the access control policy for a billing account. This method takes the resource and a set 1408 * of permissions as input and returns the subset of the input permissions that the caller is 1409 * allowed for that resource. 1410 * 1411 * <p>Sample code: 1412 * 1413 * <pre>{@code 1414 * // This snippet has been automatically generated and should be regarded as a code template only. 1415 * // It will require modifications to work: 1416 * // - It may require correct/in-range values for request initialization. 1417 * // - It may require specifying regional endpoints when creating the service client as shown in 1418 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1419 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 1420 * ResourceName resource = BillingAccountName.of("[BILLING_ACCOUNT]"); 1421 * List<String> permissions = new ArrayList<>(); 1422 * TestIamPermissionsResponse response = 1423 * cloudBillingClient.testIamPermissions(resource, permissions); 1424 * } 1425 * }</pre> 1426 * 1427 * @param resource REQUIRED: The resource for which the policy detail is being requested. See the 1428 * operation documentation for the appropriate value for this field. 1429 * @param permissions The set of permissions to check for the `resource`. Permissions with 1430 * wildcards (such as '*' or 'storage.*') are not allowed. For more information see 1431 * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). 1432 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1433 */ testIamPermissions( ResourceName resource, List<String> permissions)1434 public final TestIamPermissionsResponse testIamPermissions( 1435 ResourceName resource, List<String> permissions) { 1436 TestIamPermissionsRequest request = 1437 TestIamPermissionsRequest.newBuilder() 1438 .setResource(resource == null ? null : resource.toString()) 1439 .addAllPermissions(permissions) 1440 .build(); 1441 return testIamPermissions(request); 1442 } 1443 1444 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1445 /** 1446 * Tests the access control policy for a billing account. This method takes the resource and a set 1447 * of permissions as input and returns the subset of the input permissions that the caller is 1448 * allowed for that resource. 1449 * 1450 * <p>Sample code: 1451 * 1452 * <pre>{@code 1453 * // This snippet has been automatically generated and should be regarded as a code template only. 1454 * // It will require modifications to work: 1455 * // - It may require correct/in-range values for request initialization. 1456 * // - It may require specifying regional endpoints when creating the service client as shown in 1457 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1458 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 1459 * String resource = BillingAccountName.of("[BILLING_ACCOUNT]").toString(); 1460 * List<String> permissions = new ArrayList<>(); 1461 * TestIamPermissionsResponse response = 1462 * cloudBillingClient.testIamPermissions(resource, permissions); 1463 * } 1464 * }</pre> 1465 * 1466 * @param resource REQUIRED: The resource for which the policy detail is being requested. See the 1467 * operation documentation for the appropriate value for this field. 1468 * @param permissions The set of permissions to check for the `resource`. Permissions with 1469 * wildcards (such as '*' or 'storage.*') are not allowed. For more information see 1470 * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). 1471 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1472 */ testIamPermissions( String resource, List<String> permissions)1473 public final TestIamPermissionsResponse testIamPermissions( 1474 String resource, List<String> permissions) { 1475 TestIamPermissionsRequest request = 1476 TestIamPermissionsRequest.newBuilder() 1477 .setResource(resource) 1478 .addAllPermissions(permissions) 1479 .build(); 1480 return testIamPermissions(request); 1481 } 1482 1483 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1484 /** 1485 * Tests the access control policy for a billing account. This method takes the resource and a set 1486 * of permissions as input and returns the subset of the input permissions that the caller is 1487 * allowed for that resource. 1488 * 1489 * <p>Sample code: 1490 * 1491 * <pre>{@code 1492 * // This snippet has been automatically generated and should be regarded as a code template only. 1493 * // It will require modifications to work: 1494 * // - It may require correct/in-range values for request initialization. 1495 * // - It may require specifying regional endpoints when creating the service client as shown in 1496 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1497 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 1498 * TestIamPermissionsRequest request = 1499 * TestIamPermissionsRequest.newBuilder() 1500 * .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) 1501 * .addAllPermissions(new ArrayList<String>()) 1502 * .build(); 1503 * TestIamPermissionsResponse response = cloudBillingClient.testIamPermissions(request); 1504 * } 1505 * }</pre> 1506 * 1507 * @param request The request object containing all of the parameters for the API call. 1508 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1509 */ testIamPermissions(TestIamPermissionsRequest request)1510 public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request) { 1511 return testIamPermissionsCallable().call(request); 1512 } 1513 1514 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1515 /** 1516 * Tests the access control policy for a billing account. This method takes the resource and a set 1517 * of permissions as input and returns the subset of the input permissions that the caller is 1518 * allowed for that resource. 1519 * 1520 * <p>Sample code: 1521 * 1522 * <pre>{@code 1523 * // This snippet has been automatically generated and should be regarded as a code template only. 1524 * // It will require modifications to work: 1525 * // - It may require correct/in-range values for request initialization. 1526 * // - It may require specifying regional endpoints when creating the service client as shown in 1527 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1528 * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { 1529 * TestIamPermissionsRequest request = 1530 * TestIamPermissionsRequest.newBuilder() 1531 * .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) 1532 * .addAllPermissions(new ArrayList<String>()) 1533 * .build(); 1534 * ApiFuture<TestIamPermissionsResponse> future = 1535 * cloudBillingClient.testIamPermissionsCallable().futureCall(request); 1536 * // Do something. 1537 * TestIamPermissionsResponse response = future.get(); 1538 * } 1539 * }</pre> 1540 */ 1541 public final UnaryCallable<TestIamPermissionsRequest, TestIamPermissionsResponse> testIamPermissionsCallable()1542 testIamPermissionsCallable() { 1543 return stub.testIamPermissionsCallable(); 1544 } 1545 1546 @Override close()1547 public final void close() { 1548 stub.close(); 1549 } 1550 1551 @Override shutdown()1552 public void shutdown() { 1553 stub.shutdown(); 1554 } 1555 1556 @Override isShutdown()1557 public boolean isShutdown() { 1558 return stub.isShutdown(); 1559 } 1560 1561 @Override isTerminated()1562 public boolean isTerminated() { 1563 return stub.isTerminated(); 1564 } 1565 1566 @Override shutdownNow()1567 public void shutdownNow() { 1568 stub.shutdownNow(); 1569 } 1570 1571 @Override awaitTermination(long duration, TimeUnit unit)1572 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 1573 return stub.awaitTermination(duration, unit); 1574 } 1575 1576 public static class ListBillingAccountsPagedResponse 1577 extends AbstractPagedListResponse< 1578 ListBillingAccountsRequest, 1579 ListBillingAccountsResponse, 1580 BillingAccount, 1581 ListBillingAccountsPage, 1582 ListBillingAccountsFixedSizeCollection> { 1583 createAsync( PageContext<ListBillingAccountsRequest, ListBillingAccountsResponse, BillingAccount> context, ApiFuture<ListBillingAccountsResponse> futureResponse)1584 public static ApiFuture<ListBillingAccountsPagedResponse> createAsync( 1585 PageContext<ListBillingAccountsRequest, ListBillingAccountsResponse, BillingAccount> 1586 context, 1587 ApiFuture<ListBillingAccountsResponse> futureResponse) { 1588 ApiFuture<ListBillingAccountsPage> futurePage = 1589 ListBillingAccountsPage.createEmptyPage().createPageAsync(context, futureResponse); 1590 return ApiFutures.transform( 1591 futurePage, 1592 input -> new ListBillingAccountsPagedResponse(input), 1593 MoreExecutors.directExecutor()); 1594 } 1595 ListBillingAccountsPagedResponse(ListBillingAccountsPage page)1596 private ListBillingAccountsPagedResponse(ListBillingAccountsPage page) { 1597 super(page, ListBillingAccountsFixedSizeCollection.createEmptyCollection()); 1598 } 1599 } 1600 1601 public static class ListBillingAccountsPage 1602 extends AbstractPage< 1603 ListBillingAccountsRequest, 1604 ListBillingAccountsResponse, 1605 BillingAccount, 1606 ListBillingAccountsPage> { 1607 ListBillingAccountsPage( PageContext<ListBillingAccountsRequest, ListBillingAccountsResponse, BillingAccount> context, ListBillingAccountsResponse response)1608 private ListBillingAccountsPage( 1609 PageContext<ListBillingAccountsRequest, ListBillingAccountsResponse, BillingAccount> 1610 context, 1611 ListBillingAccountsResponse response) { 1612 super(context, response); 1613 } 1614 createEmptyPage()1615 private static ListBillingAccountsPage createEmptyPage() { 1616 return new ListBillingAccountsPage(null, null); 1617 } 1618 1619 @Override createPage( PageContext<ListBillingAccountsRequest, ListBillingAccountsResponse, BillingAccount> context, ListBillingAccountsResponse response)1620 protected ListBillingAccountsPage createPage( 1621 PageContext<ListBillingAccountsRequest, ListBillingAccountsResponse, BillingAccount> 1622 context, 1623 ListBillingAccountsResponse response) { 1624 return new ListBillingAccountsPage(context, response); 1625 } 1626 1627 @Override createPageAsync( PageContext<ListBillingAccountsRequest, ListBillingAccountsResponse, BillingAccount> context, ApiFuture<ListBillingAccountsResponse> futureResponse)1628 public ApiFuture<ListBillingAccountsPage> createPageAsync( 1629 PageContext<ListBillingAccountsRequest, ListBillingAccountsResponse, BillingAccount> 1630 context, 1631 ApiFuture<ListBillingAccountsResponse> futureResponse) { 1632 return super.createPageAsync(context, futureResponse); 1633 } 1634 } 1635 1636 public static class ListBillingAccountsFixedSizeCollection 1637 extends AbstractFixedSizeCollection< 1638 ListBillingAccountsRequest, 1639 ListBillingAccountsResponse, 1640 BillingAccount, 1641 ListBillingAccountsPage, 1642 ListBillingAccountsFixedSizeCollection> { 1643 ListBillingAccountsFixedSizeCollection( List<ListBillingAccountsPage> pages, int collectionSize)1644 private ListBillingAccountsFixedSizeCollection( 1645 List<ListBillingAccountsPage> pages, int collectionSize) { 1646 super(pages, collectionSize); 1647 } 1648 createEmptyCollection()1649 private static ListBillingAccountsFixedSizeCollection createEmptyCollection() { 1650 return new ListBillingAccountsFixedSizeCollection(null, 0); 1651 } 1652 1653 @Override createCollection( List<ListBillingAccountsPage> pages, int collectionSize)1654 protected ListBillingAccountsFixedSizeCollection createCollection( 1655 List<ListBillingAccountsPage> pages, int collectionSize) { 1656 return new ListBillingAccountsFixedSizeCollection(pages, collectionSize); 1657 } 1658 } 1659 1660 public static class ListProjectBillingInfoPagedResponse 1661 extends AbstractPagedListResponse< 1662 ListProjectBillingInfoRequest, 1663 ListProjectBillingInfoResponse, 1664 ProjectBillingInfo, 1665 ListProjectBillingInfoPage, 1666 ListProjectBillingInfoFixedSizeCollection> { 1667 createAsync( PageContext< ListProjectBillingInfoRequest, ListProjectBillingInfoResponse, ProjectBillingInfo> context, ApiFuture<ListProjectBillingInfoResponse> futureResponse)1668 public static ApiFuture<ListProjectBillingInfoPagedResponse> createAsync( 1669 PageContext< 1670 ListProjectBillingInfoRequest, ListProjectBillingInfoResponse, ProjectBillingInfo> 1671 context, 1672 ApiFuture<ListProjectBillingInfoResponse> futureResponse) { 1673 ApiFuture<ListProjectBillingInfoPage> futurePage = 1674 ListProjectBillingInfoPage.createEmptyPage().createPageAsync(context, futureResponse); 1675 return ApiFutures.transform( 1676 futurePage, 1677 input -> new ListProjectBillingInfoPagedResponse(input), 1678 MoreExecutors.directExecutor()); 1679 } 1680 ListProjectBillingInfoPagedResponse(ListProjectBillingInfoPage page)1681 private ListProjectBillingInfoPagedResponse(ListProjectBillingInfoPage page) { 1682 super(page, ListProjectBillingInfoFixedSizeCollection.createEmptyCollection()); 1683 } 1684 } 1685 1686 public static class ListProjectBillingInfoPage 1687 extends AbstractPage< 1688 ListProjectBillingInfoRequest, 1689 ListProjectBillingInfoResponse, 1690 ProjectBillingInfo, 1691 ListProjectBillingInfoPage> { 1692 ListProjectBillingInfoPage( PageContext< ListProjectBillingInfoRequest, ListProjectBillingInfoResponse, ProjectBillingInfo> context, ListProjectBillingInfoResponse response)1693 private ListProjectBillingInfoPage( 1694 PageContext< 1695 ListProjectBillingInfoRequest, ListProjectBillingInfoResponse, ProjectBillingInfo> 1696 context, 1697 ListProjectBillingInfoResponse response) { 1698 super(context, response); 1699 } 1700 createEmptyPage()1701 private static ListProjectBillingInfoPage createEmptyPage() { 1702 return new ListProjectBillingInfoPage(null, null); 1703 } 1704 1705 @Override createPage( PageContext< ListProjectBillingInfoRequest, ListProjectBillingInfoResponse, ProjectBillingInfo> context, ListProjectBillingInfoResponse response)1706 protected ListProjectBillingInfoPage createPage( 1707 PageContext< 1708 ListProjectBillingInfoRequest, ListProjectBillingInfoResponse, ProjectBillingInfo> 1709 context, 1710 ListProjectBillingInfoResponse response) { 1711 return new ListProjectBillingInfoPage(context, response); 1712 } 1713 1714 @Override createPageAsync( PageContext< ListProjectBillingInfoRequest, ListProjectBillingInfoResponse, ProjectBillingInfo> context, ApiFuture<ListProjectBillingInfoResponse> futureResponse)1715 public ApiFuture<ListProjectBillingInfoPage> createPageAsync( 1716 PageContext< 1717 ListProjectBillingInfoRequest, ListProjectBillingInfoResponse, ProjectBillingInfo> 1718 context, 1719 ApiFuture<ListProjectBillingInfoResponse> futureResponse) { 1720 return super.createPageAsync(context, futureResponse); 1721 } 1722 } 1723 1724 public static class ListProjectBillingInfoFixedSizeCollection 1725 extends AbstractFixedSizeCollection< 1726 ListProjectBillingInfoRequest, 1727 ListProjectBillingInfoResponse, 1728 ProjectBillingInfo, 1729 ListProjectBillingInfoPage, 1730 ListProjectBillingInfoFixedSizeCollection> { 1731 ListProjectBillingInfoFixedSizeCollection( List<ListProjectBillingInfoPage> pages, int collectionSize)1732 private ListProjectBillingInfoFixedSizeCollection( 1733 List<ListProjectBillingInfoPage> pages, int collectionSize) { 1734 super(pages, collectionSize); 1735 } 1736 createEmptyCollection()1737 private static ListProjectBillingInfoFixedSizeCollection createEmptyCollection() { 1738 return new ListProjectBillingInfoFixedSizeCollection(null, 0); 1739 } 1740 1741 @Override createCollection( List<ListProjectBillingInfoPage> pages, int collectionSize)1742 protected ListProjectBillingInfoFixedSizeCollection createCollection( 1743 List<ListProjectBillingInfoPage> pages, int collectionSize) { 1744 return new ListProjectBillingInfoFixedSizeCollection(pages, collectionSize); 1745 } 1746 } 1747 } 1748