# Google Cloud Billing V1 Client - Class CloudBillingClient (2.2.2)

2.2.2 (latest) 2.2.1 2.1.3 2.0.1 1.9.8 1.8.0 1.7.5 1.6.0 1.5.6 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 provides the ability to make remote calls to the backing service through method
calls that map to API methods.

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 parseName method to extract the individual identifiers
contained within formatted names that are returned by the API.

## Namespace

Google \\ Cloud \\ Billing \\ V1 \\ Client

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `options` | `array|https://docs.cloud.google.com/php/docs/reference/gax/latest/Options.ClientOptions.html` 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` | `https://docs.cloud.google.com/php/docs/reference/auth/latest/FetchAuthTokenInterface.html|https://docs.cloud.google.com/php/docs/reference/gax/latest/CredentialsWrapper.html` This option should only be used with a pre-constructed [Google\\Auth\\FetchAuthTokenInterface](https://docs.cloud.google.com/php/docs/reference/auth/latest/FetchAuthTokenInterface.html) or [Google\\ApiCore\\CredentialsWrapper](https://docs.cloud.google.com/php/docs/reference/gax/latest/CredentialsWrapper.html) object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. **Important** : If you are providing a path to a credentials file, or a decoded credentials file as a PHP array, this usage is now DEPRECATED. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. It is recommended to create the credentials explicitly `use Google\Auth\Credentials\ServiceAccountCredentials; use Google\Cloud\Billing\V1\CloudBillingClient; $creds = new ServiceAccountCredentials($scopes, $json); $options = new CloudBillingClient(['credentials' => $creds]);` <https://cloud.google.com/docs/authentication/external/externally-sourced-credentials> |
| `↳ 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()](https://docs.cloud.google.com/php/docs/reference/gax/latest/CredentialsWrapper.html#_Google_ApiCore_CredentialsWrapper__build__) . |
| `↳ disableRetries` | `bool` Determines whether or not retries defined by the client configuration should be disabled. Defaults to `false`. |
| `↳ 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|https://docs.cloud.google.com/php/docs/reference/gax/latest/Transport.TransportInterface.html` The transport used for executing network requests. May be either the string `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. *Advanced usage* : Additionally, it is possible to pass in an already instantiated [Google\\ApiCore\\Transport\\TransportInterface](https://docs.cloud.google.com/php/docs/reference/gax/latest/Transport.TransportInterface.html) object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored. |
| `↳ 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()](https://docs.cloud.google.com/php/docs/reference/gax/latest/Transport.GrpcTransport.html#_Google_ApiCore_Transport_GrpcTransport__build__) and [Google\\ApiCore\\Transport\\RestTransport::build()](https://docs.cloud.google.com/php/docs/reference/gax/latest/Transport.RestTransport.html#_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. |
| `↳ logger` | `false|Psr\Log\LoggerInterface` A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag |
| `↳ universeDomain` | `string` The service domain for the client. Defaults to 'googleapis.com'. |

### createBillingAccount

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 for subaccounts.

The async variant is [CloudBillingClient::createBillingAccountAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.Client.CloudBillingClient#_Google_Cloud_Billing_V1_Client_CloudBillingClient__createBillingAccountAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.CreateBillingAccountRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.BillingAccount` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\Cloud\Billing\V1\BillingAccount;
    use Google\Cloud\Billing\V1\Client\CloudBillingClient;
    use Google\Cloud\Billing\V1\CreateBillingAccountRequest;

    /**
     * This sample 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,
     *    please see the apiEndpoint client configuration option for more details.
     */
    function create_billing_account_sample(): void
    {
        // Create a client.
        $cloudBillingClient = new CloudBillingClient();

        // Prepare the request message.
        $billingAccount = new BillingAccount();
        $request = (new CreateBillingAccountRequest())
            ->setBillingAccount($billingAccount);

        // Call the API and handle any network failures.
        try {
            /** @var BillingAccount $response */
            $response = $cloudBillingClient->createBillingAccount($request);
            printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
        } catch (ApiException $ex) {
            printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
        }
    }

### getBillingAccount

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).

The async variant is [CloudBillingClient::getBillingAccountAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.Client.CloudBillingClient#_Google_Cloud_Billing_V1_Client_CloudBillingClient__getBillingAccountAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.GetBillingAccountRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.BillingAccount` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\Cloud\Billing\V1\BillingAccount;
    use Google\Cloud\Billing\V1\Client\CloudBillingClient;
    use Google\Cloud\Billing\V1\GetBillingAccountRequest;

    /**
     * @param string $formattedName The resource name of the billing account to retrieve. For
     *                              example, `billingAccounts/012345-567890-ABCDEF`. Please see
     *                              {@see CloudBillingClient::billingAccountName()} for help formatting this field.
     */
    function get_billing_account_sample(string $formattedName): void
    {
        // Create a client.
        $cloudBillingClient = new CloudBillingClient();

        // Prepare the request message.
        $request = (new GetBillingAccountRequest())
            ->setName($formattedName);

        // Call the API and handle any network failures.
        try {
            /** @var BillingAccount $response */
            $response = $cloudBillingClient->getBillingAccount($request);
            printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
        } catch (ApiException $ex) {
            printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
        }
    }

    /**
     * Helper to execute the sample.
     *
     * This sample 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,
     *    please see the apiEndpoint client configuration option for more details.
     */
    function callSample(): void
    {
        $formattedName = CloudBillingClient::billingAccountName('[BILLING_ACCOUNT]');

        get_billing_account_sample($formattedName);
    }

### 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](https://cloud.google.com/billing/docs/how-to/billing-access).

The async variant is [CloudBillingClient::getIamPolicyAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.Client.CloudBillingClient#_Google_Cloud_Billing_V1_Client_CloudBillingClient__getIamPolicyAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Cloud.Iam.V1.GetIamPolicyRequest.html` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Cloud.Iam.V1.Policy.html` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\Cloud\Billing\V1\Client\CloudBillingClient;
    use Google\Cloud\Iam\V1\GetIamPolicyRequest;
    use Google\Cloud\Iam\V1\Policy;

    /**
     * @param string $resource REQUIRED: The resource for which the policy is being requested.
     *                         See the operation documentation for the appropriate value for this field.
     */
    function get_iam_policy_sample(string $resource): void
    {
        // Create a client.
        $cloudBillingClient = new CloudBillingClient();

        // Prepare the request message.
        $request = (new GetIamPolicyRequest())
            ->setResource($resource);

        // Call the API and handle any network failures.
        try {
            /** @var Policy $response */
            $response = $cloudBillingClient->getIamPolicy($request);
            printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
        } catch (ApiException $ex) {
            printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
        }
    }

    /**
     * Helper to execute the sample.
     *
     * This sample 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,
     *    please see the apiEndpoint client configuration option for more details.
     */
    function callSample(): void
    {
        $resource = '[RESOURCE]';

        get_iam_policy_sample($resource);
    }

### 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](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles)
role.

The async variant is [CloudBillingClient::getProjectBillingInfoAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.Client.CloudBillingClient#_Google_Cloud_Billing_V1_Client_CloudBillingClient__getProjectBillingInfoAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.GetProjectBillingInfoRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.ProjectBillingInfo` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\Cloud\Billing\V1\Client\CloudBillingClient;
    use Google\Cloud\Billing\V1\GetProjectBillingInfoRequest;
    use Google\Cloud\Billing\V1\ProjectBillingInfo;

    /**
     * @param string $formattedName The resource name of the project for which billing information is
     *                              retrieved. For example, `projects/tokyo-rain-123`. Please see
     *                              {@see CloudBillingClient::projectName()} for help formatting this field.
     */
    function get_project_billing_info_sample(string $formattedName): void
    {
        // Create a client.
        $cloudBillingClient = new CloudBillingClient();

        // Prepare the request message.
        $request = (new GetProjectBillingInfoRequest())
            ->setName($formattedName);

        // Call the API and handle any network failures.
        try {
            /** @var ProjectBillingInfo $response */
            $response = $cloudBillingClient->getProjectBillingInfo($request);
            printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
        } catch (ApiException $ex) {
            printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
        }
    }

    /**
     * Helper to execute the sample.
     *
     * This sample 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,
     *    please see the apiEndpoint client configuration option for more details.
     */
    function callSample(): void
    {
        $formattedName = CloudBillingClient::projectName('[PROJECT]');

        get_project_billing_info_sample($formattedName);
    }

### listBillingAccounts

Lists the billing accounts that the current authenticated user has
permission to
[view](https://cloud.google.com/billing/docs/how-to/billing-access).

The async variant is [CloudBillingClient::listBillingAccountsAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.Client.CloudBillingClient#_Google_Cloud_Billing_V1_Client_CloudBillingClient__listBillingAccountsAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.ListBillingAccountsRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/gax/latest/PagedListResponse.html` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\ApiCore\PagedListResponse;
    use Google\Cloud\Billing\V1\BillingAccount;
    use Google\Cloud\Billing\V1\Client\CloudBillingClient;
    use Google\Cloud\Billing\V1\ListBillingAccountsRequest;

    /**
     * This sample 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,
     *    please see the apiEndpoint client configuration option for more details.
     */
    function list_billing_accounts_sample(): void
    {
        // Create a client.
        $cloudBillingClient = new CloudBillingClient();

        // Prepare the request message.
        $request = new ListBillingAccountsRequest();

        // Call the API and handle any network failures.
        try {
            /** @var PagedListResponse $response */
            $response = $cloudBillingClient->listBillingAccounts($request);

            /** @var BillingAccount $element */
            foreach ($response as $element) {
                printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
            }
        } catch (ApiException $ex) {
            printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
        }
    }

### 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](https://cloud.google.com/billing/docs/how-to/billing-access).

The async variant is [CloudBillingClient::listProjectBillingInfoAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.Client.CloudBillingClient#_Google_Cloud_Billing_V1_Client_CloudBillingClient__listProjectBillingInfoAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.ListProjectBillingInfoRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/gax/latest/PagedListResponse.html` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\ApiCore\PagedListResponse;
    use Google\Cloud\Billing\V1\Client\CloudBillingClient;
    use Google\Cloud\Billing\V1\ListProjectBillingInfoRequest;
    use Google\Cloud\Billing\V1\ProjectBillingInfo;

    /**
     * @param string $formattedName The resource name of the billing account associated with the
     *                              projects that you want to list. For example,
     *                              `billingAccounts/012345-567890-ABCDEF`. Please see
     *                              {@see CloudBillingClient::billingAccountName()} for help formatting this field.
     */
    function list_project_billing_info_sample(string $formattedName): void
    {
        // Create a client.
        $cloudBillingClient = new CloudBillingClient();

        // Prepare the request message.
        $request = (new ListProjectBillingInfoRequest())
            ->setName($formattedName);

        // Call the API and handle any network failures.
        try {
            /** @var PagedListResponse $response */
            $response = $cloudBillingClient->listProjectBillingInfo($request);

            /** @var ProjectBillingInfo $element */
            foreach ($response as $element) {
                printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
            }
        } catch (ApiException $ex) {
            printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
        }
    }

    /**
     * Helper to execute the sample.
     *
     * This sample 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,
     *    please see the apiEndpoint client configuration option for more details.
     */
    function callSample(): void
    {
        $formattedName = CloudBillingClient::billingAccountName('[BILLING_ACCOUNT]');

        list_project_billing_info_sample($formattedName);
    }

### moveBillingAccount

Changes which parent organization a billing account belongs to.

The async variant is [CloudBillingClient::moveBillingAccountAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.Client.CloudBillingClient#_Google_Cloud_Billing_V1_Client_CloudBillingClient__moveBillingAccountAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.MoveBillingAccountRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.BillingAccount` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\Cloud\Billing\V1\BillingAccount;
    use Google\Cloud\Billing\V1\Client\CloudBillingClient;
    use Google\Cloud\Billing\V1\MoveBillingAccountRequest;

    /**
     * @param string $formattedName              The resource name of the billing account to move.
     *                                           Must be of the form `billingAccounts/{billing_account_id}`.
     *                                           The specified billing account cannot be a subaccount, since a subaccount
     *                                           always belongs to the same organization as its parent account. Please see
     *                                           {@see CloudBillingClient::billingAccountName()} for help formatting this field.
     * @param string $formattedDestinationParent The resource name of the Organization to move
     *                                           the billing account under.
     *                                           Must be of the form `organizations/{organization_id}`. Please see
     *                                           {@see CloudBillingClient::organizationName()} for help formatting this field.
     */
    function move_billing_account_sample(
        string $formattedName,
        string $formattedDestinationParent
    ): void {
        // Create a client.
        $cloudBillingClient = new CloudBillingClient();

        // Prepare the request message.
        $request = (new MoveBillingAccountRequest())
            ->setName($formattedName)
            ->setDestinationParent($formattedDestinationParent);

        // Call the API and handle any network failures.
        try {
            /** @var BillingAccount $response */
            $response = $cloudBillingClient->moveBillingAccount($request);
            printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
        } catch (ApiException $ex) {
            printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
        }
    }

    /**
     * Helper to execute the sample.
     *
     * This sample 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,
     *    please see the apiEndpoint client configuration option for more details.
     */
    function callSample(): void
    {
        $formattedName = CloudBillingClient::billingAccountName('[BILLING_ACCOUNT]');
        $formattedDestinationParent = CloudBillingClient::organizationName('[ORGANIZATION]');

        move_billing_account_sample($formattedName, $formattedDestinationParent);
    }

### 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](https://cloud.google.com/billing/docs/how-to/billing-access).

The async variant is [CloudBillingClient::setIamPolicyAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.Client.CloudBillingClient#_Google_Cloud_Billing_V1_Client_CloudBillingClient__setIamPolicyAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Cloud.Iam.V1.SetIamPolicyRequest.html` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Cloud.Iam.V1.Policy.html` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\Cloud\Billing\V1\Client\CloudBillingClient;
    use Google\Cloud\Iam\V1\Policy;
    use Google\Cloud\Iam\V1\SetIamPolicyRequest;

    /**
     * @param string $resource REQUIRED: The resource for which the policy is being specified.
     *                         See the operation documentation for the appropriate value for this field.
     */
    function set_iam_policy_sample(string $resource): void
    {
        // Create a client.
        $cloudBillingClient = new CloudBillingClient();

        // Prepare the request message.
        $policy = new Policy();
        $request = (new SetIamPolicyRequest())
            ->setResource($resource)
            ->setPolicy($policy);

        // Call the API and handle any network failures.
        try {
            /** @var Policy $response */
            $response = $cloudBillingClient->setIamPolicy($request);
            printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
        } catch (ApiException $ex) {
            printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
        }
    }

    /**
     * Helper to execute the sample.
     *
     * This sample 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,
     *    please see the apiEndpoint client configuration option for more details.
     */
    function callSample(): void
    {
        $resource = '[RESOURCE]';

        set_iam_policy_sample($resource);
    }

### 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 [CloudBillingClient::testIamPermissionsAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.Client.CloudBillingClient#_Google_Cloud_Billing_V1_Client_CloudBillingClient__testIamPermissionsAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Cloud.Iam.V1.TestIamPermissionsRequest.html` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Cloud.Iam.V1.TestIamPermissionsResponse.html` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\Cloud\Billing\V1\Client\CloudBillingClient;
    use Google\Cloud\Iam\V1\TestIamPermissionsRequest;
    use Google\Cloud\Iam\V1\TestIamPermissionsResponse;

    /**
     * @param string $resource           REQUIRED: The resource for which the policy detail is being requested.
     *                                   See the operation documentation for the appropriate value for this field.
     * @param string $permissionsElement 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).
     */
    function test_iam_permissions_sample(string $resource, string $permissionsElement): void
    {
        // Create a client.
        $cloudBillingClient = new CloudBillingClient();

        // Prepare the request message.
        $permissions = [$permissionsElement,];
        $request = (new TestIamPermissionsRequest())
            ->setResource($resource)
            ->setPermissions($permissions);

        // Call the API and handle any network failures.
        try {
            /** @var TestIamPermissionsResponse $response */
            $response = $cloudBillingClient->testIamPermissions($request);
            printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
        } catch (ApiException $ex) {
            printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
        }
    }

    /**
     * Helper to execute the sample.
     *
     * This sample 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,
     *    please see the apiEndpoint client configuration option for more details.
     */
    function callSample(): void
    {
        $resource = '[RESOURCE]';
        $permissionsElement = '[PERMISSIONS]';

        test_iam_permissions_sample($resource, $permissionsElement);
    }

### 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](https://cloud.google.com/billing/docs/how-to/billing-access)
of the billing account.

The async variant is [CloudBillingClient::updateBillingAccountAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.Client.CloudBillingClient#_Google_Cloud_Billing_V1_Client_CloudBillingClient__updateBillingAccountAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.UpdateBillingAccountRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.BillingAccount` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\Cloud\Billing\V1\BillingAccount;
    use Google\Cloud\Billing\V1\Client\CloudBillingClient;
    use Google\Cloud\Billing\V1\UpdateBillingAccountRequest;

    /**
     * @param string $formattedName The name of the billing account resource to be updated. Please see
     *                              {@see CloudBillingClient::billingAccountName()} for help formatting this field.
     */
    function update_billing_account_sample(string $formattedName): void
    {
        // Create a client.
        $cloudBillingClient = new CloudBillingClient();

        // Prepare the request message.
        $account = new BillingAccount();
        $request = (new UpdateBillingAccountRequest())
            ->setName($formattedName)
            ->setAccount($account);

        // Call the API and handle any network failures.
        try {
            /** @var BillingAccount $response */
            $response = $cloudBillingClient->updateBillingAccount($request);
            printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
        } catch (ApiException $ex) {
            printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
        }
    }

    /**
     * Helper to execute the sample.
     *
     * This sample 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,
     *    please see the apiEndpoint client configuration option for more details.
     */
    function callSample(): void
    {
        $formattedName = CloudBillingClient::billingAccountName('[BILLING_ACCOUNT]');

        update_billing_account_sample($formattedName);
    }

### 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](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.

The async variant is [CloudBillingClient::updateProjectBillingInfoAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.Client.CloudBillingClient#_Google_Cloud_Billing_V1_Client_CloudBillingClient__updateProjectBillingInfoAsync__)
.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.UpdateProjectBillingInfoRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.ProjectBillingInfo` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\Cloud\Billing\V1\Client\CloudBillingClient;
    use Google\Cloud\Billing\V1\ProjectBillingInfo;
    use Google\Cloud\Billing\V1\UpdateProjectBillingInfoRequest;

    /**
     * @param string $name The resource name of the project associated with the billing
     *                     information that you want to update. For example,
     *                     `projects/tokyo-rain-123`.
     */
    function update_project_billing_info_sample(string $name): void
    {
        // Create a client.
        $cloudBillingClient = new CloudBillingClient();

        // Prepare the request message.
        $request = (new UpdateProjectBillingInfoRequest())
            ->setName($name);

        // Call the API and handle any network failures.
        try {
            /** @var ProjectBillingInfo $response */
            $response = $cloudBillingClient->updateProjectBillingInfo($request);
            printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
        } catch (ApiException $ex) {
            printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
        }
    }

    /**
     * Helper to execute the sample.
     *
     * This sample 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,
     *    please see the apiEndpoint client configuration option for more details.
     */
    function callSample(): void
    {
        $name = '[NAME]';

        update_project_billing_info_sample($name);
    }

### createBillingAccountAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.CreateBillingAccountRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.BillingAccount>` |   |

### getBillingAccountAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.GetBillingAccountRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.BillingAccount>` |   |

### getIamPolicyAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Cloud.Iam.V1.GetIamPolicyRequest.html` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Cloud.Iam.V1.Policy.html>` |   |

### getProjectBillingInfoAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.GetProjectBillingInfoRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.ProjectBillingInfo>` |   |

### listBillingAccountsAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.ListBillingAccountsRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/gax/latest/PagedListResponse.html>` |   |

### listProjectBillingInfoAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.ListProjectBillingInfoRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/gax/latest/PagedListResponse.html>` |   |

### moveBillingAccountAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.MoveBillingAccountRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.BillingAccount>` |   |

### setIamPolicyAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Cloud.Iam.V1.SetIamPolicyRequest.html` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Cloud.Iam.V1.Policy.html>` |   |

### testIamPermissionsAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Cloud.Iam.V1.TestIamPermissionsRequest.html` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Cloud.Iam.V1.TestIamPermissionsResponse.html>` |   |

### updateBillingAccountAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.UpdateBillingAccountRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.BillingAccount>` |   |

### updateProjectBillingInfoAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.UpdateProjectBillingInfoRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/cloud-billing/latest/V1.ProjectBillingInfo>` |   |

### 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::organizationName

Formats a string containing the fully-qualified path to represent a organization
resource.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `organization` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` | The formatted organization resource. |

### static::organizationBillingAccountName

Formats a string containing the fully-qualified path to represent a
organization_billing_account resource.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `organization` | `string` |
| `billingAccount` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` | The formatted organization_billing_account resource. |

### static::projectName

Formats a string containing the fully-qualified path to represent a project
resource.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `project` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` | The formatted project resource. |

### static::projectBillingInfoName

Formats a string containing the fully-qualified path to represent a
project_billing_info resource.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `project` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` | The formatted project_billing_info 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}
- organization: organizations/{organization}
- organizationBillingAccount: organizations/{organization}/billingAccounts/{billing_account}
- project: projects/{project}
- projectBillingInfo: projects/{project}/billingInfo

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. |