deepctl-cmd-billing 0.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- deepctl_cmd_billing-0.0.2/PKG-INFO +63 -0
- deepctl_cmd_billing-0.0.2/README.md +42 -0
- deepctl_cmd_billing-0.0.2/pyproject.toml +40 -0
- deepctl_cmd_billing-0.0.2/setup.cfg +4 -0
- deepctl_cmd_billing-0.0.2/src/deepctl_cmd_billing/__init__.py +1 -0
- deepctl_cmd_billing-0.0.2/src/deepctl_cmd_billing/command.py +210 -0
- deepctl_cmd_billing-0.0.2/src/deepctl_cmd_billing/models.py +19 -0
- deepctl_cmd_billing-0.0.2/src/deepctl_cmd_billing.egg-info/PKG-INFO +63 -0
- deepctl_cmd_billing-0.0.2/src/deepctl_cmd_billing.egg-info/SOURCES.txt +11 -0
- deepctl_cmd_billing-0.0.2/src/deepctl_cmd_billing.egg-info/dependency_links.txt +1 -0
- deepctl_cmd_billing-0.0.2/src/deepctl_cmd_billing.egg-info/entry_points.txt +2 -0
- deepctl_cmd_billing-0.0.2/src/deepctl_cmd_billing.egg-info/requires.txt +4 -0
- deepctl_cmd_billing-0.0.2/src/deepctl_cmd_billing.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deepctl-cmd-billing
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: Billing command for deepctl
|
|
5
|
+
Author-email: Deepgram <devrel@deepgram.com>
|
|
6
|
+
Maintainer-email: Deepgram <devrel@deepgram.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Keywords: deepgram,cli,billing,usage
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Requires-Dist: deepctl-core>=0.1.10
|
|
18
|
+
Requires-Dist: click>=8.0.0
|
|
19
|
+
Requires-Dist: rich>=13.0.0
|
|
20
|
+
Requires-Dist: pydantic>=2.0.0
|
|
21
|
+
|
|
22
|
+
# deepctl-cmd-billing
|
|
23
|
+
|
|
24
|
+
> Part of [deepctl](https://github.com/deepgram/cli) — Official Deepgram CLI
|
|
25
|
+
|
|
26
|
+
Billing command for deepctl
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
This package is included with deepctl and does not need to be installed separately.
|
|
31
|
+
|
|
32
|
+
### Install deepctl
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Install with pip
|
|
36
|
+
pip install deepctl
|
|
37
|
+
|
|
38
|
+
# Or install with uv
|
|
39
|
+
uv tool install deepctl
|
|
40
|
+
|
|
41
|
+
# Or install with pipx
|
|
42
|
+
pipx install deepctl
|
|
43
|
+
|
|
44
|
+
# Or run without installing
|
|
45
|
+
uvx deepctl --help
|
|
46
|
+
pipx run deepctl --help
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Commands
|
|
50
|
+
|
|
51
|
+
| Command | Entry Point |
|
|
52
|
+
|---------|-------------|
|
|
53
|
+
| `deepctl billing` | `deepctl_cmd_billing.command:BillingCommand` |
|
|
54
|
+
|
|
55
|
+
## Dependencies
|
|
56
|
+
|
|
57
|
+
- `click>=8.0.0`
|
|
58
|
+
- `rich>=13.0.0`
|
|
59
|
+
- `pydantic>=2.0.0`
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
MIT — see [LICENSE](../../LICENSE)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# deepctl-cmd-billing
|
|
2
|
+
|
|
3
|
+
> Part of [deepctl](https://github.com/deepgram/cli) — Official Deepgram CLI
|
|
4
|
+
|
|
5
|
+
Billing command for deepctl
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
This package is included with deepctl and does not need to be installed separately.
|
|
10
|
+
|
|
11
|
+
### Install deepctl
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Install with pip
|
|
15
|
+
pip install deepctl
|
|
16
|
+
|
|
17
|
+
# Or install with uv
|
|
18
|
+
uv tool install deepctl
|
|
19
|
+
|
|
20
|
+
# Or install with pipx
|
|
21
|
+
pipx install deepctl
|
|
22
|
+
|
|
23
|
+
# Or run without installing
|
|
24
|
+
uvx deepctl --help
|
|
25
|
+
pipx run deepctl --help
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Commands
|
|
29
|
+
|
|
30
|
+
| Command | Entry Point |
|
|
31
|
+
|---------|-------------|
|
|
32
|
+
| `deepctl billing` | `deepctl_cmd_billing.command:BillingCommand` |
|
|
33
|
+
|
|
34
|
+
## Dependencies
|
|
35
|
+
|
|
36
|
+
- `click>=8.0.0`
|
|
37
|
+
- `rich>=13.0.0`
|
|
38
|
+
- `pydantic>=2.0.0`
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
MIT — see [LICENSE](../../LICENSE)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "deepctl-cmd-billing"
|
|
7
|
+
version = "0.0.2" # x-release-please-version
|
|
8
|
+
description = "Billing command for deepctl"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
authors = [{ name = "Deepgram", email = "devrel@deepgram.com" }]
|
|
12
|
+
maintainers = [{ name = "Deepgram", email = "devrel@deepgram.com" }]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.10",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
]
|
|
21
|
+
keywords = ["deepgram", "cli", "billing", "usage"]
|
|
22
|
+
requires-python = ">=3.10"
|
|
23
|
+
dependencies = [
|
|
24
|
+
"deepctl-core>=0.1.10",
|
|
25
|
+
"click>=8.0.0",
|
|
26
|
+
"rich>=13.0.0",
|
|
27
|
+
"pydantic>=2.0.0",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.scripts]
|
|
31
|
+
|
|
32
|
+
[project.entry-points."deepctl.commands"]
|
|
33
|
+
billing = "deepctl_cmd_billing.command:BillingCommand"
|
|
34
|
+
|
|
35
|
+
[tool.setuptools]
|
|
36
|
+
package-dir = { "" = "src" }
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.packages.find]
|
|
39
|
+
where = ["src"]
|
|
40
|
+
include = ["deepctl_cmd_billing*"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Billing command for deepctl."""
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"""Billing command for deepctl."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from deepctl_core import (
|
|
8
|
+
AuthManager,
|
|
9
|
+
BaseCommand,
|
|
10
|
+
BaseResult,
|
|
11
|
+
Config,
|
|
12
|
+
DeepgramClient,
|
|
13
|
+
)
|
|
14
|
+
from rich.console import Console
|
|
15
|
+
from rich.table import Table
|
|
16
|
+
|
|
17
|
+
from .models import BalanceInfo, BillingResult
|
|
18
|
+
|
|
19
|
+
console = Console()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class BillingCommand(BaseCommand):
|
|
23
|
+
"""Command for viewing billing information."""
|
|
24
|
+
|
|
25
|
+
name = "billing"
|
|
26
|
+
help = "View Deepgram billing and balances"
|
|
27
|
+
short_help = "Billing info"
|
|
28
|
+
|
|
29
|
+
requires_auth = True
|
|
30
|
+
requires_project = True
|
|
31
|
+
ci_friendly = True
|
|
32
|
+
|
|
33
|
+
examples = [
|
|
34
|
+
"dg billing",
|
|
35
|
+
"dg billing --balances",
|
|
36
|
+
"dg billing --breakdown --start 2025-01-01 --end 2025-01-31",
|
|
37
|
+
"dg billing --breakdown --grouping tags",
|
|
38
|
+
]
|
|
39
|
+
agent_help = (
|
|
40
|
+
"View billing breakdown and account balances for the current project. "
|
|
41
|
+
"Requires authentication and a project ID."
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
def get_arguments(self) -> list[dict[str, Any]]:
|
|
45
|
+
return [
|
|
46
|
+
{
|
|
47
|
+
"names": ["--balances", "-b"],
|
|
48
|
+
"help": "Show account balances",
|
|
49
|
+
"is_flag": True,
|
|
50
|
+
"is_option": True,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"names": ["--breakdown"],
|
|
54
|
+
"help": "Show billing breakdown",
|
|
55
|
+
"is_flag": True,
|
|
56
|
+
"is_option": True,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"names": ["--start"],
|
|
60
|
+
"help": "Start date for breakdown (YYYY-MM-DD)",
|
|
61
|
+
"type": str,
|
|
62
|
+
"is_option": True,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"names": ["--end"],
|
|
66
|
+
"help": "End date for breakdown (YYYY-MM-DD)",
|
|
67
|
+
"type": str,
|
|
68
|
+
"is_option": True,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"names": ["--grouping"],
|
|
72
|
+
"help": "Grouping for breakdown (accessor, deployment, line_item, tags)",
|
|
73
|
+
"type": str,
|
|
74
|
+
"is_option": True,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"names": ["--project-id", "-p"],
|
|
78
|
+
"help": "Project ID (uses configured project if not provided)",
|
|
79
|
+
"type": str,
|
|
80
|
+
"is_option": True,
|
|
81
|
+
},
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
def handle(
|
|
85
|
+
self,
|
|
86
|
+
config: Config,
|
|
87
|
+
auth_manager: AuthManager,
|
|
88
|
+
client: DeepgramClient,
|
|
89
|
+
**kwargs: Any,
|
|
90
|
+
) -> BaseResult:
|
|
91
|
+
show_balances = kwargs.get("balances", False)
|
|
92
|
+
show_breakdown = kwargs.get("breakdown", False)
|
|
93
|
+
project_id = kwargs.get("project_id")
|
|
94
|
+
|
|
95
|
+
try:
|
|
96
|
+
# Default: show both balances and breakdown
|
|
97
|
+
if not show_balances and not show_breakdown:
|
|
98
|
+
show_balances = True
|
|
99
|
+
show_breakdown = True
|
|
100
|
+
|
|
101
|
+
result = BillingResult(status="success")
|
|
102
|
+
|
|
103
|
+
if show_balances:
|
|
104
|
+
self._show_balances(client, project_id, result)
|
|
105
|
+
|
|
106
|
+
if show_breakdown:
|
|
107
|
+
self._show_breakdown(
|
|
108
|
+
client,
|
|
109
|
+
project_id,
|
|
110
|
+
result,
|
|
111
|
+
start=kwargs.get("start"),
|
|
112
|
+
end=kwargs.get("end"),
|
|
113
|
+
grouping=kwargs.get("grouping"),
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
return result
|
|
117
|
+
|
|
118
|
+
except Exception as e:
|
|
119
|
+
console.print(f"[red]Error:[/red] {e}")
|
|
120
|
+
return BaseResult(status="error", message=str(e))
|
|
121
|
+
|
|
122
|
+
def _show_balances(
|
|
123
|
+
self,
|
|
124
|
+
client: DeepgramClient,
|
|
125
|
+
project_id: str | None,
|
|
126
|
+
result: BillingResult,
|
|
127
|
+
) -> None:
|
|
128
|
+
console.print("[blue]Fetching balances...[/blue]")
|
|
129
|
+
data = client.get_balances(project_id=project_id)
|
|
130
|
+
|
|
131
|
+
balances_raw = data.get("balances", [])
|
|
132
|
+
if not balances_raw:
|
|
133
|
+
console.print("[yellow]No balances found[/yellow]")
|
|
134
|
+
return
|
|
135
|
+
|
|
136
|
+
table = Table(
|
|
137
|
+
title="Account Balances", show_header=True, header_style="bold blue"
|
|
138
|
+
)
|
|
139
|
+
table.add_column("Balance ID", style="dim")
|
|
140
|
+
table.add_column("Amount", justify="right", style="green")
|
|
141
|
+
table.add_column("Units")
|
|
142
|
+
|
|
143
|
+
for b in balances_raw:
|
|
144
|
+
b_data = (
|
|
145
|
+
b
|
|
146
|
+
if isinstance(b, dict)
|
|
147
|
+
else (b.__dict__ if hasattr(b, "__dict__") else {})
|
|
148
|
+
)
|
|
149
|
+
info = BalanceInfo(
|
|
150
|
+
balance_id=b_data.get("balance_id", ""),
|
|
151
|
+
amount=float(b_data.get("amount", 0)),
|
|
152
|
+
units=b_data.get("units", ""),
|
|
153
|
+
)
|
|
154
|
+
result.balances.append(info)
|
|
155
|
+
table.add_row(info.balance_id, f"{info.amount:,.2f}", info.units)
|
|
156
|
+
|
|
157
|
+
console.print(table)
|
|
158
|
+
|
|
159
|
+
def _show_breakdown(
|
|
160
|
+
self,
|
|
161
|
+
client: DeepgramClient,
|
|
162
|
+
project_id: str | None,
|
|
163
|
+
result: BillingResult,
|
|
164
|
+
start: str | None = None,
|
|
165
|
+
end: str | None = None,
|
|
166
|
+
grouping: str | None = None,
|
|
167
|
+
) -> None:
|
|
168
|
+
|
|
169
|
+
console.print("[blue]Fetching billing breakdown...[/blue]")
|
|
170
|
+
data = client.get_billing_breakdown(
|
|
171
|
+
project_id=project_id,
|
|
172
|
+
start=start,
|
|
173
|
+
end=end,
|
|
174
|
+
grouping=grouping,
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
result.breakdown = data
|
|
178
|
+
|
|
179
|
+
# Display breakdown summary
|
|
180
|
+
resolution = data.get("resolution", {})
|
|
181
|
+
if resolution:
|
|
182
|
+
period = resolution.get("period", "")
|
|
183
|
+
amount = resolution.get("amount", 0)
|
|
184
|
+
if period:
|
|
185
|
+
console.print(
|
|
186
|
+
f"\n[green]Billing Period:[/green] {period} ({amount} units)"
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
results = data.get("results", [])
|
|
190
|
+
if results:
|
|
191
|
+
table = Table(
|
|
192
|
+
title="Billing Breakdown", show_header=True, header_style="bold blue"
|
|
193
|
+
)
|
|
194
|
+
table.add_column("Period")
|
|
195
|
+
table.add_column("Amount", justify="right", style="green")
|
|
196
|
+
table.add_column("Units")
|
|
197
|
+
|
|
198
|
+
for item in results:
|
|
199
|
+
item_data = item if isinstance(item, dict) else {}
|
|
200
|
+
table.add_row(
|
|
201
|
+
str(item_data.get("start", "-")),
|
|
202
|
+
f"{item_data.get('amount', 0):,.2f}",
|
|
203
|
+
str(item_data.get("units", "")),
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
console.print(table)
|
|
207
|
+
else:
|
|
208
|
+
console.print(
|
|
209
|
+
"[dim]No breakdown data available for the specified period[/dim]"
|
|
210
|
+
)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Models for billing command."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from deepctl_core import BaseResult
|
|
8
|
+
from pydantic import BaseModel, Field
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class BalanceInfo(BaseModel):
|
|
12
|
+
balance_id: str = ""
|
|
13
|
+
amount: float = 0.0
|
|
14
|
+
units: str = ""
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class BillingResult(BaseResult):
|
|
18
|
+
balances: list[BalanceInfo] = Field(default_factory=list)
|
|
19
|
+
breakdown: dict[str, Any] = Field(default_factory=dict)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deepctl-cmd-billing
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: Billing command for deepctl
|
|
5
|
+
Author-email: Deepgram <devrel@deepgram.com>
|
|
6
|
+
Maintainer-email: Deepgram <devrel@deepgram.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Keywords: deepgram,cli,billing,usage
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Requires-Dist: deepctl-core>=0.1.10
|
|
18
|
+
Requires-Dist: click>=8.0.0
|
|
19
|
+
Requires-Dist: rich>=13.0.0
|
|
20
|
+
Requires-Dist: pydantic>=2.0.0
|
|
21
|
+
|
|
22
|
+
# deepctl-cmd-billing
|
|
23
|
+
|
|
24
|
+
> Part of [deepctl](https://github.com/deepgram/cli) — Official Deepgram CLI
|
|
25
|
+
|
|
26
|
+
Billing command for deepctl
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
This package is included with deepctl and does not need to be installed separately.
|
|
31
|
+
|
|
32
|
+
### Install deepctl
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Install with pip
|
|
36
|
+
pip install deepctl
|
|
37
|
+
|
|
38
|
+
# Or install with uv
|
|
39
|
+
uv tool install deepctl
|
|
40
|
+
|
|
41
|
+
# Or install with pipx
|
|
42
|
+
pipx install deepctl
|
|
43
|
+
|
|
44
|
+
# Or run without installing
|
|
45
|
+
uvx deepctl --help
|
|
46
|
+
pipx run deepctl --help
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Commands
|
|
50
|
+
|
|
51
|
+
| Command | Entry Point |
|
|
52
|
+
|---------|-------------|
|
|
53
|
+
| `deepctl billing` | `deepctl_cmd_billing.command:BillingCommand` |
|
|
54
|
+
|
|
55
|
+
## Dependencies
|
|
56
|
+
|
|
57
|
+
- `click>=8.0.0`
|
|
58
|
+
- `rich>=13.0.0`
|
|
59
|
+
- `pydantic>=2.0.0`
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
MIT — see [LICENSE](../../LICENSE)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/deepctl_cmd_billing/__init__.py
|
|
4
|
+
src/deepctl_cmd_billing/command.py
|
|
5
|
+
src/deepctl_cmd_billing/models.py
|
|
6
|
+
src/deepctl_cmd_billing.egg-info/PKG-INFO
|
|
7
|
+
src/deepctl_cmd_billing.egg-info/SOURCES.txt
|
|
8
|
+
src/deepctl_cmd_billing.egg-info/dependency_links.txt
|
|
9
|
+
src/deepctl_cmd_billing.egg-info/entry_points.txt
|
|
10
|
+
src/deepctl_cmd_billing.egg-info/requires.txt
|
|
11
|
+
src/deepctl_cmd_billing.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
deepctl_cmd_billing
|