Reference documentation and code samples for the Google Cloud Billing V1 Client class CloudBillingClient.
Service Description: Retrieves the Google Cloud Console billing accounts and associates them with projects.
This class is currently experimental and may be subject to changes.
Namespace
Google \ Cloud \ Billing \ V1 \ ClientMethods
__construct
Constructor.
Parameters | |
---|---|
Name | Description |
options |
array
Optional. Options for configuring the service API wrapper. |
↳ apiEndpoint |
string
The address of the API remote host. May optionally include the port, formatted as "
|
↳ credentials |
string|array|FetchAuthTokenInterface|CredentialsWrapper
The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. |
↳ credentialsConfig |
array
Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() . |
↳ disableRetries |
bool
Determines whether or not retries defined by the client configuration should be disabled. Defaults to |
↳ clientConfig |
string|array
Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder. |
↳ transport |
string|TransportInterface
The transport used for executing network requests. May be either the string |
↳ transportConfig |
array
Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options. |
↳ clientCertSource |
callable
A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS. |
createBillingAccount
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 as a reseller account.
The async variant is Google\Cloud\Billing\V1\Client\BaseClient\self::createBillingAccountAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Billing\V1\CreateBillingAccountRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Billing\V1\BillingAccount |
getBillingAccount
Gets information about a billing account. The current authenticated user must be a viewer of the billing account.
The async variant is Google\Cloud\Billing\V1\Client\BaseClient\self::getBillingAccountAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Billing\V1\GetBillingAccountRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Billing\V1\BillingAccount |
getIamPolicy
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.
The async variant is Google\Cloud\Billing\V1\Client\BaseClient\self::getIamPolicyAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Iam\V1\GetIamPolicyRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Iam\V1\Policy |
getProjectBillingInfo
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.
The async variant is Google\Cloud\Billing\V1\Client\BaseClient\self::getProjectBillingInfoAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Billing\V1\GetProjectBillingInfoRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Billing\V1\ProjectBillingInfo |
listBillingAccounts
Lists the billing accounts that the current authenticated user has permission to view.
The async variant is Google\Cloud\Billing\V1\Client\BaseClient\self::listBillingAccountsAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Billing\V1\ListBillingAccountsRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
listProjectBillingInfo
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.
The async variant is Google\Cloud\Billing\V1\Client\BaseClient\self::listProjectBillingInfoAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Billing\V1\ListProjectBillingInfoRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
setIamPolicy
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.
The async variant is Google\Cloud\Billing\V1\Client\BaseClient\self::setIamPolicyAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Iam\V1\SetIamPolicyRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Iam\V1\Policy |
testIamPermissions
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.
The async variant is Google\Cloud\Billing\V1\Client\BaseClient\self::testIamPermissionsAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Iam\V1\TestIamPermissionsRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Iam\V1\TestIamPermissionsResponse |
updateBillingAccount
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.
The async variant is Google\Cloud\Billing\V1\Client\BaseClient\self::updateBillingAccountAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Billing\V1\UpdateBillingAccountRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Billing\V1\BillingAccount |
updateProjectBillingInfo
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.
The async variant is Google\Cloud\Billing\V1\Client\BaseClient\self::updateProjectBillingInfoAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Billing\V1\UpdateProjectBillingInfoRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Billing\V1\ProjectBillingInfo |
createBillingAccountAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Billing\V1\CreateBillingAccountRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
getBillingAccountAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Billing\V1\GetBillingAccountRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
getIamPolicyAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Iam\V1\GetIamPolicyRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
getProjectBillingInfoAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Billing\V1\GetProjectBillingInfoRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
listBillingAccountsAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Billing\V1\ListBillingAccountsRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
listProjectBillingInfoAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Billing\V1\ListProjectBillingInfoRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
setIamPolicyAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Iam\V1\SetIamPolicyRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
testIamPermissionsAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Iam\V1\TestIamPermissionsRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
updateBillingAccountAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Billing\V1\UpdateBillingAccountRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
updateProjectBillingInfoAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Billing\V1\UpdateProjectBillingInfoRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
static::billingAccountName
Formats a string containing the fully-qualified path to represent a billing_account resource.
Parameter | |
---|---|
Name | Description |
billingAccount |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted billing_account resource. |
static::parseName
Parses a formatted name string and returns an associative array of the components in the name.
The following name formats are supported: Template: Pattern
- billingAccount: billingAccounts/{billing_account}
The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.
Parameters | |
---|---|
Name | Description |
formattedName |
string
The formatted name string |
template |
string
Optional name of template to match |
Returns | |
---|---|
Type | Description |
array | An associative array from name component IDs to component values. |