Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make docs useful again #519

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions docs/account/billing/billable_usage.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
``a.billable_usage``: Billable usage download
=============================================
.. currentmodule:: databricks.sdk.service.billing

.. py:class:: BillableUsageAPI
This API allows you to download billable usage logs for the specified account and date range. This feature
works with all account types.

.. py:method:: download(start_month: str, end_month: str [, personal_data: Optional[bool]]) -> DownloadResponse
Usage:

.. code-block::
from databricks.sdk import AccountClient
a = AccountClient()
resp = a.billable_usage.download(start_month="2023-01", end_month="2023-02")
Return billable usage logs.

Returns billable usage logs in CSV format for the specified account and date range. For the data
schema, see [CSV file schema]. Note that this method might take multiple minutes to complete.

**Warning**: Depending on the queried date range, the number of workspaces in the account, the size of
the response and the internet speed of the caller, this API may hit a timeout after a few minutes. If
you experience this, try to mitigate by calling the API with narrower date ranges.

[CSV file schema]: https://docs.databricks.com/administration-guide/account-settings/usage-analysis.html#schema

:param start_month: str
Format: `YYYY-MM`. First month to return billable usage logs for. This field is required.
:param end_month: str
Format: `YYYY-MM`. Last month to return billable usage logs for. This field is required.
:param personal_data: bool (optional)
Specify whether to include personally identifiable information in the billable usage logs, for
example the email addresses of cluster creators. Handle this information with care. Defaults to
false.

:returns: :class:`DownloadResponse`

162 changes: 162 additions & 0 deletions docs/account/billing/budgets.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
``a.budgets``: Budgets
======================
.. currentmodule:: databricks.sdk.service.billing

.. py:class:: BudgetsAPI
These APIs manage budget configuration including notifications for exceeding a budget for a period. They
can also retrieve the status of each budget.

.. py:method:: create(budget: Budget) -> WrappedBudgetWithStatus
Usage:

.. code-block::
import time
from databricks.sdk import AccountClient
from databricks.sdk.service import billing
a = AccountClient()
created = a.budgets.create(budget=billing.Budget(
name=f'sdk-{time.time_ns()}',
filter="tag.tagName = 'all'",
period="1 month",
start_date="2022-01-01",
target_amount="100",
alerts=[billing.BudgetAlert(email_notifications=["admin@example.com"], min_percentage=50)]))
# cleanup
a.budgets.delete(budget_id=created.budget.budget_id)
Create a new budget.

Creates a new budget in the specified account.

:param budget: :class:`Budget`
Budget configuration to be created.

:returns: :class:`WrappedBudgetWithStatus`


.. py:method:: delete(budget_id: str)
Delete budget.

Deletes the budget specified by its UUID.

:param budget_id: str
Budget ID




.. py:method:: get(budget_id: str) -> WrappedBudgetWithStatus
Usage:

.. code-block::
import time
from databricks.sdk import AccountClient
from databricks.sdk.service import billing
a = AccountClient()
created = a.budgets.create(budget=billing.Budget(
name=f'sdk-{time.time_ns()}',
filter="tag.tagName = 'all'",
period="1 month",
start_date="2022-01-01",
target_amount="100",
alerts=[billing.BudgetAlert(email_notifications=["admin@example.com"], min_percentage=50)]))
by_id = a.budgets.get(budget_id=created.budget.budget_id)
# cleanup
a.budgets.delete(budget_id=created.budget.budget_id)
Get budget and its status.

Gets the budget specified by its UUID, including noncumulative status for each day that the budget is
configured to include.

:param budget_id: str
Budget ID

:returns: :class:`WrappedBudgetWithStatus`


.. py:method:: list() -> Iterator[BudgetWithStatus]
Usage:

.. code-block::
from databricks.sdk import AccountClient
a = AccountClient()
all = a.budgets.list()
Get all budgets.

Gets all budgets associated with this account, including noncumulative status for each day that the
budget is configured to include.

:returns: Iterator over :class:`BudgetWithStatus`


.. py:method:: update(budget_id: str, budget: Budget)
Usage:

.. code-block::
import time
from databricks.sdk import AccountClient
from databricks.sdk.service import billing
a = AccountClient()
created = a.budgets.create(budget=billing.Budget(
name=f'sdk-{time.time_ns()}',
filter="tag.tagName = 'all'",
period="1 month",
start_date="2022-01-01",
target_amount="100",
alerts=[billing.BudgetAlert(email_notifications=["admin@example.com"], min_percentage=50)]))
a.budgets.update(budget_id=created.budget.budget_id,
budget=billing.Budget(name=f'sdk-{time.time_ns()}',
filter="tag.tagName = 'all'",
period="1 month",
start_date="2022-01-01",
target_amount="100",
alerts=[
billing.BudgetAlert(email_notifications=["admin@example.com"],
min_percentage=70)
]))
# cleanup
a.budgets.delete(budget_id=created.budget.budget_id)
Modify budget.

Modifies a budget in this account. Budget properties are completely overwritten.

:param budget_id: str
Budget ID
:param budget: :class:`Budget`
Budget configuration to be created.



12 changes: 12 additions & 0 deletions docs/account/billing/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

Billing
=======

Configure different aspects of Databricks billing and usage.

.. toctree::
:maxdepth: 1

billable_usage
budgets
log_delivery
Loading
Loading