Class v1.CloudBillingClient (4.1.0)

Retrieves the Google Cloud Console billing accounts and associates them with projects. v1

Package

@google-cloud/billing

Constructors

(constructor)(opts, gaxInstance)

constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);

Construct an instance of CloudBillingClient.

Parameters
NameDescription
opts ClientOptions
gaxInstance typeof gax | typeof fallback

: loaded instance of google-gax. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: ``` const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new CloudBillingClient({fallback: true}, gax); ```

Properties

apiEndpoint

static get apiEndpoint(): string;

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

auth

auth: gax.GoogleAuth;

cloudBillingStub

cloudBillingStub?: Promise<{
        [name: string]: Function;
    }>;

descriptors

descriptors: Descriptors;

innerApiCalls

innerApiCalls: {
        [name: string]: Function;
    };

pathTemplates

pathTemplates: {
        [name: string]: gax.PathTemplate;
    };

port

static get port(): number;

The port for this API service.

scopes

static get scopes(): string[];

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

static get servicePath(): string;

The DNS address for this API service.

warn

warn: (code: string, message: string, warnType?: string) => void;

Methods

billingAccountPath(billingAccount)

billingAccountPath(billingAccount: string): string;

Return a fully-qualified billingAccount resource name string.

Parameter
NameDescription
billingAccount string
Returns
TypeDescription
string

{string} Resource name string.

close()

close(): Promise<void>;

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns
TypeDescription
Promise<void>

{Promise} A promise that resolves when the client is closed.

createBillingAccount(request, options)

createBillingAccount(request?: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, options?: CallOptions): Promise<[
        protos.google.cloud.billing.v1.IBillingAccount,
        protos.google.cloud.billing.v1.ICreateBillingAccountRequest | undefined,
        {} | undefined
    ]>;

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.

Parameters
NameDescription
request ICreateBillingAccountRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.ICreateBillingAccountRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing BillingAccount. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  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.
   */
  // const billingAccount = {}
  /**
   *  Optional. The parent to create a billing account from.
   *  Format:
   *    - `organizations/{organization_id}`, for example,
   *      `organizations/12345678`
   *    - `billingAccounts/{billing_account_id}`, for example,
   *       `billingAccounts/012345-567890-ABCDEF`
   */
  // const parent = 'abc123'

  // Imports the Billing library
  const {CloudBillingClient} = require('@google-cloud/billing').v1;

  // Instantiates a client
  const billingClient = new CloudBillingClient();

  async function callCreateBillingAccount() {
    // Construct request
    const request = {
      billingAccount,
    };

    // Run request
    const response = await billingClient.createBillingAccount(request);
    console.log(response);
  }

  callCreateBillingAccount();

createBillingAccount(request, options, callback)

createBillingAccount(request: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, options: CallOptions, callback: Callback<protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.ICreateBillingAccountRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICreateBillingAccountRequest
options CallOptions
callback Callback<protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.ICreateBillingAccountRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

createBillingAccount(request, callback)

createBillingAccount(request: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, callback: Callback<protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.ICreateBillingAccountRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICreateBillingAccountRequest
callback Callback<protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.ICreateBillingAccountRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getBillingAccount(request, options)

getBillingAccount(request?: protos.google.cloud.billing.v1.IGetBillingAccountRequest, options?: CallOptions): Promise<[
        protos.google.cloud.billing.v1.IBillingAccount,
        protos.google.cloud.billing.v1.IGetBillingAccountRequest | undefined,
        {} | undefined
    ]>;

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

Parameters
NameDescription
request IGetBillingAccountRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.IGetBillingAccountRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing BillingAccount. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The resource name of the billing account to retrieve. For
   *  example, `billingAccounts/012345-567890-ABCDEF`.
   */
  // const name = 'abc123'

  // Imports the Billing library
  const {CloudBillingClient} = require('@google-cloud/billing').v1;

  // Instantiates a client
  const billingClient = new CloudBillingClient();

  async function callGetBillingAccount() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await billingClient.getBillingAccount(request);
    console.log(response);
  }

  callGetBillingAccount();

getBillingAccount(request, options, callback)

getBillingAccount(request: protos.google.cloud.billing.v1.IGetBillingAccountRequest, options: CallOptions, callback: Callback<protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.IGetBillingAccountRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetBillingAccountRequest
options CallOptions
callback Callback<protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.IGetBillingAccountRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getBillingAccount(request, callback)

getBillingAccount(request: protos.google.cloud.billing.v1.IGetBillingAccountRequest, callback: Callback<protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.IGetBillingAccountRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetBillingAccountRequest
callback Callback<protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.IGetBillingAccountRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getIamPolicy(request, options)

getIamPolicy(request?: protos.google.iam.v1.IGetIamPolicyRequest, options?: CallOptions): Promise<[
        protos.google.iam.v1.IPolicy,
        protos.google.iam.v1.IGetIamPolicyRequest | undefined,
        {} | undefined
    ]>;

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

Parameters
NameDescription
request IGetIamPolicyRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.iam.v1.IPolicy, protos.google.iam.v1.IGetIamPolicyRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Policy. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  REQUIRED: The resource for which the policy is being requested.
   *  See the operation documentation for the appropriate value for this field.
   */
  // const resource = 'abc123'
  /**
   *  OPTIONAL: A `GetPolicyOptions` object for specifying options to
   *  `GetIamPolicy`.
   */
  // const options = {}

  // Imports the Billing library
  const {CloudBillingClient} = require('@google-cloud/billing').v1;

  // Instantiates a client
  const billingClient = new CloudBillingClient();

  async function callGetIamPolicy() {
    // Construct request
    const request = {
      resource,
    };

    // Run request
    const response = await billingClient.getIamPolicy(request);
    console.log(response);
  }

  callGetIamPolicy();

getIamPolicy(request, options, callback)

getIamPolicy(request: protos.google.iam.v1.IGetIamPolicyRequest, options: CallOptions, callback: Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetIamPolicyRequest
options CallOptions
callback Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getIamPolicy(request, callback)

getIamPolicy(request: protos.google.iam.v1.IGetIamPolicyRequest, callback: Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetIamPolicyRequest
callback Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getProjectBillingInfo(request, options)

getProjectBillingInfo(request?: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, options?: CallOptions): Promise<[
        protos.google.cloud.billing.v1.IProjectBillingInfo,
        protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest | undefined,
        {} | undefined
    ]>;

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.

Parameters
NameDescription
request IGetProjectBillingInfoRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.billing.v1.IProjectBillingInfo, protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing ProjectBillingInfo. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The resource name of the project for which billing information is
   *  retrieved. For example, `projects/tokyo-rain-123`.
   */
  // const name = 'abc123'

  // Imports the Billing library
  const {CloudBillingClient} = require('@google-cloud/billing').v1;

  // Instantiates a client
  const billingClient = new CloudBillingClient();

  async function callGetProjectBillingInfo() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await billingClient.getProjectBillingInfo(request);
    console.log(response);
  }

  callGetProjectBillingInfo();

getProjectBillingInfo(request, options, callback)

getProjectBillingInfo(request: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, options: CallOptions, callback: Callback<protos.google.cloud.billing.v1.IProjectBillingInfo, protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetProjectBillingInfoRequest
options CallOptions
callback Callback<protos.google.cloud.billing.v1.IProjectBillingInfo, protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getProjectBillingInfo(request, callback)

getProjectBillingInfo(request: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, callback: Callback<protos.google.cloud.billing.v1.IProjectBillingInfo, protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetProjectBillingInfoRequest
callback Callback<protos.google.cloud.billing.v1.IProjectBillingInfo, protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getProjectId()

getProjectId(): Promise<string>;
Returns
TypeDescription
Promise<string>

getProjectId(callback)

getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter
NameDescription
callback Callback<string, undefined, undefined>
Returns
TypeDescription
void

initialize()

initialize(): Promise<{
        [name: string]: Function;
    }>;

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns
TypeDescription
Promise<{ [name: string]: Function; }>

{Promise} A promise that resolves to an authenticated service stub.

listBillingAccounts(request, options)

listBillingAccounts(request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, options?: CallOptions): Promise<[
        protos.google.cloud.billing.v1.IBillingAccount[],
        protos.google.cloud.billing.v1.IListBillingAccountsRequest | null,
        protos.google.cloud.billing.v1.IListBillingAccountsResponse
    ]>;

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

Parameters
NameDescription
request IListBillingAccountsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.billing.v1.IBillingAccount[], protos.google.cloud.billing.v1.IListBillingAccountsRequest | null, protos.google.cloud.billing.v1.IListBillingAccountsResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of BillingAccount. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listBillingAccountsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listBillingAccounts(request, options, callback)

listBillingAccounts(request: protos.google.cloud.billing.v1.IListBillingAccountsRequest, options: CallOptions, callback: PaginationCallback<protos.google.cloud.billing.v1.IListBillingAccountsRequest, protos.google.cloud.billing.v1.IListBillingAccountsResponse | null | undefined, protos.google.cloud.billing.v1.IBillingAccount>): void;
Parameters
NameDescription
request IListBillingAccountsRequest
options CallOptions
callback PaginationCallback<protos.google.cloud.billing.v1.IListBillingAccountsRequest, protos.google.cloud.billing.v1.IListBillingAccountsResponse | null | undefined, protos.google.cloud.billing.v1.IBillingAccount>
Returns
TypeDescription
void

listBillingAccounts(request, callback)

listBillingAccounts(request: protos.google.cloud.billing.v1.IListBillingAccountsRequest, callback: PaginationCallback<protos.google.cloud.billing.v1.IListBillingAccountsRequest, protos.google.cloud.billing.v1.IListBillingAccountsResponse | null | undefined, protos.google.cloud.billing.v1.IBillingAccount>): void;
Parameters
NameDescription
request IListBillingAccountsRequest
callback PaginationCallback<protos.google.cloud.billing.v1.IListBillingAccountsRequest, protos.google.cloud.billing.v1.IListBillingAccountsResponse | null | undefined, protos.google.cloud.billing.v1.IBillingAccount>
Returns
TypeDescription
void

listBillingAccountsAsync(request, options)

listBillingAccountsAsync(request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, options?: CallOptions): AsyncIterable<protos.google.cloud.billing.v1.IBillingAccount>;

Equivalent to listBillingAccounts, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
NameDescription
request IListBillingAccountsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
AsyncIterable<protos.google.cloud.billing.v1.IBillingAccount>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing BillingAccount. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Requested page size. The maximum page size is 100; this is also the
   *  default.
   */
  // const pageSize = 1234
  /**
   *  A token identifying a page of results to return. This should be a
   *  `next_page_token` value returned from a previous `ListBillingAccounts`
   *  call. If unspecified, the first page of results is returned.
   */
  // const pageToken = 'abc123'
  /**
   *  Options for how to filter the returned billing accounts.
   *  This only supports filtering for
   *  subaccounts (https://cloud.google.com/billing/docs/concepts) under a
   *  single provided parent billing account.
   *  (for example,
   *  `master_billing_account=billingAccounts/012345-678901-ABCDEF`).
   *  Boolean algebra and other fields are not currently supported.
   */
  // const filter = 'abc123'
  /**
   *  Optional. The parent resource to list billing accounts from.
   *  Format:
   *    - `organizations/{organization_id}`, for example,
   *      `organizations/12345678`
   *    - `billingAccounts/{billing_account_id}`, for example,
   *      `billingAccounts/012345-567890-ABCDEF`
   */
  // const parent = 'abc123'

  // Imports the Billing library
  const {CloudBillingClient} = require('@google-cloud/billing').v1;

  // Instantiates a client
  const billingClient = new CloudBillingClient();

  async function callListBillingAccounts() {
    // Construct request
    const request = {
    };

    // Run request
    const iterable = await billingClient.listBillingAccountsAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListBillingAccounts();

listBillingAccountsStream(request, options)

listBillingAccountsStream(request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
NameDescription
request IListBillingAccountsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Transform

{Stream} An object stream which emits an object representing BillingAccount on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listBillingAccountsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listProjectBillingInfo(request, options)

listProjectBillingInfo(request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, options?: CallOptions): Promise<[
        protos.google.cloud.billing.v1.IProjectBillingInfo[],
        protos.google.cloud.billing.v1.IListProjectBillingInfoRequest | null,
        protos.google.cloud.billing.v1.IListProjectBillingInfoResponse
    ]>;

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

Parameters
NameDescription
request IListProjectBillingInfoRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.billing.v1.IProjectBillingInfo[], protos.google.cloud.billing.v1.IListProjectBillingInfoRequest | null, protos.google.cloud.billing.v1.IListProjectBillingInfoResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of ProjectBillingInfo. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listProjectBillingInfoAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listProjectBillingInfo(request, options, callback)

listProjectBillingInfo(request: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, options: CallOptions, callback: PaginationCallback<protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, protos.google.cloud.billing.v1.IListProjectBillingInfoResponse | null | undefined, protos.google.cloud.billing.v1.IProjectBillingInfo>): void;
Parameters
NameDescription
request IListProjectBillingInfoRequest
options CallOptions
callback PaginationCallback<protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, protos.google.cloud.billing.v1.IListProjectBillingInfoResponse | null | undefined, protos.google.cloud.billing.v1.IProjectBillingInfo>
Returns
TypeDescription
void

listProjectBillingInfo(request, callback)

listProjectBillingInfo(request: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, callback: PaginationCallback<protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, protos.google.cloud.billing.v1.IListProjectBillingInfoResponse | null | undefined, protos.google.cloud.billing.v1.IProjectBillingInfo>): void;
Parameters
NameDescription
request IListProjectBillingInfoRequest
callback PaginationCallback<protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, protos.google.cloud.billing.v1.IListProjectBillingInfoResponse | null | undefined, protos.google.cloud.billing.v1.IProjectBillingInfo>
Returns
TypeDescription
void

listProjectBillingInfoAsync(request, options)

listProjectBillingInfoAsync(request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, options?: CallOptions): AsyncIterable<protos.google.cloud.billing.v1.IProjectBillingInfo>;

Equivalent to listProjectBillingInfo, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
NameDescription
request IListProjectBillingInfoRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
AsyncIterable<protos.google.cloud.billing.v1.IProjectBillingInfo>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing ProjectBillingInfo. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The resource name of the billing account associated with the
   *  projects that you want to list. For example,
   *  `billingAccounts/012345-567890-ABCDEF`.
   */
  // const name = 'abc123'
  /**
   *  Requested page size. The maximum page size is 100; this is also the
   *  default.
   */
  // const pageSize = 1234
  /**
   *  A token identifying a page of results to be returned. This should be a
   *  `next_page_token` value returned from a previous `ListProjectBillingInfo`
   *  call. If unspecified, the first page of results is returned.
   */
  // const pageToken = 'abc123'

  // Imports the Billing library
  const {CloudBillingClient} = require('@google-cloud/billing').v1;

  // Instantiates a client
  const billingClient = new CloudBillingClient();

  async function callListProjectBillingInfo() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const iterable = await billingClient.listProjectBillingInfoAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListProjectBillingInfo();

listProjectBillingInfoStream(request, options)

listProjectBillingInfoStream(request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
NameDescription
request IListProjectBillingInfoRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Transform

{Stream} An object stream which emits an object representing ProjectBillingInfo on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listProjectBillingInfoAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

matchBillingAccountFromBillingAccountName(billingAccountName)

matchBillingAccountFromBillingAccountName(billingAccountName: string): string | number;

Parse the billing_account from BillingAccount resource.

Parameter
NameDescription
billingAccountName string

A fully-qualified path representing billing_account resource.

Returns
TypeDescription
string | number

{string} A string representing the billing_account.

matchBillingAccountFromOrganizationBillingAccountName(organizationBillingAccountName)

matchBillingAccountFromOrganizationBillingAccountName(organizationBillingAccountName: string): string | number;

Parse the billing_account from OrganizationBillingAccount resource.

Parameter
NameDescription
organizationBillingAccountName string

A fully-qualified path representing organization_billing_account resource.

Returns
TypeDescription
string | number

{string} A string representing the billing_account.

matchOrganizationFromOrganizationBillingAccountName(organizationBillingAccountName)

matchOrganizationFromOrganizationBillingAccountName(organizationBillingAccountName: string): string | number;

Parse the organization from OrganizationBillingAccount resource.

Parameter
NameDescription
organizationBillingAccountName string

A fully-qualified path representing organization_billing_account resource.

Returns
TypeDescription
string | number

{string} A string representing the organization.

matchOrganizationFromOrganizationName(organizationName)

matchOrganizationFromOrganizationName(organizationName: string): string | number;

Parse the organization from Organization resource.

Parameter
NameDescription
organizationName string

A fully-qualified path representing Organization resource.

Returns
TypeDescription
string | number

{string} A string representing the organization.

matchProjectFromProjectBillingInfoName(projectBillingInfoName)

matchProjectFromProjectBillingInfoName(projectBillingInfoName: string): string | number;

Parse the project from ProjectBillingInfo resource.

Parameter
NameDescription
projectBillingInfoName string

A fully-qualified path representing ProjectBillingInfo resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchProjectFromProjectName(projectName)

matchProjectFromProjectName(projectName: string): string | number;

Parse the project from Project resource.

Parameter
NameDescription
projectName string

A fully-qualified path representing Project resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchServiceFromServiceName(serviceName)

matchServiceFromServiceName(serviceName: string): string | number;

Parse the service from Service resource.

Parameter
NameDescription
serviceName string

A fully-qualified path representing Service resource.

Returns
TypeDescription
string | number

{string} A string representing the service.

matchServiceFromSkuName(skuName)

matchServiceFromSkuName(skuName: string): string | number;

Parse the service from Sku resource.

Parameter
NameDescription
skuName string

A fully-qualified path representing Sku resource.

Returns
TypeDescription
string | number

{string} A string representing the service.

matchSkuFromSkuName(skuName)

matchSkuFromSkuName(skuName: string): string | number;

Parse the sku from Sku resource.

Parameter
NameDescription
skuName string

A fully-qualified path representing Sku resource.

Returns
TypeDescription
string | number

{string} A string representing the sku.

moveBillingAccount(request, options)

moveBillingAccount(request?: protos.google.cloud.billing.v1.IMoveBillingAccountRequest, options?: CallOptions): Promise<[
        protos.google.cloud.billing.v1.IBillingAccount,
        protos.google.cloud.billing.v1.IMoveBillingAccountRequest | undefined,
        {} | undefined
    ]>;

Changes which parent organization a billing account belongs to.

Parameters
NameDescription
request IMoveBillingAccountRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.IMoveBillingAccountRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing BillingAccount. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. 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.
   */
  // const name = 'abc123'
  /**
   *  Required. The resource name of the Organization to reparent
   *  the billing account under.
   *  Must be of the form `organizations/{organization_id}`.
   */
  // const destinationParent = 'abc123'

  // Imports the Billing library
  const {CloudBillingClient} = require('@google-cloud/billing').v1;

  // Instantiates a client
  const billingClient = new CloudBillingClient();

  async function callMoveBillingAccount() {
    // Construct request
    const request = {
      name,
      destinationParent,
    };

    // Run request
    const response = await billingClient.moveBillingAccount(request);
    console.log(response);
  }

  callMoveBillingAccount();

moveBillingAccount(request, options, callback)

moveBillingAccount(request: protos.google.cloud.billing.v1.IMoveBillingAccountRequest, options: CallOptions, callback: Callback<protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.IMoveBillingAccountRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IMoveBillingAccountRequest
options CallOptions
callback Callback<protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.IMoveBillingAccountRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

moveBillingAccount(request, callback)

moveBillingAccount(request: protos.google.cloud.billing.v1.IMoveBillingAccountRequest, callback: Callback<protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.IMoveBillingAccountRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IMoveBillingAccountRequest
callback Callback<protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.IMoveBillingAccountRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

organizationBillingAccountPath(organization, billingAccount)

organizationBillingAccountPath(organization: string, billingAccount: string): string;

Return a fully-qualified organizationBillingAccount resource name string.

Parameters
NameDescription
organization string
billingAccount string
Returns
TypeDescription
string

{string} Resource name string.

organizationPath(organization)

organizationPath(organization: string): string;

Return a fully-qualified organization resource name string.

Parameter
NameDescription
organization string
Returns
TypeDescription
string

{string} Resource name string.

projectBillingInfoPath(project)

projectBillingInfoPath(project: string): string;

Return a fully-qualified projectBillingInfo resource name string.

Parameter
NameDescription
project string
Returns
TypeDescription
string

{string} Resource name string.

projectPath(project)

projectPath(project: string): string;

Return a fully-qualified project resource name string.

Parameter
NameDescription
project string
Returns
TypeDescription
string

{string} Resource name string.

servicePath(service)

servicePath(service: string): string;

Return a fully-qualified service resource name string.

Parameter
NameDescription
service string
Returns
TypeDescription
string

{string} Resource name string.

setIamPolicy(request, options)

setIamPolicy(request?: protos.google.iam.v1.ISetIamPolicyRequest, options?: CallOptions): Promise<[
        protos.google.iam.v1.IPolicy,
        protos.google.iam.v1.ISetIamPolicyRequest | undefined,
        {} | undefined
    ]>;

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

Parameters
NameDescription
request ISetIamPolicyRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.iam.v1.IPolicy, protos.google.iam.v1.ISetIamPolicyRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Policy. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  REQUIRED: The resource for which the policy is being specified.
   *  See the operation documentation for the appropriate value for this field.
   */
  // const resource = 'abc123'
  /**
   *  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.
   */
  // const policy = {}
  /**
   *  OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only
   *  the fields in the mask will be modified. If no mask is provided, the
   *  following default mask is used:
   *  `paths: "bindings, etag"`
   */
  // const updateMask = {}

  // Imports the Billing library
  const {CloudBillingClient} = require('@google-cloud/billing').v1;

  // Instantiates a client
  const billingClient = new CloudBillingClient();

  async function callSetIamPolicy() {
    // Construct request
    const request = {
      resource,
      policy,
    };

    // Run request
    const response = await billingClient.setIamPolicy(request);
    console.log(response);
  }

  callSetIamPolicy();

setIamPolicy(request, options, callback)

setIamPolicy(request: protos.google.iam.v1.ISetIamPolicyRequest, options: CallOptions, callback: Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ISetIamPolicyRequest
options CallOptions
callback Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

setIamPolicy(request, callback)

setIamPolicy(request: protos.google.iam.v1.ISetIamPolicyRequest, callback: Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ISetIamPolicyRequest
callback Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

skuPath(service, sku)

skuPath(service: string, sku: string): string;

Return a fully-qualified sku resource name string.

Parameters
NameDescription
service string
sku string
Returns
TypeDescription
string

{string} Resource name string.

testIamPermissions(request, options)

testIamPermissions(request?: protos.google.iam.v1.ITestIamPermissionsRequest, options?: CallOptions): Promise<[
        protos.google.iam.v1.ITestIamPermissionsResponse,
        protos.google.iam.v1.ITestIamPermissionsRequest | undefined,
        {} | undefined
    ]>;

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
NameDescription
request ITestIamPermissionsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.iam.v1.ITestIamPermissionsResponse, protos.google.iam.v1.ITestIamPermissionsRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing TestIamPermissionsResponse. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  REQUIRED: The resource for which the policy detail is being requested.
   *  See the operation documentation for the appropriate value for this field.
   */
  // const resource = 'abc123'
  /**
   *  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).
   */
  // const permissions = ['abc','def']

  // Imports the Billing library
  const {CloudBillingClient} = require('@google-cloud/billing').v1;

  // Instantiates a client
  const billingClient = new CloudBillingClient();

  async function callTestIamPermissions() {
    // Construct request
    const request = {
      resource,
      permissions,
    };

    // Run request
    const response = await billingClient.testIamPermissions(request);
    console.log(response);
  }

  callTestIamPermissions();

testIamPermissions(request, options, callback)

testIamPermissions(request: protos.google.iam.v1.ITestIamPermissionsRequest, options: CallOptions, callback: Callback<protos.google.iam.v1.ITestIamPermissionsResponse, protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ITestIamPermissionsRequest
options CallOptions
callback Callback<protos.google.iam.v1.ITestIamPermissionsResponse, protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

testIamPermissions(request, callback)

testIamPermissions(request: protos.google.iam.v1.ITestIamPermissionsRequest, callback: Callback<protos.google.iam.v1.ITestIamPermissionsResponse, protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ITestIamPermissionsRequest
callback Callback<protos.google.iam.v1.ITestIamPermissionsResponse, protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

updateBillingAccount(request, options)

updateBillingAccount(request?: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, options?: CallOptions): Promise<[
        protos.google.cloud.billing.v1.IBillingAccount,
        protos.google.cloud.billing.v1.IUpdateBillingAccountRequest | undefined,
        {} | undefined
    ]>;

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.

Parameters
NameDescription
request IUpdateBillingAccountRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.IUpdateBillingAccountRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing BillingAccount. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The name of the billing account resource to be updated.
   */
  // const name = 'abc123'
  /**
   *  Required. The billing account resource to replace the resource on the
   *  server.
   */
  // const account = {}
  /**
   *  The update mask applied to the resource.
   *  Only "display_name" is currently supported.
   */
  // const updateMask = {}

  // Imports the Billing library
  const {CloudBillingClient} = require('@google-cloud/billing').v1;

  // Instantiates a client
  const billingClient = new CloudBillingClient();

  async function callUpdateBillingAccount() {
    // Construct request
    const request = {
      name,
      account,
    };

    // Run request
    const response = await billingClient.updateBillingAccount(request);
    console.log(response);
  }

  callUpdateBillingAccount();

updateBillingAccount(request, options, callback)

updateBillingAccount(request: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, options: CallOptions, callback: Callback<protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.IUpdateBillingAccountRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IUpdateBillingAccountRequest
options CallOptions
callback Callback<protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.IUpdateBillingAccountRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

updateBillingAccount(request, callback)

updateBillingAccount(request: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, callback: Callback<protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.IUpdateBillingAccountRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IUpdateBillingAccountRequest
callback Callback<protos.google.cloud.billing.v1.IBillingAccount, protos.google.cloud.billing.v1.IUpdateBillingAccountRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

updateProjectBillingInfo(request, options)

updateProjectBillingInfo(request?: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, options?: CallOptions): Promise<[
        protos.google.cloud.billing.v1.IProjectBillingInfo,
        (protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest | undefined),
        {} | undefined
    ]>;

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.

Parameters
NameDescription
request IUpdateProjectBillingInfoRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.billing.v1.IProjectBillingInfo, (protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing ProjectBillingInfo. Please see the documentation for more details and examples.

Example

  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The resource name of the project associated with the billing
   *  information that you want to update. For example,
   *  `projects/tokyo-rain-123`.
   */
  // const name = 'abc123'
  /**
   *  The new billing information for the project. Output-only fields are
   *  ignored; thus, you can leave empty all fields except
   *  `billing_account_name`.
   */
  // const projectBillingInfo = {}

  // Imports the Billing library
  const {CloudBillingClient} = require('@google-cloud/billing').v1;

  // Instantiates a client
  const billingClient = new CloudBillingClient();

  async function callUpdateProjectBillingInfo() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await billingClient.updateProjectBillingInfo(request);
    console.log(response);
  }

  callUpdateProjectBillingInfo();

updateProjectBillingInfo(request, options, callback)

updateProjectBillingInfo(request: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, options: CallOptions, callback: Callback<protos.google.cloud.billing.v1.IProjectBillingInfo, protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IUpdateProjectBillingInfoRequest
options CallOptions
callback Callback<protos.google.cloud.billing.v1.IProjectBillingInfo, protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

updateProjectBillingInfo(request, callback)

updateProjectBillingInfo(request: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, callback: Callback<protos.google.cloud.billing.v1.IProjectBillingInfo, protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IUpdateProjectBillingInfoRequest
callback Callback<protos.google.cloud.billing.v1.IProjectBillingInfo, protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void