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.
Name | Description |
channel |
grpc.Channel
DEPRECATED. A |
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 |
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 |
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)
Name | Description |
parent |
str
Required. The name of the billing account to create the budget in. Values are of the form |
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 |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If 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)
Name | Description |
name |
str
Required. Name of the budget to delete. Values are of the form |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If 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.
Name | Description |
filename |
str
The path to the service account private key json file. |
Type | Description |
BudgetServiceClient | The constructed client. |
from_service_account_json
from_service_account_json(filename, *args, **kwargs)
Creates an instance of this client using the provided credentials file.
Name | Description |
filename |
str
The path to the service account private key json file. |
Type | Description |
BudgetServiceClient | The 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)
Name | Description |
name |
str
Required. Name of budget to get. Values are of the form |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If 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
Name | Description |
parent |
str
Required. Name of billing account to list budgets under. Values are of the form |
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 |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If 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)
Name | Description |
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 |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |