Retrieves the Google Cloud Console billing accounts and associates them with projects.
Equality
Instances of this class created via copy-construction or copy-assignment always compare equal. Instances created with equal std::shared_ptr<*Connection>
objects compare equal. Objects that compare equal share the same underlying resources.
Performance
Creating a new instance of this class is a relatively expensive operation, new objects establish new connections to the service. In contrast, copy-construction, move-construction, and the corresponding assignment operations are relatively efficient as the copies share all underlying resources.
Thread Safety
Concurrent access to different instances of this class, even if they compare equal, is guaranteed to work. Two or more threads operating on the same instance of this class is not guaranteed to work. Since copy-construction and move-construction is a relatively efficient operation, consider using such a copy when using this class from multiple threads.
Constructors
CloudBillingClient(CloudBillingClient const &)
Copy and move support
Parameter | |
---|---|
Name | Description |
|
CloudBillingClient const &
|
CloudBillingClient(CloudBillingClient &&)
Copy and move support
Parameter | |
---|---|
Name | Description |
|
CloudBillingClient &&
|
CloudBillingClient(std::shared_ptr< CloudBillingConnection >, Options)
Parameters | |
---|---|
Name | Description |
connection |
std::shared_ptr< CloudBillingConnection >
|
opts |
Options
|
Operators
operator=(CloudBillingClient const &)
Copy and move support
Parameter | |
---|---|
Name | Description |
|
CloudBillingClient const &
|
Returns | |
---|---|
Type | Description |
CloudBillingClient & |
operator=(CloudBillingClient &&)
Copy and move support
Parameter | |
---|---|
Name | Description |
|
CloudBillingClient &&
|
Returns | |
---|---|
Type | Description |
CloudBillingClient & |
Functions
GetBillingAccount(std::string const &, Options)
Gets information about a billing account.
The current authenticated user must be a viewer of the billing account.
Parameters | |
---|---|
Name | Description |
name |
std::string const &
Required. The resource name of the billing account to retrieve. For example, |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StatusOr< google::cloud::billing::v1::BillingAccount > | the result of the RPC. The response message type (google.cloud.billing.v1.BillingAccount) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the |
GetBillingAccount(google::cloud::billing::v1::GetBillingAccountRequest const &, Options)
Gets information about a billing account.
The current authenticated user must be a viewer of the billing account.
Parameters | |
---|---|
Name | Description |
request |
google::cloud::billing::v1::GetBillingAccountRequest const &
Unary RPCs, such as the one wrapped by this function, receive a single |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StatusOr< google::cloud::billing::v1::BillingAccount > | the result of the RPC. The response message type (google.cloud.billing.v1.BillingAccount) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the |
ListBillingAccounts(Options)
Lists the billing accounts that the current authenticated user has permission to view.
Parameter | |
---|---|
Name | Description |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StreamRange< google::cloud::billing::v1::BillingAccount > | a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has |
ListBillingAccounts(google::cloud::billing::v1::ListBillingAccountsRequest, Options)
Lists the billing accounts that the current authenticated user has permission to view.
Parameters | |
---|---|
Name | Description |
request |
google::cloud::billing::v1::ListBillingAccountsRequest
Unary RPCs, such as the one wrapped by this function, receive a single |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StreamRange< google::cloud::billing::v1::BillingAccount > | a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has |
UpdateBillingAccount(std::string const &, google::cloud::billing::v1::BillingAccount const &, Options)
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 of the billing account.
Parameters | |
---|---|
Name | Description |
name |
std::string const &
Required. The name of the billing account resource to be updated. |
account |
google::cloud::billing::v1::BillingAccount const &
Required. The billing account resource to replace the resource on the server. |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StatusOr< google::cloud::billing::v1::BillingAccount > | the result of the RPC. The response message type (google.cloud.billing.v1.BillingAccount) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the |
UpdateBillingAccount(google::cloud::billing::v1::UpdateBillingAccountRequest const &, Options)
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 of the billing account.
Parameters | |
---|---|
Name | Description |
request |
google::cloud::billing::v1::UpdateBillingAccountRequest const &
Unary RPCs, such as the one wrapped by this function, receive a single |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StatusOr< google::cloud::billing::v1::BillingAccount > | the result of the RPC. The response message type (google.cloud.billing.v1.BillingAccount) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the |
CreateBillingAccount(google::cloud::billing::v1::BillingAccount const &, Options)
This method creates billing subaccounts.
Google Cloud resellers should use the Channel Services APIs, accounts.customers.create and 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. This method will return an error if the parent account has not been provisioned for subaccounts.
Parameters | |
---|---|
Name | Description |
billing_account |
google::cloud::billing::v1::BillingAccount const &
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. |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StatusOr< google::cloud::billing::v1::BillingAccount > | the result of the RPC. The response message type (google.cloud.billing.v1.BillingAccount) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the |
CreateBillingAccount(google::cloud::billing::v1::CreateBillingAccountRequest const &, Options)
This method creates billing subaccounts.
Google Cloud resellers should use the Channel Services APIs, accounts.customers.create and 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. This method will return an error if the parent account has not been provisioned for subaccounts.
Parameters | |
---|---|
Name | Description |
request |
google::cloud::billing::v1::CreateBillingAccountRequest const &
Unary RPCs, such as the one wrapped by this function, receive a single |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StatusOr< google::cloud::billing::v1::BillingAccount > | the result of the RPC. The response message type (google.cloud.billing.v1.BillingAccount) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the |
ListProjectBillingInfo(std::string const &, Options)
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.
Parameters | |
---|---|
Name | Description |
name |
std::string const &
Required. The resource name of the billing account associated with the projects that you want to list. For example, |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StreamRange< google::cloud::billing::v1::ProjectBillingInfo > | a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has |
ListProjectBillingInfo(google::cloud::billing::v1::ListProjectBillingInfoRequest, Options)
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.
Parameters | |
---|---|
Name | Description |
request |
google::cloud::billing::v1::ListProjectBillingInfoRequest
Unary RPCs, such as the one wrapped by this function, receive a single |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StreamRange< google::cloud::billing::v1::ProjectBillingInfo > | a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has |
GetProjectBillingInfo(std::string const &, Options)
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 role.
Parameters | |
---|---|
Name | Description |
name |
std::string const &
Required. The resource name of the project for which billing information is retrieved. For example, |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StatusOr< google::cloud::billing::v1::ProjectBillingInfo > | the result of the RPC. The response message type (google.cloud.billing.v1.ProjectBillingInfo) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the |
GetProjectBillingInfo(google::cloud::billing::v1::GetProjectBillingInfoRequest const &, Options)
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 role.
Parameters | |
---|---|
Name | Description |
request |
google::cloud::billing::v1::GetProjectBillingInfoRequest const &
Unary RPCs, such as the one wrapped by this function, receive a single |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StatusOr< google::cloud::billing::v1::ProjectBillingInfo > | the result of the RPC. The response message type (google.cloud.billing.v1.ProjectBillingInfo) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the |
UpdateProjectBillingInfo(std::string const &, google::cloud::billing::v1::ProjectBillingInfo const &, Options)
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 and the billing account.
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.
Parameters | |
---|---|
Name | Description |
name |
std::string const &
Required. The resource name of the project associated with the billing information that you want to update. For example, |
project_billing_info |
google::cloud::billing::v1::ProjectBillingInfo const &
The new billing information for the project. Output-only fields are ignored; thus, you can leave empty all fields except |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StatusOr< google::cloud::billing::v1::ProjectBillingInfo > | the result of the RPC. The response message type (google.cloud.billing.v1.ProjectBillingInfo) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the |
UpdateProjectBillingInfo(google::cloud::billing::v1::UpdateProjectBillingInfoRequest const &, Options)
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 and the billing account.
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.
Parameters | |
---|---|
Name | Description |
request |
google::cloud::billing::v1::UpdateProjectBillingInfoRequest const &
Unary RPCs, such as the one wrapped by this function, receive a single |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StatusOr< google::cloud::billing::v1::ProjectBillingInfo > | the result of the RPC. The response message type (google.cloud.billing.v1.ProjectBillingInfo) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the |
GetIamPolicy(std::string const &, Options)
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.
Parameters | |
---|---|
Name | Description |
resource |
std::string const &
REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StatusOr< google::iam::v1::Policy > | the result of the RPC. The response message type (google.iam.v1.Policy) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the |
GetIamPolicy(google::iam::v1::GetIamPolicyRequest const &, Options)
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.
Parameters | |
---|---|
Name | Description |
request |
google::iam::v1::GetIamPolicyRequest const &
Unary RPCs, such as the one wrapped by this function, receive a single |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StatusOr< google::iam::v1::Policy > | the result of the RPC. The response message type (google.iam.v1.Policy) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the |
SetIamPolicy(std::string const &, google::iam::v1::Policy const &, Options)
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.
Parameters | |
---|---|
Name | Description |
resource |
std::string const &
REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. |
policy |
google::iam::v1::Policy const &
REQUIRED: The complete policy to be applied to the |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StatusOr< google::iam::v1::Policy > | the result of the RPC. The response message type (google.iam.v1.Policy) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the |
SetIamPolicy(std::string const &, IamUpdater const &, Options)
Updates the IAM policy for resource
using an optimistic concurrency control loop.
The loop fetches the current policy for resource
, and passes it to updater
, which should return the new policy. This new policy should use the current etag so that the read-modify-write cycle can detect races and rerun the update when there is a mismatch. If the new policy does not have an etag, the existing policy will be blindly overwritten. If updater
does not yield a policy, the control loop is terminated and kCancelled is returned.
Parameters | |
---|---|
Name | Description |
resource |
std::string const &
Required. The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. |
updater |
IamUpdater const &
Required. Functor to map the current policy to a new one. |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StatusOr< google::iam::v1::Policy > | google::iam::v1::Policy |
SetIamPolicy(google::iam::v1::SetIamPolicyRequest const &, Options)
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.
Parameters | |
---|---|
Name | Description |
request |
google::iam::v1::SetIamPolicyRequest const &
Unary RPCs, such as the one wrapped by this function, receive a single |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StatusOr< google::iam::v1::Policy > | the result of the RPC. The response message type (google.iam.v1.Policy) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the |
TestIamPermissions(std::string const &, std::vector< std::string > const &, Options)
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.
Parameters | |
---|---|
Name | Description |
resource |
std::string const &
REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. |
permissions |
std::vector< std::string > const &
The set of permissions to check for the |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StatusOr< google::iam::v1::TestIamPermissionsResponse > | the result of the RPC. The response message type (google.iam.v1.TestIamPermissionsResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the |
TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const &, Options)
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.
Parameters | |
---|---|
Name | Description |
request |
google::iam::v1::TestIamPermissionsRequest const &
Unary RPCs, such as the one wrapped by this function, receive a single |
opts |
Options
Optional. Override the class-level options, such as retry and backoff policies. |
Returns | |
---|---|
Type | Description |
StatusOr< google::iam::v1::TestIamPermissionsResponse > | the result of the RPC. The response message type (google.iam.v1.TestIamPermissionsResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the |