-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support the newly added billing endpoint `GET https://billing.tidbapi.com/v1beta1/bills/{YYYY-MM}`, which is compatible with TiDB Cloud API v1beta1 [Release 20230928](https://docs.pingcap.com/tidbcloud/api/v1beta1#section/API-Changelog/2023-09-28). To be compatible with TiDB Cloud API v1beta and v1beta1 in the current release (1.0.8), the following changes are made: - Introduce the `tidbcloudy.baseURL` module to specify the base URL of the API server. For v1beta, the base URL is `https://api.tidbcloud.com/v1beta`. For the billing system v1beta1, the base URL is `https://billing.tidbapi.com/v1beta1`. - To support v1beta and v1beta1 in 1.0.8, `Context.base_url` is removed. Instead, `Context().call_...()` methods accept a `base_url` parameter to specify the base URL of the API server. - To reduce the change of preceding code, such as the Project, Cluster, Backup, and Restore classes, the v1beta base URL is set as the default value when calling `Context().call_...()` methods. - Introduce the `TiDBCloud().get_monthly_bill()` method to support the newly added billing endpoint **Return organization monthly bills** and describe the usage in [`examples/v1beta1_get_monthly_bill.py`](/examples/v1beta1_get_monthly_bill.py).
- Loading branch information
Showing
8 changed files
with
445 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import os | ||
|
||
import tidbcloudy | ||
|
||
public_key = os.environ.get("PUBLIC_KEY") | ||
private_key = os.environ.get("PRIVATE_KEY") | ||
debug_mode = os.environ.get("TIDBCLOUDY_LOG") | ||
|
||
api = tidbcloudy.TiDBCloud(public_key=public_key, private_key=private_key) | ||
billing = api.get_monthly_bill(month="2023-10") | ||
# billing = api.get_monthly_bill(month="202310") | ||
# billing = api.get_current_month_bill() | ||
print(billing) | ||
print(billing.overview) | ||
print(billing.summaryByProject) | ||
print(billing.summaryByService) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "tidbcloudy" | ||
version = "1.0.7" | ||
version = "1.0.8" | ||
description = "(Unofficial) Python SDK for TiDB Cloud" | ||
readme = "README.md" | ||
authors = ["Aolin <[email protected]>"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from enum import Enum | ||
|
||
|
||
class V1BETA(Enum): | ||
HOST = "https://api.tidbcloud.com/api/v1beta/" | ||
|
||
|
||
class V1BETA1(Enum): | ||
BILLING = "https://billing.tidbapi.com/v1beta1/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters