Retrieves GCP Console billing accounts and associates them with projects. v1
Package
@google-cloud/billingConstructors
(constructor)(opts)
constructor
(
opts
?:
ClientOptions
);
Construct an instance of CloudBillingClient.
Name | Description |
---|---|
opts | ClientOptions
|
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.
Name | Description |
---|---|
billingAccount | string
|
Type | Description |
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.
Type | Description |
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
]>;
Creates a billing account. This method can only be used to create [billing subaccounts]( https://cloud.google.com/billing/docs/concepts
) by GCP resellers. When creating a subaccount, the current authenticated user must have the billing.accounts.update
IAM permission on the master 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 master account has not been provisioned as a reseller account.
Name | Description |
request | protos. google.cloud.billing.v1.ICreateBillingAccountRequest
The request object that will be sent. |
options | CallOptions
Call options. See CallOptions for more details. |
Type | Description |
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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* 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 master billing
* account.
*/
// const billingAccount = {}
// 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
;
Name | Description |
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>
|
Type | Description |
---|---|
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
;
Name | Description |
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>
|
Type | Description |
---|---|
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 ).
Name | Description |
request | protos. google.cloud.billing.v1.IGetBillingAccountRequest
The request object that will be sent. |
options | CallOptions
Call options. See CallOptions for more details. |
Type | Description |
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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* 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
;
Name | Description |
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>
|
Type | Description |
---|---|
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
;
Name | Description |
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>
|
Type | Description |
---|---|
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
).
Name | Description |
request | protos. google.iam.v1.IGetIamPolicyRequest
The request object that will be sent. |
options | CallOptions
Call options. See CallOptions for more details. |
Type | Description |
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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* 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
;
Name | Description |
request | protos. google.iam.v1.IGetIamPolicyRequest
|
options | CallOptions
|
callback | Callback
<protos. google.iam.v1.IPolicy
, protos. google.iam.v1.IGetIamPolicyRequest
| null | undefined, {} | null | undefined>
|
Type | Description |
---|---|
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
;
Name | Description |
request | protos. google.iam.v1.IGetIamPolicyRequest
|
callback | Callback
<protos. google.iam.v1.IPolicy
, protos. google.iam.v1.IGetIamPolicyRequest
| null | undefined, {} | null | undefined>
|
Type | Description |
---|---|
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 [permission to view the project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ).
Name | Description |
request | protos. google.cloud.billing.v1.IGetProjectBillingInfoRequest
The request object that will be sent. |
options | CallOptions
Call options. See CallOptions for more details. |
Type | Description |
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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* 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
;
Name | Description |
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>
|
Type | Description |
---|---|
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
;
Name | Description |
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>
|
Type | Description |
---|---|
void |
getProjectId()
getProjectId
()
:
Promise<string>
;
Type | Description |
---|---|
Promise <string> |
getProjectId(callback)
getProjectId
(
callback
:
Callback<string
,
undefined
,
undefined
> )
:
void
;
Name | Description |
callback | Callback
<string, undefined, undefined>
|
Type | Description |
---|---|
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.
Type | Description |
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 ).
Name | Description |
request | protos. google.cloud.billing.v1.IListBillingAccountsRequest
The request object that will be sent. |
options | CallOptions
Call options. See CallOptions for more details. |
Type | Description |
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 |
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
;
Name | Description |
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
>
|
Type | Description |
---|---|
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
;
Name | Description |
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
>
|
Type | Description |
---|---|
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.
Name | Description |
request | protos. google.cloud.billing.v1.IListBillingAccountsRequest
The request object that will be sent. |
options | CallOptions
Call options. See CallOptions for more details. |
Type | Description |
AsyncIterable <protos. google.cloud.billing.v1.IBillingAccount > | {Object} An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). 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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) for more details and examples. |
/**
* 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.
* Currently this only supports filtering for
* subaccounts (https://cloud.google.com/billing/docs/concepts) under a
* single provided reseller billing account.
* (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF").
* Boolean algebra and other fields are not currently supported.
*/
// const filter = '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.
Name | Description |
request | protos. google.cloud.billing.v1.IListBillingAccountsRequest
The request object that will be sent. |
options | CallOptions
Call options. See CallOptions for more details. |
Type | Description |
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 |
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
).
Name | Description |
request | protos. google.cloud.billing.v1.IListProjectBillingInfoRequest
The request object that will be sent. |
options | CallOptions
Call options. See CallOptions for more details. |
Type | Description |
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 |
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
;
Name | Description |
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
>
|
Type | Description |
---|---|
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
;
Name | Description |
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
>
|
Type | Description |
---|---|
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.
Name | Description |
request | protos. google.cloud.billing.v1.IListProjectBillingInfoRequest
The request object that will be sent. |
options | CallOptions
Call options. See CallOptions for more details. |
Type | Description |
AsyncIterable <protos. google.cloud.billing.v1.IProjectBillingInfo > | {Object} An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). 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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) for more details and examples. |
/**
* 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.
Name | Description |
request | protos. google.cloud.billing.v1.IListProjectBillingInfoRequest
The request object that will be sent. |
options | CallOptions
Call options. See CallOptions for more details. |
Type | Description |
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 |
matchBillingAccountFromBillingAccountName(billingAccountName)
matchBillingAccountFromBillingAccountName
(
billingAccountName
:
string
)
:
string
|
number
;
Parse the billing_account from BillingAccount resource.
Name | Description |
billingAccountName | string
A fully-qualified path representing BillingAccount resource. |
Type | Description |
string | number | {string} A string representing the billing_account. |
matchServiceFromServiceName(serviceName)
matchServiceFromServiceName
(
serviceName
:
string
)
:
string
|
number
;
Parse the service from Service resource.
Name | Description |
serviceName | string
A fully-qualified path representing Service resource. |
Type | Description |
string | number | {string} A string representing the service. |
matchServiceFromSkuName(skuName)
matchServiceFromSkuName
(
skuName
:
string
)
:
string
|
number
;
Parse the service from Sku resource.
Name | Description |
skuName | string
A fully-qualified path representing Sku resource. |
Type | Description |
string | number | {string} A string representing the service. |
matchSkuFromSkuName(skuName)
matchSkuFromSkuName
(
skuName
:
string
)
:
string
|
number
;
Parse the sku from Sku resource.
Name | Description |
skuName | string
A fully-qualified path representing Sku resource. |
Type | Description |
string | number | {string} A string representing the sku. |
servicePath(service)
servicePath
(
service
:
string
)
:
string
;
Return a fully-qualified service resource name string.
Name | Description |
---|---|
service | string
|
Type | Description |
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
).
Name | Description |
request | protos. google.iam.v1.ISetIamPolicyRequest
The request object that will be sent. |
options | CallOptions
Call options. See CallOptions for more details. |
Type | Description |
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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* 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
;
Name | Description |
request | protos. google.iam.v1.ISetIamPolicyRequest
|
options | CallOptions
|
callback | Callback
<protos. google.iam.v1.IPolicy
, protos. google.iam.v1.ISetIamPolicyRequest
| null | undefined, {} | null | undefined>
|
Type | Description |
---|---|
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
;
Name | Description |
request | protos. google.iam.v1.ISetIamPolicyRequest
|
callback | Callback
<protos. google.iam.v1.IPolicy
, protos. google.iam.v1.ISetIamPolicyRequest
| null | undefined, {} | null | undefined>
|
Type | Description |
---|---|
void |
skuPath(service, sku)
skuPath
(
service
:
string
,
sku
:
string
)
:
string
;
Return a fully-qualified sku resource name string.
Name | Description |
---|---|
service | string
|
sku | string
|
Type | Description |
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.
Name | Description |
request | protos. google.iam.v1.ITestIamPermissionsRequest
The request object that will be sent. |
options | CallOptions
Call options. See CallOptions for more details. |
Type | Description |
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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* 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 = 'abc123'
// 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
;
Name | Description |
request | protos. google.iam.v1.ITestIamPermissionsRequest
|
options | CallOptions
|
callback | Callback
<protos. google.iam.v1.ITestIamPermissionsResponse
, protos. google.iam.v1.ITestIamPermissionsRequest
| null | undefined, {} | null | undefined>
|
Type | Description |
---|---|
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
;
Name | Description |
request | protos. google.iam.v1.ITestIamPermissionsRequest
|
callback | Callback
<protos. google.iam.v1.ITestIamPermissionsResponse
, protos. google.iam.v1.ITestIamPermissionsRequest
| null | undefined, {} | null | undefined>
|
Type | Description |
---|---|
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.
Name | Description |
request | protos. google.cloud.billing.v1.IUpdateBillingAccountRequest
The request object that will be sent. |
options | CallOptions
Call options. See CallOptions for more details. |
Type | Description |
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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* 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
;
Name | Description |
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>
|
Type | Description |
---|---|
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
;
Name | Description |
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>
|
Type | Description |
---|---|
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 GCP 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.
Name | Description |
request | protos. google.cloud.billing.v1.IUpdateProjectBillingInfoRequest
The request object that will be sent. |
options | CallOptions
Call options. See CallOptions for more details. |
Type | Description |
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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* 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. Read-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
;
Name | Description |
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>
|
Type | Description |
---|---|
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
;
Name | Description |
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>
|
Type | Description |
---|---|
void |