BudgetService stores Cloud Billing budgets, which define a budget plan and rules to execute as we track spend against that plan. v1beta1
Package
@google-cloud/billing-budgetsConstructors
(constructor)(opts)
constructor(opts?: ClientOptions);
Construct an instance of BudgetServiceClient.
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;
budgetServiceStub
budgetServiceStub?: 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. |
budgetPath(billingAccount, budget)
budgetPath(billingAccount: string, budget: string): string;
Return a fully-qualified budget resource name string.
Name | Description |
billingAccount |
string
|
budget |
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. |
createBudget(request, options)
createBudget(request?: protos.google.cloud.billing.budgets.v1beta1.ICreateBudgetRequest, options?: CallOptions): Promise<[protos.google.cloud.billing.budgets.v1beta1.IBudget, (protos.google.cloud.billing.budgets.v1beta1.ICreateBudgetRequest | undefined), {} | undefined]>;
Creates a new budget. See Quotas and limits for more information on the limits of the number of budgets you can create.
Name | Description |
request |
protos.google.cloud.billing.budgets.v1beta1.ICreateBudgetRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[protos.google.cloud.billing.budgets.v1beta1.IBudget, (protos.google.cloud.billing.budgets.v1beta1.ICreateBudgetRequest | undefined), {} | undefined]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing [Budget]. 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 to create the budget in. Values
* are of the form `billingAccounts/{billingAccountId}`.
*/
// const parent = 'abc123'
/**
* Required. Budget to create.
*/
// const budget = {}
// Imports the Budgets library
const {BudgetServiceClient} =
require('@google-cloud/billing-budgets').v1beta1;
// Instantiates a client
const budgetsClient = new BudgetServiceClient();
async function callCreateBudget() {
// Construct request
const request = {
parent,
budget,
};
// Run request
const response = await budgetsClient.createBudget(request);
console.log(response);
}
callCreateBudget();
createBudget(request, options, callback)
createBudget(request: protos.google.cloud.billing.budgets.v1beta1.ICreateBudgetRequest, options: CallOptions, callback: Callback<protos.google.cloud.billing.budgets.v1beta1.IBudget, protos.google.cloud.billing.budgets.v1beta1.ICreateBudgetRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.billing.budgets.v1beta1.ICreateBudgetRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.cloud.billing.budgets.v1beta1.IBudget, protos.google.cloud.billing.budgets.v1beta1.ICreateBudgetRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
createBudget(request, callback)
createBudget(request: protos.google.cloud.billing.budgets.v1beta1.ICreateBudgetRequest, callback: Callback<protos.google.cloud.billing.budgets.v1beta1.IBudget, protos.google.cloud.billing.budgets.v1beta1.ICreateBudgetRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.billing.budgets.v1beta1.ICreateBudgetRequest
|
callback |
Callback<protos.google.cloud.billing.budgets.v1beta1.IBudget, protos.google.cloud.billing.budgets.v1beta1.ICreateBudgetRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
deleteBudget(request, options)
deleteBudget(request?: protos.google.cloud.billing.budgets.v1beta1.IDeleteBudgetRequest, options?: CallOptions): Promise<[protos.google.protobuf.IEmpty, (protos.google.cloud.billing.budgets.v1beta1.IDeleteBudgetRequest | undefined), {} | undefined]>;
Deletes a budget. Returns successfully if already deleted.
Name | Description |
request |
protos.google.cloud.billing.budgets.v1beta1.IDeleteBudgetRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[protos.google.protobuf.IEmpty, (protos.google.cloud.billing.budgets.v1beta1.IDeleteBudgetRequest | undefined), {} | undefined]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing [Empty]. 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. Name of the budget to delete. Values are of the form
* `billingAccounts/{billingAccountId}/budgets/{budgetId}`.
*/
// const name = 'abc123'
// Imports the Budgets library
const {BudgetServiceClient} =
require('@google-cloud/billing-budgets').v1beta1;
// Instantiates a client
const budgetsClient = new BudgetServiceClient();
async function callDeleteBudget() {
// Construct request
const request = {
name,
};
// Run request
const response = await budgetsClient.deleteBudget(request);
console.log(response);
}
callDeleteBudget();
deleteBudget(request, options, callback)
deleteBudget(request: protos.google.cloud.billing.budgets.v1beta1.IDeleteBudgetRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.cloud.billing.budgets.v1beta1.IDeleteBudgetRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.billing.budgets.v1beta1.IDeleteBudgetRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.protobuf.IEmpty, protos.google.cloud.billing.budgets.v1beta1.IDeleteBudgetRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
deleteBudget(request, callback)
deleteBudget(request: protos.google.cloud.billing.budgets.v1beta1.IDeleteBudgetRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.cloud.billing.budgets.v1beta1.IDeleteBudgetRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.billing.budgets.v1beta1.IDeleteBudgetRequest
|
callback |
Callback<protos.google.protobuf.IEmpty, protos.google.cloud.billing.budgets.v1beta1.IDeleteBudgetRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
getBudget(request, options)
getBudget(request?: protos.google.cloud.billing.budgets.v1beta1.IGetBudgetRequest, options?: CallOptions): Promise<[protos.google.cloud.billing.budgets.v1beta1.IBudget, protos.google.cloud.billing.budgets.v1beta1.IGetBudgetRequest | undefined, {} | undefined]>;
Returns a budget.
WARNING: There are some fields exposed on the Google Cloud Console that aren't available on this API. When reading from the API, you will not see these fields in the return value, though they may have been set in the Cloud Console.
Name | Description |
request |
protos.google.cloud.billing.budgets.v1beta1.IGetBudgetRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[protos.google.cloud.billing.budgets.v1beta1.IBudget, protos.google.cloud.billing.budgets.v1beta1.IGetBudgetRequest | undefined, {} | undefined]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing [Budget]. 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. Name of budget to get. Values are of the form
* `billingAccounts/{billingAccountId}/budgets/{budgetId}`.
*/
// const name = 'abc123'
// Imports the Budgets library
const {BudgetServiceClient} =
require('@google-cloud/billing-budgets').v1beta1;
// Instantiates a client
const budgetsClient = new BudgetServiceClient();
async function callGetBudget() {
// Construct request
const request = {
name,
};
// Run request
const response = await budgetsClient.getBudget(request);
console.log(response);
}
callGetBudget();
getBudget(request, options, callback)
getBudget(request: protos.google.cloud.billing.budgets.v1beta1.IGetBudgetRequest, options: CallOptions, callback: Callback<protos.google.cloud.billing.budgets.v1beta1.IBudget, protos.google.cloud.billing.budgets.v1beta1.IGetBudgetRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.billing.budgets.v1beta1.IGetBudgetRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.cloud.billing.budgets.v1beta1.IBudget, protos.google.cloud.billing.budgets.v1beta1.IGetBudgetRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
getBudget(request, callback)
getBudget(request: protos.google.cloud.billing.budgets.v1beta1.IGetBudgetRequest, callback: Callback<protos.google.cloud.billing.budgets.v1beta1.IBudget, protos.google.cloud.billing.budgets.v1beta1.IGetBudgetRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.billing.budgets.v1beta1.IGetBudgetRequest
|
callback |
Callback<protos.google.cloud.billing.budgets.v1beta1.IBudget, protos.google.cloud.billing.budgets.v1beta1.IGetBudgetRequest | 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. |
listBudgets(request, options)
listBudgets(request?: protos.google.cloud.billing.budgets.v1beta1.IListBudgetsRequest, options?: CallOptions): Promise<[protos.google.cloud.billing.budgets.v1beta1.IBudget[], protos.google.cloud.billing.budgets.v1beta1.IListBudgetsRequest | null, protos.google.cloud.billing.budgets.v1beta1.IListBudgetsResponse]>;
Returns a list of budgets for a billing account.
WARNING: There are some fields exposed on the Google Cloud Console that aren't available on this API. When reading from the API, you will not see these fields in the return value, though they may have been set in the Cloud Console.
Name | Description |
request |
protos.google.cloud.billing.budgets.v1beta1.IListBudgetsRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[protos.google.cloud.billing.budgets.v1beta1.IBudget[], protos.google.cloud.billing.budgets.v1beta1.IListBudgetsRequest | null, protos.google.cloud.billing.budgets.v1beta1.IListBudgetsResponse]> | {Promise} - The promise which resolves to an array. The first element of the array is Array of [Budget]. 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 |
listBudgets(request, options, callback)
listBudgets(request: protos.google.cloud.billing.budgets.v1beta1.IListBudgetsRequest, options: CallOptions, callback: PaginationCallback<protos.google.cloud.billing.budgets.v1beta1.IListBudgetsRequest, protos.google.cloud.billing.budgets.v1beta1.IListBudgetsResponse | null | undefined, protos.google.cloud.billing.budgets.v1beta1.IBudget>): void;
Name | Description |
request |
protos.google.cloud.billing.budgets.v1beta1.IListBudgetsRequest
|
options |
CallOptions
|
callback |
PaginationCallback<protos.google.cloud.billing.budgets.v1beta1.IListBudgetsRequest, protos.google.cloud.billing.budgets.v1beta1.IListBudgetsResponse | null | undefined, protos.google.cloud.billing.budgets.v1beta1.IBudget>
|
Type | Description |
void |
listBudgets(request, callback)
listBudgets(request: protos.google.cloud.billing.budgets.v1beta1.IListBudgetsRequest, callback: PaginationCallback<protos.google.cloud.billing.budgets.v1beta1.IListBudgetsRequest, protos.google.cloud.billing.budgets.v1beta1.IListBudgetsResponse | null | undefined, protos.google.cloud.billing.budgets.v1beta1.IBudget>): void;
Name | Description |
request |
protos.google.cloud.billing.budgets.v1beta1.IListBudgetsRequest
|
callback |
PaginationCallback<protos.google.cloud.billing.budgets.v1beta1.IListBudgetsRequest, protos.google.cloud.billing.budgets.v1beta1.IListBudgetsResponse | null | undefined, protos.google.cloud.billing.budgets.v1beta1.IBudget>
|
Type | Description |
void |
listBudgetsAsync(request, options)
listBudgetsAsync(request?: protos.google.cloud.billing.budgets.v1beta1.IListBudgetsRequest, options?: CallOptions): AsyncIterable<protos.google.cloud.billing.budgets.v1beta1.IBudget>;
Equivalent to listBudgets
, 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.budgets.v1beta1.IListBudgetsRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
AsyncIterable<protos.google.cloud.billing.budgets.v1beta1.IBudget> | {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 [Budget]. 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. Name of billing account to list budgets under. Values
* are of the form `billingAccounts/{billingAccountId}`.
*/
// const parent = 'abc123'
/**
* Optional. The maximum number of budgets to return per page.
* The default and maximum value are 100.
*/
// const pageSize = 1234
/**
* Optional. The value returned by the last `ListBudgetsResponse` which
* indicates that this is a continuation of a prior `ListBudgets` call,
* and that the system should return the next page of data.
*/
// const pageToken = 'abc123'
// Imports the Budgets library
const {BudgetServiceClient} =
require('@google-cloud/billing-budgets').v1beta1;
// Instantiates a client
const budgetsClient = new BudgetServiceClient();
async function callListBudgets() {
// Construct request
const request = {
parent,
};
// Run request
const iterable = await budgetsClient.listBudgetsAsync(request);
for await (const response of iterable) {
console.log(response);
}
}
callListBudgets();
listBudgetsStream(request, options)
listBudgetsStream(request?: protos.google.cloud.billing.budgets.v1beta1.IListBudgetsRequest, options?: CallOptions): Transform;
Equivalent to method.name.toCamelCase()
, but returns a NodeJS Stream object.
Name | Description |
request |
protos.google.cloud.billing.budgets.v1beta1.IListBudgetsRequest
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 [Budget] 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. |
matchBillingAccountFromBudgetName(budgetName)
matchBillingAccountFromBudgetName(budgetName: string): string | number;
Parse the billing_account from Budget resource.
Name | Description |
budgetName |
string
A fully-qualified path representing Budget resource. |
Type | Description |
string | number | {string} A string representing the billing_account. |
matchBudgetFromBudgetName(budgetName)
matchBudgetFromBudgetName(budgetName: string): string | number;
Parse the budget from Budget resource.
Name | Description |
budgetName |
string
A fully-qualified path representing Budget resource. |
Type | Description |
string | number | {string} A string representing the budget. |
updateBudget(request, options)
updateBudget(request?: protos.google.cloud.billing.budgets.v1beta1.IUpdateBudgetRequest, options?: CallOptions): Promise<[protos.google.cloud.billing.budgets.v1beta1.IBudget, (protos.google.cloud.billing.budgets.v1beta1.IUpdateBudgetRequest | undefined), {} | undefined]>;
Updates a budget and returns the updated budget.
WARNING: There are some fields exposed on the Google Cloud Console that aren't available on this API. Budget fields that are not exposed in this API will not be changed by this method.
Name | Description |
request |
protos.google.cloud.billing.budgets.v1beta1.IUpdateBudgetRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[protos.google.cloud.billing.budgets.v1beta1.IBudget, (protos.google.cloud.billing.budgets.v1beta1.IUpdateBudgetRequest | undefined), {} | undefined]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing [Budget]. 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 updated budget object.
* The budget to update is specified by the budget name in the budget.
*/
// const budget = {}
/**
* Optional. Indicates which fields in the provided budget to update.
* Read-only fields (such as `name`) cannot be changed. If this is not
* provided, then only fields with non-default values from the request are
* updated. See
* https://developers.google.com/protocol-buffers/docs/proto3#default for more
* details about default values.
*/
// const updateMask = {}
// Imports the Budgets library
const {BudgetServiceClient} =
require('@google-cloud/billing-budgets').v1beta1;
// Instantiates a client
const budgetsClient = new BudgetServiceClient();
async function callUpdateBudget() {
// Construct request
const request = {
budget,
};
// Run request
const response = await budgetsClient.updateBudget(request);
console.log(response);
}
callUpdateBudget();
updateBudget(request, options, callback)
updateBudget(request: protos.google.cloud.billing.budgets.v1beta1.IUpdateBudgetRequest, options: CallOptions, callback: Callback<protos.google.cloud.billing.budgets.v1beta1.IBudget, protos.google.cloud.billing.budgets.v1beta1.IUpdateBudgetRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.billing.budgets.v1beta1.IUpdateBudgetRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.cloud.billing.budgets.v1beta1.IBudget, protos.google.cloud.billing.budgets.v1beta1.IUpdateBudgetRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
updateBudget(request, callback)
updateBudget(request: protos.google.cloud.billing.budgets.v1beta1.IUpdateBudgetRequest, callback: Callback<protos.google.cloud.billing.budgets.v1beta1.IBudget, protos.google.cloud.billing.budgets.v1beta1.IUpdateBudgetRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.billing.budgets.v1beta1.IUpdateBudgetRequest
|
callback |
Callback<protos.google.cloud.billing.budgets.v1beta1.IBudget, protos.google.cloud.billing.budgets.v1beta1.IUpdateBudgetRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |