Class CloudBillingClient
- java.lang.Object
-
- com.google.cloud.billing.v1.CloudBillingClient
-
- All Implemented Interfaces:
com.google.api.gax.core.BackgroundResource
,AutoCloseable
@Generated("by gapic-generator-java") public class CloudBillingClient extends Object implements com.google.api.gax.core.BackgroundResource
Service Description: Retrieves the Google Cloud Console billing accounts and associates them with projects.This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { BillingAccountName name = BillingAccountName.of("[BILLING_ACCOUNT]"); BillingAccount response = cloudBillingClient.getBillingAccount(name); }
Note: close() needs to be called on the CloudBillingClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of CloudBillingSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library CloudBillingSettings cloudBillingSettings = CloudBillingSettings.newBuilder() .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) .build(); CloudBillingClient cloudBillingClient = CloudBillingClient.create(cloudBillingSettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library CloudBillingSettings cloudBillingSettings = CloudBillingSettings.newBuilder().setEndpoint(myEndpoint).build(); CloudBillingClient cloudBillingClient = CloudBillingClient.create(cloudBillingSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library CloudBillingSettings cloudBillingSettings = CloudBillingSettings.newHttpJsonBuilder().build(); CloudBillingClient cloudBillingClient = CloudBillingClient.create(cloudBillingSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CloudBillingClient.ListBillingAccountsFixedSizeCollection
static class
CloudBillingClient.ListBillingAccountsPage
static class
CloudBillingClient.ListBillingAccountsPagedResponse
static class
CloudBillingClient.ListProjectBillingInfoFixedSizeCollection
static class
CloudBillingClient.ListProjectBillingInfoPage
static class
CloudBillingClient.ListProjectBillingInfoPagedResponse
-
Constructor Summary
Constructors Modifier Constructor Description protected
CloudBillingClient(CloudBillingSettings settings)
Constructs an instance of CloudBillingClient, using the given settings.protected
CloudBillingClient(CloudBillingStub stub)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
awaitTermination(long duration, TimeUnit unit)
void
close()
static CloudBillingClient
create()
Constructs an instance of CloudBillingClient with default settings.static CloudBillingClient
create(CloudBillingSettings settings)
Constructs an instance of CloudBillingClient, using the given settings.static CloudBillingClient
create(CloudBillingStub stub)
Constructs an instance of CloudBillingClient, using the given stub for making calls.BillingAccount
createBillingAccount(BillingAccount billingAccount)
This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts).BillingAccount
createBillingAccount(CreateBillingAccountRequest request)
This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts).com.google.api.gax.rpc.UnaryCallable<CreateBillingAccountRequest,BillingAccount>
createBillingAccountCallable()
This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts).BillingAccount
getBillingAccount(BillingAccountName name)
Gets information about a billing account.BillingAccount
getBillingAccount(GetBillingAccountRequest request)
Gets information about a billing account.BillingAccount
getBillingAccount(String name)
Gets information about a billing account.com.google.api.gax.rpc.UnaryCallable<GetBillingAccountRequest,BillingAccount>
getBillingAccountCallable()
Gets information about a billing account.com.google.iam.v1.Policy
getIamPolicy(com.google.api.resourcenames.ResourceName resource)
Gets the access control policy for a billing account.com.google.iam.v1.Policy
getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Gets the access control policy for a billing account.com.google.iam.v1.Policy
getIamPolicy(String resource)
Gets the access control policy for a billing account.com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy>
getIamPolicyCallable()
Gets the access control policy for a billing account.ProjectBillingInfo
getProjectBillingInfo(GetProjectBillingInfoRequest request)
Gets the billing information for a project.ProjectBillingInfo
getProjectBillingInfo(ProjectName name)
Gets the billing information for a project.ProjectBillingInfo
getProjectBillingInfo(String name)
Gets the billing information for a project.com.google.api.gax.rpc.UnaryCallable<GetProjectBillingInfoRequest,ProjectBillingInfo>
getProjectBillingInfoCallable()
Gets the billing information for a project.CloudBillingSettings
getSettings()
CloudBillingStub
getStub()
boolean
isShutdown()
boolean
isTerminated()
CloudBillingClient.ListBillingAccountsPagedResponse
listBillingAccounts()
Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).CloudBillingClient.ListBillingAccountsPagedResponse
listBillingAccounts(ListBillingAccountsRequest request)
Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).com.google.api.gax.rpc.UnaryCallable<ListBillingAccountsRequest,ListBillingAccountsResponse>
listBillingAccountsCallable()
Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).com.google.api.gax.rpc.UnaryCallable<ListBillingAccountsRequest,CloudBillingClient.ListBillingAccountsPagedResponse>
listBillingAccountsPagedCallable()
Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).CloudBillingClient.ListProjectBillingInfoPagedResponse
listProjectBillingInfo(BillingAccountName name)
Lists the projects associated with a billing account.CloudBillingClient.ListProjectBillingInfoPagedResponse
listProjectBillingInfo(ListProjectBillingInfoRequest request)
Lists the projects associated with a billing account.CloudBillingClient.ListProjectBillingInfoPagedResponse
listProjectBillingInfo(String name)
Lists the projects associated with a billing account.com.google.api.gax.rpc.UnaryCallable<ListProjectBillingInfoRequest,ListProjectBillingInfoResponse>
listProjectBillingInfoCallable()
Lists the projects associated with a billing account.com.google.api.gax.rpc.UnaryCallable<ListProjectBillingInfoRequest,CloudBillingClient.ListProjectBillingInfoPagedResponse>
listProjectBillingInfoPagedCallable()
Lists the projects associated with a billing account.com.google.iam.v1.Policy
setIamPolicy(com.google.api.resourcenames.ResourceName resource, com.google.iam.v1.Policy policy)
Sets the access control policy for a billing account.com.google.iam.v1.Policy
setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Sets the access control policy for a billing account.com.google.iam.v1.Policy
setIamPolicy(String resource, com.google.iam.v1.Policy policy)
Sets the access control policy for a billing account.com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy>
setIamPolicyCallable()
Sets the access control policy for a billing account.void
shutdown()
void
shutdownNow()
com.google.iam.v1.TestIamPermissionsResponse
testIamPermissions(com.google.api.resourcenames.ResourceName resource, List<String> permissions)
Tests the access control policy for a billing account.com.google.iam.v1.TestIamPermissionsResponse
testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
Tests the access control policy for a billing account.com.google.iam.v1.TestIamPermissionsResponse
testIamPermissions(String resource, List<String> permissions)
Tests the access control policy for a billing account.com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse>
testIamPermissionsCallable()
Tests the access control policy for a billing account.BillingAccount
updateBillingAccount(BillingAccountName name, BillingAccount account)
Updates a billing account's fields.BillingAccount
updateBillingAccount(UpdateBillingAccountRequest request)
Updates a billing account's fields.BillingAccount
updateBillingAccount(String name, BillingAccount account)
Updates a billing account's fields.com.google.api.gax.rpc.UnaryCallable<UpdateBillingAccountRequest,BillingAccount>
updateBillingAccountCallable()
Updates a billing account's fields.ProjectBillingInfo
updateProjectBillingInfo(UpdateProjectBillingInfoRequest request)
Sets or updates the billing account associated with a project.ProjectBillingInfo
updateProjectBillingInfo(String name, ProjectBillingInfo projectBillingInfo)
Sets or updates the billing account associated with a project.com.google.api.gax.rpc.UnaryCallable<UpdateProjectBillingInfoRequest,ProjectBillingInfo>
updateProjectBillingInfoCallable()
Sets or updates the billing account associated with a project.
-
-
-
Constructor Detail
-
CloudBillingClient
protected CloudBillingClient(CloudBillingSettings settings) throws IOException
Constructs an instance of CloudBillingClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.- Throws:
IOException
-
CloudBillingClient
protected CloudBillingClient(CloudBillingStub stub)
-
-
Method Detail
-
create
public static final CloudBillingClient create() throws IOException
Constructs an instance of CloudBillingClient with default settings.- Throws:
IOException
-
create
public static final CloudBillingClient create(CloudBillingSettings settings) throws IOException
Constructs an instance of CloudBillingClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.- Throws:
IOException
-
create
public static final CloudBillingClient create(CloudBillingStub stub)
Constructs an instance of CloudBillingClient, using the given stub for making calls. This is for advanced usage - prefer using create(CloudBillingSettings).
-
getSettings
public final CloudBillingSettings getSettings()
-
getStub
public CloudBillingStub getStub()
-
getBillingAccount
public final BillingAccount getBillingAccount(BillingAccountName name)
Gets information about a billing account. The current authenticated user must be a [viewer of the billing account](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { BillingAccountName name = BillingAccountName.of("[BILLING_ACCOUNT]"); BillingAccount response = cloudBillingClient.getBillingAccount(name); }
- Parameters:
name
- Required. The resource name of the billing account to retrieve. For example, `billingAccounts/012345-567890-ABCDEF`.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getBillingAccount
public final BillingAccount getBillingAccount(String name)
Gets information about a billing account. The current authenticated user must be a [viewer of the billing account](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { String name = BillingAccountName.of("[BILLING_ACCOUNT]").toString(); BillingAccount response = cloudBillingClient.getBillingAccount(name); }
- Parameters:
name
- Required. The resource name of the billing account to retrieve. For example, `billingAccounts/012345-567890-ABCDEF`.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getBillingAccount
public final BillingAccount getBillingAccount(GetBillingAccountRequest request)
Gets information about a billing account. The current authenticated user must be a [viewer of the billing account](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { GetBillingAccountRequest request = GetBillingAccountRequest.newBuilder() .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) .build(); BillingAccount response = cloudBillingClient.getBillingAccount(request); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getBillingAccountCallable
public final com.google.api.gax.rpc.UnaryCallable<GetBillingAccountRequest,BillingAccount> getBillingAccountCallable()
Gets information about a billing account. The current authenticated user must be a [viewer of the billing account](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { GetBillingAccountRequest request = GetBillingAccountRequest.newBuilder() .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) .build(); ApiFuture<BillingAccount> future = cloudBillingClient.getBillingAccountCallable().futureCall(request); // Do something. BillingAccount response = future.get(); }
-
listBillingAccounts
public final CloudBillingClient.ListBillingAccountsPagedResponse listBillingAccounts()
Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { for (BillingAccount element : cloudBillingClient.listBillingAccounts().iterateAll()) { // doThingsWith(element); } }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listBillingAccounts
public final CloudBillingClient.ListBillingAccountsPagedResponse listBillingAccounts(ListBillingAccountsRequest request)
Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { ListBillingAccountsRequest request = ListBillingAccountsRequest.newBuilder() .setPageSize(883849137) .setPageToken("pageToken873572522") .setFilter("filter-1274492040") .build(); for (BillingAccount element : cloudBillingClient.listBillingAccounts(request).iterateAll()) { // doThingsWith(element); } }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listBillingAccountsPagedCallable
public final com.google.api.gax.rpc.UnaryCallable<ListBillingAccountsRequest,CloudBillingClient.ListBillingAccountsPagedResponse> listBillingAccountsPagedCallable()
Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { ListBillingAccountsRequest request = ListBillingAccountsRequest.newBuilder() .setPageSize(883849137) .setPageToken("pageToken873572522") .setFilter("filter-1274492040") .build(); ApiFuture<BillingAccount> future = cloudBillingClient.listBillingAccountsPagedCallable().futureCall(request); // Do something. for (BillingAccount element : future.get().iterateAll()) { // doThingsWith(element); } }
-
listBillingAccountsCallable
public final com.google.api.gax.rpc.UnaryCallable<ListBillingAccountsRequest,ListBillingAccountsResponse> listBillingAccountsCallable()
Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { ListBillingAccountsRequest request = ListBillingAccountsRequest.newBuilder() .setPageSize(883849137) .setPageToken("pageToken873572522") .setFilter("filter-1274492040") .build(); while (true) { ListBillingAccountsResponse response = cloudBillingClient.listBillingAccountsCallable().call(request); for (BillingAccount element : response.getBillingAccountsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } }
-
updateBillingAccount
public final BillingAccount updateBillingAccount(BillingAccountName name, BillingAccount account)
Updates a billing account's fields. Currently the only field that can be edited is `display_name`. The current authenticated user must have the `billing.accounts.update` IAM permission, which is typically given to the [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) of the billing account.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { BillingAccountName name = BillingAccountName.of("[BILLING_ACCOUNT]"); BillingAccount account = BillingAccount.newBuilder().build(); BillingAccount response = cloudBillingClient.updateBillingAccount(name, account); }
- Parameters:
name
- Required. The name of the billing account resource to be updated.account
- Required. The billing account resource to replace the resource on the server.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
updateBillingAccount
public final BillingAccount updateBillingAccount(String name, BillingAccount account)
Updates a billing account's fields. Currently the only field that can be edited is `display_name`. The current authenticated user must have the `billing.accounts.update` IAM permission, which is typically given to the [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) of the billing account.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { String name = BillingAccountName.of("[BILLING_ACCOUNT]").toString(); BillingAccount account = BillingAccount.newBuilder().build(); BillingAccount response = cloudBillingClient.updateBillingAccount(name, account); }
- Parameters:
name
- Required. The name of the billing account resource to be updated.account
- Required. The billing account resource to replace the resource on the server.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
updateBillingAccount
public final BillingAccount updateBillingAccount(UpdateBillingAccountRequest request)
Updates a billing account's fields. Currently the only field that can be edited is `display_name`. The current authenticated user must have the `billing.accounts.update` IAM permission, which is typically given to the [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) of the billing account.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { UpdateBillingAccountRequest request = UpdateBillingAccountRequest.newBuilder() .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) .setAccount(BillingAccount.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); BillingAccount response = cloudBillingClient.updateBillingAccount(request); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
updateBillingAccountCallable
public final com.google.api.gax.rpc.UnaryCallable<UpdateBillingAccountRequest,BillingAccount> updateBillingAccountCallable()
Updates a billing account's fields. Currently the only field that can be edited is `display_name`. The current authenticated user must have the `billing.accounts.update` IAM permission, which is typically given to the [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) of the billing account.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { UpdateBillingAccountRequest request = UpdateBillingAccountRequest.newBuilder() .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) .setAccount(BillingAccount.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); ApiFuture<BillingAccount> future = cloudBillingClient.updateBillingAccountCallable().futureCall(request); // Do something. BillingAccount response = future.get(); }
-
createBillingAccount
public final BillingAccount createBillingAccount(BillingAccount billingAccount)
This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts).Google Cloud resellers should use the Channel Services APIs, [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) and [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create).
When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the parent account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the parent account has not been provisioned as a reseller account.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { BillingAccount billingAccount = BillingAccount.newBuilder().build(); BillingAccount response = cloudBillingClient.createBillingAccount(billingAccount); }
- Parameters:
billingAccount
- Required. The billing account resource to create. Currently CreateBillingAccount only supports subaccount creation, so any created billing accounts must be under a provided parent billing account.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
createBillingAccount
public final BillingAccount createBillingAccount(CreateBillingAccountRequest request)
This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts).Google Cloud resellers should use the Channel Services APIs, [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) and [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create).
When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the parent account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the parent account has not been provisioned as a reseller account.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { CreateBillingAccountRequest request = CreateBillingAccountRequest.newBuilder() .setBillingAccount(BillingAccount.newBuilder().build()) .build(); BillingAccount response = cloudBillingClient.createBillingAccount(request); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
createBillingAccountCallable
public final com.google.api.gax.rpc.UnaryCallable<CreateBillingAccountRequest,BillingAccount> createBillingAccountCallable()
This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts).Google Cloud resellers should use the Channel Services APIs, [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) and [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create).
When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the parent account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the parent account has not been provisioned as a reseller account.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { CreateBillingAccountRequest request = CreateBillingAccountRequest.newBuilder() .setBillingAccount(BillingAccount.newBuilder().build()) .build(); ApiFuture<BillingAccount> future = cloudBillingClient.createBillingAccountCallable().futureCall(request); // Do something. BillingAccount response = future.get(); }
-
listProjectBillingInfo
public final CloudBillingClient.ListProjectBillingInfoPagedResponse listProjectBillingInfo(BillingAccountName name)
Lists the projects associated with a billing account. The current authenticated user must have the `billing.resourceAssociations.list` IAM permission, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { BillingAccountName name = BillingAccountName.of("[BILLING_ACCOUNT]"); for (ProjectBillingInfo element : cloudBillingClient.listProjectBillingInfo(name).iterateAll()) { // doThingsWith(element); } }
- Parameters:
name
- Required. The resource name of the billing account associated with the projects that you want to list. For example, `billingAccounts/012345-567890-ABCDEF`.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listProjectBillingInfo
public final CloudBillingClient.ListProjectBillingInfoPagedResponse listProjectBillingInfo(String name)
Lists the projects associated with a billing account. The current authenticated user must have the `billing.resourceAssociations.list` IAM permission, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { String name = BillingAccountName.of("[BILLING_ACCOUNT]").toString(); for (ProjectBillingInfo element : cloudBillingClient.listProjectBillingInfo(name).iterateAll()) { // doThingsWith(element); } }
- Parameters:
name
- Required. The resource name of the billing account associated with the projects that you want to list. For example, `billingAccounts/012345-567890-ABCDEF`.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listProjectBillingInfo
public final CloudBillingClient.ListProjectBillingInfoPagedResponse listProjectBillingInfo(ListProjectBillingInfoRequest request)
Lists the projects associated with a billing account. The current authenticated user must have the `billing.resourceAssociations.list` IAM permission, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { ListProjectBillingInfoRequest request = ListProjectBillingInfoRequest.newBuilder() .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); for (ProjectBillingInfo element : cloudBillingClient.listProjectBillingInfo(request).iterateAll()) { // doThingsWith(element); } }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
listProjectBillingInfoPagedCallable
public final com.google.api.gax.rpc.UnaryCallable<ListProjectBillingInfoRequest,CloudBillingClient.ListProjectBillingInfoPagedResponse> listProjectBillingInfoPagedCallable()
Lists the projects associated with a billing account. The current authenticated user must have the `billing.resourceAssociations.list` IAM permission, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { ListProjectBillingInfoRequest request = ListProjectBillingInfoRequest.newBuilder() .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); ApiFuture<ProjectBillingInfo> future = cloudBillingClient.listProjectBillingInfoPagedCallable().futureCall(request); // Do something. for (ProjectBillingInfo element : future.get().iterateAll()) { // doThingsWith(element); } }
-
listProjectBillingInfoCallable
public final com.google.api.gax.rpc.UnaryCallable<ListProjectBillingInfoRequest,ListProjectBillingInfoResponse> listProjectBillingInfoCallable()
Lists the projects associated with a billing account. The current authenticated user must have the `billing.resourceAssociations.list` IAM permission, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { ListProjectBillingInfoRequest request = ListProjectBillingInfoRequest.newBuilder() .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); while (true) { ListProjectBillingInfoResponse response = cloudBillingClient.listProjectBillingInfoCallable().call(request); for (ProjectBillingInfo element : response.getProjectBillingInfoList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } }
-
getProjectBillingInfo
public final ProjectBillingInfo getProjectBillingInfo(ProjectName name)
Gets the billing information for a project. The current authenticated user must have the `resourcemanager.projects.get` permission for the project, which can be granted by assigning the [Project Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) role.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { ProjectName name = ProjectName.of("[PROJECT]"); ProjectBillingInfo response = cloudBillingClient.getProjectBillingInfo(name); }
- Parameters:
name
- Required. The resource name of the project for which billing information is retrieved. For example, `projects/tokyo-rain-123`.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getProjectBillingInfo
public final ProjectBillingInfo getProjectBillingInfo(String name)
Gets the billing information for a project. The current authenticated user must have the `resourcemanager.projects.get` permission for the project, which can be granted by assigning the [Project Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) role.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { String name = ProjectName.of("[PROJECT]").toString(); ProjectBillingInfo response = cloudBillingClient.getProjectBillingInfo(name); }
- Parameters:
name
- Required. The resource name of the project for which billing information is retrieved. For example, `projects/tokyo-rain-123`.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getProjectBillingInfo
public final ProjectBillingInfo getProjectBillingInfo(GetProjectBillingInfoRequest request)
Gets the billing information for a project. The current authenticated user must have the `resourcemanager.projects.get` permission for the project, which can be granted by assigning the [Project Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) role.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { GetProjectBillingInfoRequest request = GetProjectBillingInfoRequest.newBuilder() .setName(ProjectName.of("[PROJECT]").toString()) .build(); ProjectBillingInfo response = cloudBillingClient.getProjectBillingInfo(request); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getProjectBillingInfoCallable
public final com.google.api.gax.rpc.UnaryCallable<GetProjectBillingInfoRequest,ProjectBillingInfo> getProjectBillingInfoCallable()
Gets the billing information for a project. The current authenticated user must have the `resourcemanager.projects.get` permission for the project, which can be granted by assigning the [Project Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) role.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { GetProjectBillingInfoRequest request = GetProjectBillingInfoRequest.newBuilder() .setName(ProjectName.of("[PROJECT]").toString()) .build(); ApiFuture<ProjectBillingInfo> future = cloudBillingClient.getProjectBillingInfoCallable().futureCall(request); // Do something. ProjectBillingInfo response = future.get(); }
-
updateProjectBillingInfo
public final ProjectBillingInfo updateProjectBillingInfo(String name, ProjectBillingInfo projectBillingInfo)
Sets or updates the billing account associated with a project. You specify the new billing account by setting the `billing_account_name` in the `ProjectBillingInfo` resource to the resource name of a billing account. Associating a project with an open billing account enables billing on the project and allows charges for resource usage. If the project already had a billing account, this method changes the billing account used for resource usage charges.*Note:* Incurred charges that have not yet been reported in the transaction history of the Google Cloud Console might be billed to the new billing account, even if the charge occurred before the new billing account was assigned to the project.
The current authenticated user must have ownership privileges for both the [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing account](https://cloud.google.com/billing/docs/how-to/billing-access).
You can disable billing on the project by setting the `billing_account_name` field to empty. This action disassociates the current billing account from the project. Any billable activity of your in-use services will stop, and your application could stop functioning as expected. Any unbilled charges to date will be billed to the previously associated account. The current authenticated user must be either an owner of the project or an owner of the billing account for the project.
Note that associating a project with a *closed* billing account will have much the same effect as disabling billing on the project: any paid resources used by the project will be shut down. Thus, unless you wish to disable billing, you should always call this method with the name of an
- open* billing account.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { String name = "name3373707"; ProjectBillingInfo projectBillingInfo = ProjectBillingInfo.newBuilder().build(); ProjectBillingInfo response = cloudBillingClient.updateProjectBillingInfo(name, projectBillingInfo); }
- Parameters:
name
- Required. The resource name of the project associated with the billing information that you want to update. For example, `projects/tokyo-rain-123`.projectBillingInfo
- The new billing information for the project. Output-only fields are ignored; thus, you can leave empty all fields except `billing_account_name`.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
updateProjectBillingInfo
public final ProjectBillingInfo updateProjectBillingInfo(UpdateProjectBillingInfoRequest request)
Sets or updates the billing account associated with a project. You specify the new billing account by setting the `billing_account_name` in the `ProjectBillingInfo` resource to the resource name of a billing account. Associating a project with an open billing account enables billing on the project and allows charges for resource usage. If the project already had a billing account, this method changes the billing account used for resource usage charges.*Note:* Incurred charges that have not yet been reported in the transaction history of the Google Cloud Console might be billed to the new billing account, even if the charge occurred before the new billing account was assigned to the project.
The current authenticated user must have ownership privileges for both the [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing account](https://cloud.google.com/billing/docs/how-to/billing-access).
You can disable billing on the project by setting the `billing_account_name` field to empty. This action disassociates the current billing account from the project. Any billable activity of your in-use services will stop, and your application could stop functioning as expected. Any unbilled charges to date will be billed to the previously associated account. The current authenticated user must be either an owner of the project or an owner of the billing account for the project.
Note that associating a project with a *closed* billing account will have much the same effect as disabling billing on the project: any paid resources used by the project will be shut down. Thus, unless you wish to disable billing, you should always call this method with the name of an
- open* billing account.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { UpdateProjectBillingInfoRequest request = UpdateProjectBillingInfoRequest.newBuilder() .setName("name3373707") .setProjectBillingInfo(ProjectBillingInfo.newBuilder().build()) .build(); ProjectBillingInfo response = cloudBillingClient.updateProjectBillingInfo(request); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
updateProjectBillingInfoCallable
public final com.google.api.gax.rpc.UnaryCallable<UpdateProjectBillingInfoRequest,ProjectBillingInfo> updateProjectBillingInfoCallable()
Sets or updates the billing account associated with a project. You specify the new billing account by setting the `billing_account_name` in the `ProjectBillingInfo` resource to the resource name of a billing account. Associating a project with an open billing account enables billing on the project and allows charges for resource usage. If the project already had a billing account, this method changes the billing account used for resource usage charges.*Note:* Incurred charges that have not yet been reported in the transaction history of the Google Cloud Console might be billed to the new billing account, even if the charge occurred before the new billing account was assigned to the project.
The current authenticated user must have ownership privileges for both the [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing account](https://cloud.google.com/billing/docs/how-to/billing-access).
You can disable billing on the project by setting the `billing_account_name` field to empty. This action disassociates the current billing account from the project. Any billable activity of your in-use services will stop, and your application could stop functioning as expected. Any unbilled charges to date will be billed to the previously associated account. The current authenticated user must be either an owner of the project or an owner of the billing account for the project.
Note that associating a project with a *closed* billing account will have much the same effect as disabling billing on the project: any paid resources used by the project will be shut down. Thus, unless you wish to disable billing, you should always call this method with the name of an
- open* billing account.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { UpdateProjectBillingInfoRequest request = UpdateProjectBillingInfoRequest.newBuilder() .setName("name3373707") .setProjectBillingInfo(ProjectBillingInfo.newBuilder().build()) .build(); ApiFuture<ProjectBillingInfo> future = cloudBillingClient.updateProjectBillingInfoCallable().futureCall(request); // Do something. ProjectBillingInfo response = future.get(); }
-
getIamPolicy
public final com.google.iam.v1.Policy getIamPolicy(com.google.api.resourcenames.ResourceName resource)
Gets the access control policy for a billing account. The caller must have the `billing.accounts.getIamPolicy` permission on the account, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { ResourceName resource = BillingAccountName.of("[BILLING_ACCOUNT]"); Policy response = cloudBillingClient.getIamPolicy(resource); }
- Parameters:
resource
- REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getIamPolicy
public final com.google.iam.v1.Policy getIamPolicy(String resource)
Gets the access control policy for a billing account. The caller must have the `billing.accounts.getIamPolicy` permission on the account, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { String resource = BillingAccountName.of("[BILLING_ACCOUNT]").toString(); Policy response = cloudBillingClient.getIamPolicy(resource); }
- Parameters:
resource
- REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getIamPolicy
public final com.google.iam.v1.Policy getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Gets the access control policy for a billing account. The caller must have the `billing.accounts.getIamPolicy` permission on the account, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); Policy response = cloudBillingClient.getIamPolicy(request); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
getIamPolicyCallable
public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> getIamPolicyCallable()
Gets the access control policy for a billing account. The caller must have the `billing.accounts.getIamPolicy` permission on the account, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); ApiFuture<Policy> future = cloudBillingClient.getIamPolicyCallable().futureCall(request); // Do something. Policy response = future.get(); }
-
setIamPolicy
public final com.google.iam.v1.Policy setIamPolicy(com.google.api.resourcenames.ResourceName resource, com.google.iam.v1.Policy policy)
Sets the access control policy for a billing account. Replaces any existing policy. The caller must have the `billing.accounts.setIamPolicy` permission on the account, which is often given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { ResourceName resource = BillingAccountName.of("[BILLING_ACCOUNT]"); Policy policy = Policy.newBuilder().build(); Policy response = cloudBillingClient.setIamPolicy(resource, policy); }
- Parameters:
resource
- REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.policy
- REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
setIamPolicy
public final com.google.iam.v1.Policy setIamPolicy(String resource, com.google.iam.v1.Policy policy)
Sets the access control policy for a billing account. Replaces any existing policy. The caller must have the `billing.accounts.setIamPolicy` permission on the account, which is often given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { String resource = BillingAccountName.of("[BILLING_ACCOUNT]").toString(); Policy policy = Policy.newBuilder().build(); Policy response = cloudBillingClient.setIamPolicy(resource, policy); }
- Parameters:
resource
- REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.policy
- REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
setIamPolicy
public final com.google.iam.v1.Policy setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Sets the access control policy for a billing account. Replaces any existing policy. The caller must have the `billing.accounts.setIamPolicy` permission on the account, which is often given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); Policy response = cloudBillingClient.setIamPolicy(request); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
setIamPolicyCallable
public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> setIamPolicyCallable()
Sets the access control policy for a billing account. Replaces any existing policy. The caller must have the `billing.accounts.setIamPolicy` permission on the account, which is often given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); ApiFuture<Policy> future = cloudBillingClient.setIamPolicyCallable().futureCall(request); // Do something. Policy response = future.get(); }
-
testIamPermissions
public final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(com.google.api.resourcenames.ResourceName resource, List<String> permissions)
Tests the access control policy for a billing account. This method takes the resource and a set of permissions as input and returns the subset of the input permissions that the caller is allowed for that resource.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { ResourceName resource = BillingAccountName.of("[BILLING_ACCOUNT]"); List<String> permissions = new ArrayList<>(); TestIamPermissionsResponse response = cloudBillingClient.testIamPermissions(resource, permissions); }
- Parameters:
resource
- REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.permissions
- The set of permissions to check for the `resource`. Permissions with wildcards (such as '*' or 'storage.*') are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
testIamPermissions
public final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(String resource, List<String> permissions)
Tests the access control policy for a billing account. This method takes the resource and a set of permissions as input and returns the subset of the input permissions that the caller is allowed for that resource.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { String resource = BillingAccountName.of("[BILLING_ACCOUNT]").toString(); List<String> permissions = new ArrayList<>(); TestIamPermissionsResponse response = cloudBillingClient.testIamPermissions(resource, permissions); }
- Parameters:
resource
- REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.permissions
- The set of permissions to check for the `resource`. Permissions with wildcards (such as '*' or 'storage.*') are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
testIamPermissions
public final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
Tests the access control policy for a billing account. This method takes the resource and a set of permissions as input and returns the subset of the input permissions that the caller is allowed for that resource.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) .addAllPermissions(new ArrayList<String>()) .build(); TestIamPermissionsResponse response = cloudBillingClient.testIamPermissions(request); }
- Parameters:
request
- The request object containing all of the parameters for the API call.- Throws:
com.google.api.gax.rpc.ApiException
- if the remote call fails
-
testIamPermissionsCallable
public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> testIamPermissionsCallable()
Tests the access control policy for a billing account. This method takes the resource and a set of permissions as input and returns the subset of the input permissions that the caller is allowed for that resource.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString()) .addAllPermissions(new ArrayList<String>()) .build(); ApiFuture<TestIamPermissionsResponse> future = cloudBillingClient.testIamPermissionsCallable().futureCall(request); // Do something. TestIamPermissionsResponse response = future.get(); }
-
close
public final void close()
- Specified by:
close
in interfaceAutoCloseable
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfacecom.google.api.gax.core.BackgroundResource
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdown
in interfacecom.google.api.gax.core.BackgroundResource
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminated
in interfacecom.google.api.gax.core.BackgroundResource
-
shutdownNow
public void shutdownNow()
- Specified by:
shutdownNow
in interfacecom.google.api.gax.core.BackgroundResource
-
awaitTermination
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
- Specified by:
awaitTermination
in interfacecom.google.api.gax.core.BackgroundResource
- Throws:
InterruptedException
-
-