Skip to content

Commit

Permalink
Make docs useful again (#519)
Browse files Browse the repository at this point in the history
## Changes
The last refactor to docs introduced dataclasses and enum documentation
but regressed on examples and ease of use/navigability by introducing
extremely long pages with many different APIs and classes documented.
This has led to some confusion for users of the SDK who are simply
trying to explore/understand what functionality is supported.

This PR undoes that refactor while preserving the dataclass and enum
documentation, and it even improves on it somewhat, reducing a
substantial amount of visual noise from dataclass constructor signatures
and making enum values easier to read and understand.

Link to preview:
https://databricks-sdk-py--519.org.readthedocs.build/en/519/

## Tests
<!-- 
How is this tested? Please see the checklist below and also describe any
other relevant tests
-->

- [ ] `make test` run locally
- [ ] `make fmt` applied
- [ ] relevant integration tests applied
  • Loading branch information
mgyucht authored Jan 26, 2024
1 parent e37de2c commit 851be2b
Show file tree
Hide file tree
Showing 154 changed files with 20,132 additions and 216 deletions.
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

0 comments on commit 851be2b

Please sign in to comment.