proxcli 0.7.0__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 (52) hide show
  1. {proxcli-0.7.0 → proxcli-0.7.2}/CHANGELOG.md +20 -0
  2. {proxcli-0.7.0 → proxcli-0.7.2}/PKG-INFO +18 -1
  3. {proxcli-0.7.0 → proxcli-0.7.2}/README.md +17 -0
  4. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/cli/main.py +68 -16
  5. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/client/auth.py +1 -4
  6. {proxcli-0.7.0 → proxcli-0.7.2}/pyproject.toml +1 -1
  7. {proxcli-0.7.0 → proxcli-0.7.2}/tests/test_auth.py +1 -5
  8. {proxcli-0.7.0 → proxcli-0.7.2}/uv.lock +1 -1
  9. {proxcli-0.7.0 → proxcli-0.7.2}/.env.example +0 -0
  10. {proxcli-0.7.0 → proxcli-0.7.2}/.github/workflows/ci.yml +0 -0
  11. {proxcli-0.7.0 → proxcli-0.7.2}/.gitignore +0 -0
  12. {proxcli-0.7.0 → proxcli-0.7.2}/.python-version +0 -0
  13. {proxcli-0.7.0 → proxcli-0.7.2}/AGENTS.md +0 -0
  14. {proxcli-0.7.0 → proxcli-0.7.2}/PLAN.md +0 -0
  15. {proxcli-0.7.0 → proxcli-0.7.2}/PROJECT.md +0 -0
  16. {proxcli-0.7.0 → proxcli-0.7.2}/PROMPT.md +0 -0
  17. {proxcli-0.7.0 → proxcli-0.7.2}/TODO.md +0 -0
  18. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/__init__.py +0 -0
  19. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/cli/__init__.py +0 -0
  20. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/cli/auth.py +0 -0
  21. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/cli/cluster.py +0 -0
  22. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/cli/completion.py +0 -0
  23. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/cli/container.py +0 -0
  24. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/cli/firewall_helpers.py +0 -0
  25. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/cli/node.py +0 -0
  26. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/cli/pool.py +0 -0
  27. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/cli/storage.py +0 -0
  28. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/cli/tasks.py +0 -0
  29. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/cli/vm.py +0 -0
  30. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/client/__init__.py +0 -0
  31. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/client/client.py +0 -0
  32. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/client/exceptions.py +0 -0
  33. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/config/__init__.py +0 -0
  34. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/config/config.py +0 -0
  35. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/config/models.py +0 -0
  36. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/output/__init__.py +0 -0
  37. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/output/formatter.py +0 -0
  38. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/output/json_fmt.py +0 -0
  39. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/output/table_fmt.py +0 -0
  40. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/output/yaml_fmt.py +0 -0
  41. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/utils/__init__.py +0 -0
  42. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/utils/helpers.py +0 -0
  43. {proxcli-0.7.0 → proxcli-0.7.2}/proxmox/utils/logging.py +0 -0
  44. {proxcli-0.7.0 → proxcli-0.7.2}/tests/__init__.py +0 -0
  45. {proxcli-0.7.0 → proxcli-0.7.2}/tests/conftest.py +0 -0
  46. {proxcli-0.7.0 → proxcli-0.7.2}/tests/test_cli/__init__.py +0 -0
  47. {proxcli-0.7.0 → proxcli-0.7.2}/tests/test_cli/test_main.py +0 -0
  48. {proxcli-0.7.0 → proxcli-0.7.2}/tests/test_client.py +0 -0
  49. {proxcli-0.7.0 → proxcli-0.7.2}/tests/test_config.py +0 -0
  50. {proxcli-0.7.0 → proxcli-0.7.2}/tests/test_integration/__init__.py +0 -0
  51. {proxcli-0.7.0 → proxcli-0.7.2}/tests/test_output/__init__.py +0 -0
  52. {proxcli-0.7.0 → proxcli-0.7.2}/tests/test_output/test_formatter.py +0 -0
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.7.2] - 2026-06-20
11
+
12
+ ### Added
13
+ - Helpful hint when global flags are placed after the resource subcommand.
14
+ Running `proxmox vm list --output table` now shows:
15
+ `Error: Global flag '--output' must come before the resource. Try: proxmox --output vm list ...`
16
+
17
+ ## [0.7.1] - 2026-06-20
18
+
19
+ ### Fixed
20
+ - API token authentication: Removed incorrect base64 encoding.
21
+ Proxmox expects `PVEAPIToken=user@realm!tokenid=secret` as plain text
22
+ in the Authorization header, not base64-encoded.
23
+ - Dry-run mode now always sets API token headers so that
24
+ `--dry-run` output accurately reflects the Authorization header
25
+ that would be sent. (Password auth is still skipped in dry-run
26
+ since it requires a network call.)
27
+
10
28
  ## [0.7.0] - 2026-06-20
11
29
 
12
30
  ### Added
@@ -82,6 +100,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
82
100
  - CSRF ticket auto-refresh on 401.
83
101
  - AI-agent-friendly: default JSON output, strict exit codes, `--dry-run` mode.
84
102
 
103
+ [0.7.2]: https://github.com/xezpeleta/proxcli/releases/tag/v0.7.2
104
+ [0.7.1]: https://github.com/xezpeleta/proxcli/releases/tag/v0.7.1
85
105
  [0.7.0]: https://github.com/xezpeleta/proxcli/releases/tag/v0.7.0
86
106
  [0.6.0]: https://github.com/xezpeleta/proxcli/releases/tag/v0.6.0
87
107
  [0.5.0]: https://github.com/xezpeleta/proxcli/releases/tag/v0.5.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: proxcli
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: A CLI tool to interact with Proxmox VE nodes and clusters via the REST API
5
5
  Author-email: Xabi Ezpeleta <xezpeleta@gmail.com>
6
6
  License: MIT
@@ -108,6 +108,23 @@ proxmox vm list --username root@pam --url https://pve:8006
108
108
  proxmox --insecure vm list
109
109
  ```
110
110
 
111
+ ### Manual config file
112
+
113
+ If you prefer to hand-edit credentials, create `~/.config/proxmox-cli/credentials.json` (chmod 600):
114
+
115
+ ```json
116
+ {
117
+ "url": "https://192.168.1.10:8006",
118
+ "username": "root@pam",
119
+ "auth_method": "api_token",
120
+ "api_token_id": "my-token",
121
+ "api_token_secret": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
122
+ "verify_tls": false
123
+ }
124
+ ```
125
+
126
+ For password auth, use `"auth_method": "password"` with a `"password"` field instead of `api_token_id` / `api_token_secret`.
127
+
111
128
  ## Command Reference
112
129
 
113
130
  ### Global flags
@@ -85,6 +85,23 @@ proxmox vm list --username root@pam --url https://pve:8006
85
85
  proxmox --insecure vm list
86
86
  ```
87
87
 
88
+ ### Manual config file
89
+
90
+ If you prefer to hand-edit credentials, create `~/.config/proxmox-cli/credentials.json` (chmod 600):
91
+
92
+ ```json
93
+ {
94
+ "url": "https://192.168.1.10:8006",
95
+ "username": "root@pam",
96
+ "auth_method": "api_token",
97
+ "api_token_id": "my-token",
98
+ "api_token_secret": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
99
+ "verify_tls": false
100
+ }
101
+ ```
102
+
103
+ For password auth, use `"auth_method": "password"` with a `"password"` field instead of `api_token_id` / `api_token_secret`.
104
+
88
105
  ## Command Reference
89
106
 
90
107
  ### Global flags
@@ -149,21 +149,19 @@ def _build_client(overrides: dict[str, Any], args: argparse.Namespace) -> Proxmo
149
149
 
150
150
  auth_mgr = AuthManager()
151
151
 
152
- # Don't authenticate if dry-run (no actual API calls will be made)
153
- if not args.dry_run:
154
- if overrides["api_token_id"] and overrides["api_token_secret"]:
155
- auth_mgr.set_api_token(
156
- overrides["username"] or "root@pam",
157
- overrides["api_token_id"],
158
- overrides["api_token_secret"],
159
- )
160
- elif overrides["password"]:
161
- auth_mgr.authenticate_password(
162
- overrides["url"],
163
- overrides["username"] or "root@pam",
164
- overrides["password"],
165
- verify=overrides["verify_tls"],
166
- )
152
+ if overrides["api_token_id"] and overrides["api_token_secret"]:
153
+ auth_mgr.set_api_token(
154
+ overrides["username"] or "root@pam",
155
+ overrides["api_token_id"],
156
+ overrides["api_token_secret"],
157
+ )
158
+ elif overrides["password"] and not args.dry_run:
159
+ auth_mgr.authenticate_password(
160
+ overrides["url"],
161
+ overrides["username"] or "root@pam",
162
+ overrides["password"],
163
+ verify=overrides["verify_tls"],
164
+ )
167
165
 
168
166
  client = ProxmoxClient(
169
167
  base_url=overrides["url"],
@@ -195,10 +193,64 @@ def _print_command_help(args: argparse.Namespace) -> None:
195
193
  )
196
194
 
197
195
 
196
+ GLOBAL_FLAGS = {
197
+ "--url", "--username", "--password", "--password-stdin", "--api-token",
198
+ "--output", "--dry-run", "--insecure", "--timeout", "--verbose", "--version",
199
+ "-h", "--help",
200
+ }
201
+
202
+ # Flags that take a value (the value follows the flag)
203
+ GLOBAL_FLAGS_WITH_VALUE = {"--url", "--username", "--password", "--api-token", "--output", "--timeout"}
204
+
205
+
206
+ def _hint_global_flags_order(argv: list[str]) -> None:
207
+ """If user placed global flags after the resource, show a helpful hint."""
208
+ resource_pos = -1
209
+ resources = {"auth", "vm", "node", "pool", "container", "storage", "cluster", "completion", "task"}
210
+ for i, arg in enumerate(argv):
211
+ if arg in resources:
212
+ resource_pos = i
213
+ break
214
+ if resource_pos < 0:
215
+ return
216
+ # Check if any global flag (with or without value) appears after the resource
217
+ for i in range(resource_pos, len(argv)):
218
+ arg = argv[i]
219
+ if arg in GLOBAL_FLAGS:
220
+ # Build a corrected example
221
+ resource_part = argv[resource_pos:]
222
+ flags_before = []
223
+ for j in range(resource_pos):
224
+ if argv[j] in GLOBAL_FLAGS or (j > 0 and argv[j-1] in GLOBAL_FLAGS_WITH_VALUE):
225
+ flags_before.append(argv[j])
226
+ example = f"proxmox {arg} {' '.join(resource_part[:2])} ..."
227
+ log_error(
228
+ f"Global flag '{arg}' must come before the resource. "
229
+ f"Try: {example}"
230
+ )
231
+ return
232
+ # Check if this arg is the value of a previous global flag
233
+ if i > 0 and argv[i-1] in GLOBAL_FLAGS_WITH_VALUE and i-1 > resource_pos:
234
+ log_error(
235
+ f"Global flag '{argv[i-1]}' must come before the resource. "
236
+ f"Try: proxmox {argv[i-1]} {arg} {' '.join(argv[resource_pos:resource_pos+2])} ..."
237
+ )
238
+ return
239
+
240
+
198
241
  def main(argv: list[str] | None = None) -> None:
199
242
  """Main entry point."""
200
243
  parser = build_root_parser()
201
- args = parser.parse_args(argv)
244
+
245
+ effective_argv = argv if argv is not None else sys.argv[1:]
246
+
247
+ try:
248
+ args = parser.parse_args(effective_argv)
249
+ except SystemExit as e:
250
+ # If argparse rejected the args, check for global flags placed after resource
251
+ if effective_argv:
252
+ _hint_global_flags_order(effective_argv)
253
+ sys.exit(e.code if isinstance(e.code, int) else 1)
202
254
 
203
255
  # --help or no subcommand: just show help
204
256
  if args.resource is None:
@@ -2,7 +2,6 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import base64
6
5
  from enum import Enum
7
6
  from typing import Any
8
7
 
@@ -63,9 +62,7 @@ class AuthManager:
63
62
 
64
63
  def set_api_token(self, user: str, token_id: str, secret: str) -> None:
65
64
  """Use a Proxmox API token for authentication."""
66
- raw = f"{user}!{token_id}={secret}"
67
- encoded = base64.b64encode(raw.encode()).decode()
68
- self._auth_header = f"PVEAPIToken {encoded}"
65
+ self._auth_header = f"PVEAPIToken={user}!{token_id}={secret}"
69
66
  self._method = AuthMethod.API_TOKEN
70
67
  self._ticket = None
71
68
  self._csrf_token = None
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "proxcli"
3
- version = "0.7.0"
3
+ version = "0.7.2"
4
4
  description = "A CLI tool to interact with Proxmox VE nodes and clusters via the REST API"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -2,8 +2,6 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import base64
6
-
7
5
  import pytest
8
6
 
9
7
  from proxmox.client.auth import AuthMethod
@@ -60,9 +58,7 @@ class TestAuthManager:
60
58
  assert auth_manager.method == AuthMethod.API_TOKEN
61
59
 
62
60
  headers = auth_manager.get_headers()
63
- expected_raw = "root@pam!my-token=my-secret"
64
- expected_encoded = base64.b64encode(expected_raw.encode()).decode()
65
- assert headers["Authorization"] == f"PVEAPIToken {expected_encoded}"
61
+ assert headers["Authorization"] == "PVEAPIToken=root@pam!my-token=my-secret"
66
62
  assert "Cookie" not in headers
67
63
  assert "CSRFPreventionToken" not in headers
68
64
 
@@ -254,7 +254,7 @@ wheels = [
254
254
 
255
255
  [[package]]
256
256
  name = "proxcli"
257
- version = "0.7.0"
257
+ version = "0.7.2"
258
258
  source = { editable = "." }
259
259
  dependencies = [
260
260
  { name = "httpx" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes