proxy-platform 0.3.7__tar.gz → 0.7.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.
Files changed (68) hide show
  1. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/PKG-INFO +24 -6
  2. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/README.md +53 -0
  3. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/README.public.md +23 -5
  4. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform/__init__.py +1 -1
  5. proxy_platform-0.7.2/proxy_platform/commands/billing.py +381 -0
  6. proxy_platform-0.7.2/proxy_platform/commands/databases.py +513 -0
  7. proxy_platform-0.7.2/proxy_platform/commands/documents.py +118 -0
  8. proxy_platform-0.7.2/proxy_platform/commands/marketplace.py +432 -0
  9. proxy_platform-0.7.2/proxy_platform/commands/nextcloud.py +120 -0
  10. proxy_platform-0.7.2/proxy_platform/commands/providers.py +261 -0
  11. proxy_platform-0.7.2/proxy_platform/commands/settings.py +167 -0
  12. proxy_platform-0.7.2/proxy_platform/commands/subscriptions.py +142 -0
  13. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform/main.py +26 -1
  14. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform/main_public.py +26 -1
  15. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform.egg-info/PKG-INFO +24 -6
  16. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform.egg-info/SOURCES.txt +28 -0
  17. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/pyproject.toml +1 -1
  18. proxy_platform-0.7.2/tests/test_admin_activities.py +142 -0
  19. proxy_platform-0.7.2/tests/test_admin_audit_logs.py +298 -0
  20. proxy_platform-0.7.2/tests/test_admin_cache.py +473 -0
  21. proxy_platform-0.7.2/tests/test_admin_contact_submissions.py +288 -0
  22. proxy_platform-0.7.2/tests/test_admin_databases.py +986 -0
  23. proxy_platform-0.7.2/tests/test_admin_documents.py +368 -0
  24. proxy_platform-0.7.2/tests/test_admin_feature_flags.py +380 -0
  25. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/tests/test_admin_feedback.py +8 -6
  26. proxy_platform-0.7.2/tests/test_admin_metrics.py +406 -0
  27. proxy_platform-0.7.2/tests/test_admin_nextcloud.py +599 -0
  28. proxy_platform-0.7.2/tests/test_admin_spending.py +139 -0
  29. proxy_platform-0.7.2/tests/test_admin_subscriptions.py +527 -0
  30. proxy_platform-0.7.2/tests/test_admin_support.py +479 -0
  31. proxy_platform-0.7.2/tests/test_billing.py +662 -0
  32. proxy_platform-0.7.2/tests/test_databases.py +856 -0
  33. proxy_platform-0.7.2/tests/test_documents.py +305 -0
  34. proxy_platform-0.7.2/tests/test_marketplace.py +501 -0
  35. proxy_platform-0.7.2/tests/test_nextcloud.py +192 -0
  36. proxy_platform-0.7.2/tests/test_providers.py +494 -0
  37. proxy_platform-0.7.2/tests/test_settings.py +364 -0
  38. proxy_platform-0.7.2/tests/test_subscriptions.py +260 -0
  39. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform/client.py +0 -0
  40. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform/commands/__init__.py +0 -0
  41. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform/commands/auth.py +0 -0
  42. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform/commands/clusters.py +0 -0
  43. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform/commands/deployments.py +0 -0
  44. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform/commands/feedback.py +0 -0
  45. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform/commands/firewalls.py +0 -0
  46. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform/commands/orders.py +0 -0
  47. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform/commands/products.py +0 -0
  48. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform/commands/support.py +0 -0
  49. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform/commands/users.py +0 -0
  50. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform/config.py +0 -0
  51. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform.egg-info/dependency_links.txt +0 -0
  52. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform.egg-info/entry_points.txt +0 -0
  53. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform.egg-info/requires.txt +0 -0
  54. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/proxy_platform.egg-info/top_level.txt +0 -0
  55. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/setup.cfg +0 -0
  56. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/setup.py +0 -0
  57. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/tests/test_auth.py +0 -0
  58. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/tests/test_client.py +0 -0
  59. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/tests/test_clusters.py +0 -0
  60. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/tests/test_config.py +0 -0
  61. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/tests/test_deployments.py +0 -0
  62. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/tests/test_dev.py +0 -0
  63. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/tests/test_feedback.py +0 -0
  64. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/tests/test_firewalls.py +0 -0
  65. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/tests/test_main.py +0 -0
  66. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/tests/test_orders.py +0 -0
  67. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/tests/test_products.py +0 -0
  68. {proxy_platform-0.3.7 → proxy_platform-0.7.2}/tests/test_users.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: proxy-platform
3
- Version: 0.3.7
3
+ Version: 0.7.2
4
4
  Summary: CLI client for the Proxy Platform
5
5
  Author: Proxy Platform B.V.
6
6
  License: Proprietary - Proxy Platform B.V.
@@ -48,12 +48,21 @@ proxy-platform login
48
48
  # Browse the product catalog
49
49
  proxy-platform products list
50
50
 
51
- # Create an order
52
- proxy-platform orders create
53
-
54
51
  # List your clusters
55
52
  proxy-platform clusters list
56
53
 
54
+ # List your managed databases
55
+ proxy-platform databases list
56
+
57
+ # List your managed Nextcloud environments
58
+ proxy-platform nextcloud list
59
+
60
+ # Browse the marketplace
61
+ proxy-platform marketplace list
62
+
63
+ # View your invoices
64
+ proxy-platform billing invoices
65
+
57
66
  # View your profile
58
67
  proxy-platform users profile
59
68
  ```
@@ -65,16 +74,25 @@ proxy-platform users profile
65
74
  | `auth` | Login, logout, and session management |
66
75
  | `products` | Browse the product catalog |
67
76
  | `orders` | Create and manage orders |
68
- | `clusters` | Manage your clusters |
77
+ | `clusters` | Manage your Kubernetes clusters |
78
+ | `databases` | Manage your managed databases |
79
+ | `nextcloud` | Manage your managed Nextcloud environments |
80
+ | `marketplace` | Browse marketplace apps, versions, and reviews |
81
+ | `billing` | Invoices, billing information, and payments |
82
+ | `subscriptions` | View and manage your subscriptions |
69
83
  | `firewall` | Manage firewall rules |
84
+ | `providers` | Cloud provider regions and server types |
85
+ | `documents` | Download your documents |
86
+ | `settings` | Manage your account preferences |
70
87
  | `users` | View and update your profile |
71
88
  | `support` | Open and track support tickets |
72
- | `feedback` | Submit feedback |
89
+ | `feedback` | Submit feedback and feature requests |
73
90
 
74
91
  Run any command with `--help` for usage details:
75
92
 
76
93
  ```bash
77
94
  proxy-platform clusters --help
95
+ proxy-platform databases list --help
78
96
  proxy-platform orders create --help
79
97
  ```
80
98
 
@@ -19,10 +19,18 @@ As a Proxy employee you can install **both** at the same time — one for your d
19
19
  - 🌍 **Multi-environment** - Switch between development, test, acceptance, and production
20
20
  - 🎯 **Dual API Support** - Separate Admin and User commands for clear access control
21
21
  - 🖥️ **Cluster Management** - List, inspect, rename, delete, kubeconfig, and etcd key
22
+ - 🗄️ **Managed Databases** - Manage database instances, backups, connection info, and upgrades
23
+ - ☁️ **Managed Nextcloud** - Manage Nextcloud environments (admin: nodes, slots, HPB, app-allowlist)
22
24
  - 🛒 **Orders & Payments** - Guided or fully non-interactive order creation
25
+ - 🧾 **Billing & Subscriptions** - Invoices, billing info, VAT validation, and subscriptions
26
+ - 🧩 **Marketplace** - Browse listings, versions, categories, and reviews
23
27
  - 🔥 **Firewall Management** - Create and manage firewall rules
28
+ - 🌐 **Providers** - Cloud provider regions, server types, and console URLs
29
+ - 📄 **Documents** - Download platform and account documents
30
+ - ⚙️ **Settings** - Manage account preferences and metadata
24
31
  - 🎫 **Support Tickets** - Submit and track support requests
25
32
  - 💬 **Feedback Portal** - Submit feature requests and vote on community feedback
33
+ - 🛠️ **Admin Tooling** - Admin-only groups for clusters, databases, Nextcloud, subscriptions, metrics, audit logs, cache, feature flags, and more
26
34
  - 📊 **Rich Output** - Beautiful tables and formatted output
27
35
  - 🚀 **Easy to Use** - Intuitive command structure with shell completion
28
36
  - 💾 **Token Storage** - Secure token management in `~/.proxy-platform/`
@@ -301,6 +309,51 @@ proxy-platform-admin feedback unvote <feedback-id>
301
309
  proxy-platform-admin feedback comment <feedback-id> --content "I need this too"
302
310
  ```
303
311
 
312
+ ### Managed Databases
313
+
314
+ ```bash
315
+ proxy-platform-admin databases list
316
+ proxy-platform-admin databases get <instance-id>
317
+ proxy-platform-admin databases connection <instance-id>
318
+ proxy-platform-admin databases backups <instance-id>
319
+ proxy-platform-admin databases locations
320
+ ```
321
+
322
+ ### Managed Nextcloud
323
+
324
+ ```bash
325
+ proxy-platform-admin nextcloud list
326
+ proxy-platform-admin nextcloud get <instance-id>
327
+ proxy-platform-admin nextcloud rename <instance-id> "New name"
328
+ ```
329
+
330
+ ### Marketplace
331
+
332
+ ```bash
333
+ proxy-platform-admin marketplace list
334
+ proxy-platform-admin marketplace get <listing-id>
335
+ proxy-platform-admin marketplace categories
336
+ proxy-platform-admin marketplace reviews <listing-id>
337
+ ```
338
+
339
+ ### Billing & Subscriptions
340
+
341
+ ```bash
342
+ proxy-platform-admin billing billing-info
343
+ proxy-platform-admin billing invoices
344
+ proxy-platform-admin billing profile
345
+ proxy-platform-admin subscriptions list
346
+ ```
347
+
348
+ ### Providers, Documents & Settings
349
+
350
+ ```bash
351
+ proxy-platform-admin providers list
352
+ proxy-platform-admin providers regions <slug>
353
+ proxy-platform-admin documents list
354
+ proxy-platform-admin settings update-preferences --data '{"theme": "dark"}'
355
+ ```
356
+
304
357
  ### Admin Commands (Proxy employees only)
305
358
 
306
359
  ```bash
@@ -26,12 +26,21 @@ proxy-platform login
26
26
  # Browse the product catalog
27
27
  proxy-platform products list
28
28
 
29
- # Create an order
30
- proxy-platform orders create
31
-
32
29
  # List your clusters
33
30
  proxy-platform clusters list
34
31
 
32
+ # List your managed databases
33
+ proxy-platform databases list
34
+
35
+ # List your managed Nextcloud environments
36
+ proxy-platform nextcloud list
37
+
38
+ # Browse the marketplace
39
+ proxy-platform marketplace list
40
+
41
+ # View your invoices
42
+ proxy-platform billing invoices
43
+
35
44
  # View your profile
36
45
  proxy-platform users profile
37
46
  ```
@@ -43,16 +52,25 @@ proxy-platform users profile
43
52
  | `auth` | Login, logout, and session management |
44
53
  | `products` | Browse the product catalog |
45
54
  | `orders` | Create and manage orders |
46
- | `clusters` | Manage your clusters |
55
+ | `clusters` | Manage your Kubernetes clusters |
56
+ | `databases` | Manage your managed databases |
57
+ | `nextcloud` | Manage your managed Nextcloud environments |
58
+ | `marketplace` | Browse marketplace apps, versions, and reviews |
59
+ | `billing` | Invoices, billing information, and payments |
60
+ | `subscriptions` | View and manage your subscriptions |
47
61
  | `firewall` | Manage firewall rules |
62
+ | `providers` | Cloud provider regions and server types |
63
+ | `documents` | Download your documents |
64
+ | `settings` | Manage your account preferences |
48
65
  | `users` | View and update your profile |
49
66
  | `support` | Open and track support tickets |
50
- | `feedback` | Submit feedback |
67
+ | `feedback` | Submit feedback and feature requests |
51
68
 
52
69
  Run any command with `--help` for usage details:
53
70
 
54
71
  ```bash
55
72
  proxy-platform clusters --help
73
+ proxy-platform databases list --help
56
74
  proxy-platform orders create --help
57
75
  ```
58
76
 
@@ -1,3 +1,3 @@
1
1
  """Proxy Platform CLI."""
2
2
 
3
- __version__ = "0.3.7"
3
+ __version__ = "0.7.2"
@@ -0,0 +1,381 @@
1
+ """Billing & payments commands for users."""
2
+
3
+ import json
4
+ from pathlib import Path
5
+
6
+ import typer
7
+ from rich.console import Console
8
+
9
+ from ..client import APIClient
10
+
11
+ app = typer.Typer(help="Billing & payments")
12
+ console = Console()
13
+
14
+
15
+ @app.command(name="billing-info")
16
+ def billing_info(
17
+ api: str = typer.Option("user", "--api", "-a", help="API type (admin or user)"),
18
+ ) -> None:
19
+ """Show your billing information.
20
+
21
+ Examples:
22
+ proxy-platform billing billing-info
23
+ """
24
+ try:
25
+ client = APIClient(api_type=api)
26
+ response = client.get("/api/v1/payments/my-billing-info")
27
+
28
+ if response.status_code != 200:
29
+ console.print(f"[red]Error: {response.status_code}[/red]")
30
+ try:
31
+ console.print(response.json().get("detail", "Unknown error"))
32
+ except Exception:
33
+ console.print(response.text)
34
+ raise typer.Exit(1)
35
+
36
+ info = response.json()
37
+ console.print()
38
+ console.print("[bold]Billing Information[/bold]")
39
+ console.print("-" * 70)
40
+ for key, value in info.items():
41
+ console.print(f"{key}: [cyan]{value}[/cyan]")
42
+ console.print()
43
+
44
+ except typer.Exit:
45
+ raise
46
+ except Exception as e:
47
+ console.print(f"[red]Error: {e}[/red]")
48
+ raise typer.Exit(1) from None
49
+
50
+
51
+ @app.command(name="check-credit")
52
+ def check_credit(
53
+ data: str = typer.Option(..., "--data", "-d", help="JSON payload"),
54
+ api: str = typer.Option("user", "--api", "-a", help="API type (admin or user)"),
55
+ ) -> None:
56
+ """Check available credit for a payment.
57
+
58
+ Examples:
59
+ proxy-platform billing check-credit --data '{"amount": 10.0}'
60
+ """
61
+ try:
62
+ payload = json.loads(data)
63
+ except json.JSONDecodeError as e:
64
+ console.print(f"[red]Error: Invalid JSON payload: {e}[/red]")
65
+ raise typer.Exit(1) from None
66
+
67
+ try:
68
+ client = APIClient(api_type=api)
69
+ response = client.post("/api/v1/payments/check-credit", data=payload)
70
+
71
+ if response.status_code != 200:
72
+ console.print(f"[red]Error: {response.status_code}[/red]")
73
+ try:
74
+ console.print(response.json().get("detail", "Unknown error"))
75
+ except Exception:
76
+ console.print(response.text)
77
+ raise typer.Exit(1)
78
+
79
+ result = response.json()
80
+ console.print()
81
+ console.print("[bold]Credit Check[/bold]")
82
+ console.print("-" * 70)
83
+ for key, value in result.items():
84
+ console.print(f"{key}: [cyan]{value}[/cyan]")
85
+ console.print()
86
+
87
+ except typer.Exit:
88
+ raise
89
+ except Exception as e:
90
+ console.print(f"[red]Error: {e}[/red]")
91
+ raise typer.Exit(1) from None
92
+
93
+
94
+ @app.command(name="create-payment")
95
+ def create_payment(
96
+ data: str = typer.Option(..., "--data", "-d", help="JSON payload"),
97
+ api: str = typer.Option("user", "--api", "-a", help="API type (admin or user)"),
98
+ ) -> None:
99
+ """Create a new payment.
100
+
101
+ Examples:
102
+ proxy-platform billing create-payment --data '{"order_id": "..."}'
103
+ """
104
+ try:
105
+ payload = json.loads(data)
106
+ except json.JSONDecodeError as e:
107
+ console.print(f"[red]Error: Invalid JSON payload: {e}[/red]")
108
+ raise typer.Exit(1) from None
109
+
110
+ try:
111
+ client = APIClient(api_type=api)
112
+ response = client.post("/api/v1/payments/create", data=payload)
113
+
114
+ if response.status_code not in (200, 201):
115
+ console.print(f"[red]Error: {response.status_code}[/red]")
116
+ try:
117
+ console.print(response.json().get("detail", "Unknown error"))
118
+ except Exception:
119
+ console.print(response.text)
120
+ raise typer.Exit(1)
121
+
122
+ result = response.json()
123
+ console.print()
124
+ console.print("[green]Payment created successfully![/green]")
125
+ console.print()
126
+ console.print("[bold]Payment Details[/bold]")
127
+ console.print("-" * 70)
128
+ for key, value in result.items():
129
+ console.print(f"{key}: [cyan]{value}[/cyan]")
130
+ console.print()
131
+
132
+ except typer.Exit:
133
+ raise
134
+ except Exception as e:
135
+ console.print(f"[red]Error: {e}[/red]")
136
+ raise typer.Exit(1) from None
137
+
138
+
139
+ @app.command(name="order-status")
140
+ def order_status(
141
+ order_id: str = typer.Argument(..., help="Order ID (UUID)"),
142
+ api: str = typer.Option("user", "--api", "-a", help="API type (admin or user)"),
143
+ ) -> None:
144
+ """Show the payment status of one of your orders.
145
+
146
+ Examples:
147
+ proxy-platform billing order-status <order-id>
148
+ """
149
+ try:
150
+ client = APIClient(api_type=api)
151
+ response = client.get(f"/api/v1/payments/my-orders/{order_id}/status")
152
+
153
+ if response.status_code != 200:
154
+ console.print(f"[red]Error: {response.status_code}[/red]")
155
+ try:
156
+ console.print(response.json().get("detail", "Unknown error"))
157
+ except Exception:
158
+ console.print(response.text)
159
+ raise typer.Exit(1)
160
+
161
+ result = response.json()
162
+ console.print()
163
+ console.print(f"[bold]Order Status: [cyan]{order_id}[/cyan][/bold]")
164
+ console.print("-" * 70)
165
+ for key, value in result.items():
166
+ console.print(f"{key}: [cyan]{value}[/cyan]")
167
+ console.print()
168
+
169
+ except typer.Exit:
170
+ raise
171
+ except Exception as e:
172
+ console.print(f"[red]Error: {e}[/red]")
173
+ raise typer.Exit(1) from None
174
+
175
+
176
+ @app.command(name="invoice-details")
177
+ def invoice_details(
178
+ order_id: str = typer.Argument(..., help="Order ID (UUID)"),
179
+ api: str = typer.Option("user", "--api", "-a", help="API type (admin or user)"),
180
+ ) -> None:
181
+ """Show invoice details for one of your orders.
182
+
183
+ Examples:
184
+ proxy-platform billing invoice-details <order-id>
185
+ """
186
+ try:
187
+ client = APIClient(api_type=api)
188
+ response = client.get(f"/api/v1/payments/my-orders/{order_id}/invoice-details")
189
+
190
+ if response.status_code != 200:
191
+ console.print(f"[red]Error: {response.status_code}[/red]")
192
+ try:
193
+ console.print(response.json().get("detail", "Unknown error"))
194
+ except Exception:
195
+ console.print(response.text)
196
+ raise typer.Exit(1)
197
+
198
+ result = response.json()
199
+ console.print()
200
+ console.print(f"[bold]Invoice Details: [cyan]{order_id}[/cyan][/bold]")
201
+ console.print("-" * 70)
202
+ for key, value in result.items():
203
+ console.print(f"{key}: [cyan]{value}[/cyan]")
204
+ console.print()
205
+
206
+ except typer.Exit:
207
+ raise
208
+ except Exception as e:
209
+ console.print(f"[red]Error: {e}[/red]")
210
+ raise typer.Exit(1) from None
211
+
212
+
213
+ @app.command(name="invoice-pdf")
214
+ def invoice_pdf(
215
+ order_id: str = typer.Argument(..., help="Order ID (UUID)"),
216
+ output: str | None = typer.Option(
217
+ None, "--output", "-o", help="Output file path (default: invoice-<order-id>.pdf)"
218
+ ),
219
+ api: str = typer.Option("user", "--api", "-a", help="API type (admin or user)"),
220
+ ) -> None:
221
+ """Download the invoice PDF for one of your orders.
222
+
223
+ Examples:
224
+ proxy-platform billing invoice-pdf <order-id>
225
+ proxy-platform billing invoice-pdf <order-id> --output invoice.pdf
226
+ """
227
+ try:
228
+ client = APIClient(api_type=api)
229
+ response = client.get(f"/api/v1/payments/my-orders/{order_id}/invoice-pdf")
230
+
231
+ if response.status_code != 200:
232
+ console.print(f"[red]Error: {response.status_code}[/red]")
233
+ try:
234
+ console.print(response.json().get("detail", "Unknown error"))
235
+ except Exception:
236
+ console.print(response.text)
237
+ raise typer.Exit(1)
238
+
239
+ output_path = Path(output) if output else Path(f"invoice-{order_id}.pdf")
240
+ output_path.write_bytes(response.content)
241
+ console.print(f"[green]Invoice saved to [cyan]{output_path}[/cyan][/green]")
242
+
243
+ except typer.Exit:
244
+ raise
245
+ except Exception as e:
246
+ console.print(f"[red]Error: {e}[/red]")
247
+ raise typer.Exit(1) from None
248
+
249
+
250
+ def _billing_get_and_print(endpoint: str, api: str, title: str) -> None:
251
+ """GET a billing endpoint and print the JSON result."""
252
+ try:
253
+ client = APIClient(api_type=api)
254
+ response = client.get(endpoint)
255
+
256
+ if response.status_code != 200:
257
+ console.print(f"[red]Error: {response.status_code}[/red]")
258
+ try:
259
+ console.print(response.json().get("detail", "Unknown error"))
260
+ except Exception:
261
+ console.print(response.text)
262
+ raise typer.Exit(1)
263
+
264
+ console.print()
265
+ console.print(f"[bold]{title}[/bold]")
266
+ console.print("-" * 70)
267
+ console.print_json(data=response.json())
268
+ console.print()
269
+
270
+ except typer.Exit:
271
+ raise
272
+ except Exception as e:
273
+ console.print(f"[red]Error: {e}[/red]")
274
+ raise typer.Exit(1) from None
275
+
276
+
277
+ @app.command(name="invoices")
278
+ def list_invoices(
279
+ api: str = typer.Option("user", "--api", "-a", help="API type (admin or user)"),
280
+ ) -> None:
281
+ """List your invoices.
282
+
283
+ Examples:
284
+ proxy-platform billing invoices
285
+ """
286
+ _billing_get_and_print("/api/v1/billing/invoices", api, "Invoices")
287
+
288
+
289
+ @app.command(name="download-invoice")
290
+ def download_invoice(
291
+ invoice_id: str = typer.Argument(..., help="Invoice ID"),
292
+ output: str | None = typer.Option(None, "--output", "-o", help="Output file path"),
293
+ api: str = typer.Option("user", "--api", "-a", help="API type (admin or user)"),
294
+ ) -> None:
295
+ """Download an invoice PDF by invoice ID.
296
+
297
+ Examples:
298
+ proxy-platform billing download-invoice <invoice-id>
299
+ """
300
+ try:
301
+ client = APIClient(api_type=api)
302
+ response = client.get(f"/api/v1/billing/invoices/{invoice_id}/pdf")
303
+
304
+ if response.status_code != 200:
305
+ console.print(f"[red]Error: {response.status_code}[/red]")
306
+ try:
307
+ console.print(response.json().get("detail", "Unknown error"))
308
+ except Exception:
309
+ console.print(response.text)
310
+ raise typer.Exit(1)
311
+
312
+ output_path = Path(output) if output else Path(f"invoice-{invoice_id}.pdf")
313
+ output_path.write_bytes(response.content)
314
+ console.print(f"[green]Invoice saved to [cyan]{output_path}[/cyan][/green]")
315
+
316
+ except typer.Exit:
317
+ raise
318
+ except Exception as e:
319
+ console.print(f"[red]Error: {e}[/red]")
320
+ raise typer.Exit(1) from None
321
+
322
+
323
+ @app.command(name="validate-vat")
324
+ def validate_vat(
325
+ data: str = typer.Option(..., "--data", "-d", help="JSON payload"),
326
+ api: str = typer.Option("user", "--api", "-a", help="API type (admin or user)"),
327
+ ) -> None:
328
+ """Validate a VAT number.
329
+
330
+ Examples:
331
+ proxy-platform billing validate-vat --data '{"vat_number": "NL123456789B01"}'
332
+ """
333
+ try:
334
+ payload = json.loads(data)
335
+ except json.JSONDecodeError as e:
336
+ console.print(f"[red]Error: Invalid JSON payload: {e}[/red]")
337
+ raise typer.Exit(1) from None
338
+
339
+ try:
340
+ client = APIClient(api_type=api)
341
+ response = client.post("/api/v1/billing/vat/validate", data=payload)
342
+
343
+ if response.status_code != 200:
344
+ console.print(f"[red]Error: {response.status_code}[/red]")
345
+ try:
346
+ console.print(response.json().get("detail", "Unknown error"))
347
+ except Exception:
348
+ console.print(response.text)
349
+ raise typer.Exit(1)
350
+
351
+ console.print_json(data=response.json())
352
+
353
+ except typer.Exit:
354
+ raise
355
+ except Exception as e:
356
+ console.print(f"[red]Error: {e}[/red]")
357
+ raise typer.Exit(1) from None
358
+
359
+
360
+ @app.command(name="profile")
361
+ def billing_profile(
362
+ api: str = typer.Option("user", "--api", "-a", help="API type (admin or user)"),
363
+ ) -> None:
364
+ """Show your billing profile.
365
+
366
+ Examples:
367
+ proxy-platform billing profile
368
+ """
369
+ _billing_get_and_print("/api/v1/billing/profile", api, "Billing Profile")
370
+
371
+
372
+ @app.command(name="countries")
373
+ def list_countries(
374
+ api: str = typer.Option("user", "--api", "-a", help="API type (admin or user)"),
375
+ ) -> None:
376
+ """List supported billing countries.
377
+
378
+ Examples:
379
+ proxy-platform billing countries
380
+ """
381
+ _billing_get_and_print("/api/v1/billing/countries", api, "Countries")