Class BudgetServiceClient (0.4.2)

BudgetServiceClient(
    transport=None,
    channel=None,
    credentials=None,
    client_config=None,
    client_info=None,
    client_options=None,
)

BudgetService stores Cloud Billing budgets, which define a budget plan and rules to execute as we track spend against that plan.

Methods

BudgetServiceClient

BudgetServiceClient(
    transport=None,
    channel=None,
    credentials=None,
    client_config=None,
    client_info=None,
    client_options=None,
)

Constructor.

Parameters
NameDescription
channel grpc.Channel

DEPRECATED. A Channel instance through which to make calls. This argument is mutually exclusive with credentials; providing both will raise an exception.

credentials google.auth.credentials.Credentials

The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. This argument is mutually exclusive with providing a transport instance to transport; doing so will raise an exception.

client_config dict

DEPRECATED. A dictionary of call options for each method. If not specified, the default configuration is used.

client_info google.api_core.gapic_v1.client_info.ClientInfo

The client info used to send a user-agent string along with API requests. If None, then default info will be used. Generally, you only need to set this if you're developing your own client library.

client_options Union[dict, google.api_core.client_options.ClientOptions]

Client options used to set user options on the client. API Endpoint should be set through client_options.

billing_account_path

billing_account_path(billing_account)

Return a fully-qualified billing_account string.

budget_path

budget_path(billing_account, budget)

Return a fully-qualified budget string.

create_budget

create_budget(parent, budget, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Creates a new budget. See Quotas and limits for more information on the limits of the number of budgets you can create.

.. rubric:: Example

from google.cloud import billing_budgets_v1beta1

client = billing_budgets_v1beta1.BudgetServiceClient()

parent = client.billing_account_path('[BILLING_ACCOUNT]')

TODO: Initialize budget:

budget = {}

response = client.create_budget(parent, budget)

Parameters
NameDescription
parent str

Required. The name of the billing account to create the budget in. Values are of the form billingAccounts/{billingAccountId}.

budget Union[dict, Budget]

Required. Budget to create. If a dict is provided, it must be of the same form as the protobuf message Budget

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

delete_budget

delete_budget(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Deletes a budget. Returns successfully if already deleted.

.. rubric:: Example

from google.cloud import billing_budgets_v1beta1

client = billing_budgets_v1beta1.BudgetServiceClient()

name = client.budget_path('[BILLING_ACCOUNT]', '[BUDGET]')

client.delete_budget(name)

Parameters
NameDescription
name str

Required. Name of the budget to delete. Values are of the form billingAccounts/{billingAccountId}/budgets/{budgetId}.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

from_service_account_file

from_service_account_file(filename, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
BudgetServiceClientThe constructed client.

from_service_account_json

from_service_account_json(filename, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
BudgetServiceClientThe constructed client.

get_budget

get_budget(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Returns a budget.

.. rubric:: Example

from google.cloud import billing_budgets_v1beta1

client = billing_budgets_v1beta1.BudgetServiceClient()

name = client.budget_path('[BILLING_ACCOUNT]', '[BUDGET]')

response = client.get_budget(name)

Parameters
NameDescription
name str

Required. Name of budget to get. Values are of the form billingAccounts/{billingAccountId}/budgets/{budgetId}.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

list_budgets

list_budgets(parent, page_size=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Returns a list of budgets for a billing account.

.. rubric:: Example

from google.cloud import billing_budgets_v1beta1

client = billing_budgets_v1beta1.BudgetServiceClient()

parent = client.billing_account_path('[BILLING_ACCOUNT]')

Iterate over all results

for element in client.list_budgets(parent): ... # process element ... pass

Alternatively:

Iterate over results one page at a time

for page in client.list_budgets(parent).pages: ... for element in page: ... # process element ... pass

Parameters
NameDescription
parent str

Required. Name of billing account to list budgets under. Values are of the form billingAccounts/{billingAccountId}.

page_size int

The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

update_budget

update_budget(budget, update_mask=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Updates a budget and returns the updated budget.

.. rubric:: Example

from google.cloud import billing_budgets_v1beta1

client = billing_budgets_v1beta1.BudgetServiceClient()

TODO: Initialize budget:

budget = {}

response = client.update_budget(budget)

Parameters
NameDescription
budget Union[dict, Budget]

Required. The updated budget object. The budget to update is specified by the budget name in the budget. If a dict is provided, it must be of the same form as the protobuf message Budget

update_mask Union[dict, FieldMask]

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. If a dict is provided, it must be of the same form as the protobuf message FieldMask

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.