ibee-cli 0.5.2__tar.gz → 0.6.0__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.
- ibee_cli-0.6.0/PKG-INFO +189 -0
- ibee_cli-0.6.0/README.md +163 -0
- {ibee_cli-0.5.2 → ibee_cli-0.6.0}/pyproject.toml +3 -3
- {ibee_cli-0.5.2 → ibee_cli-0.6.0}/src/ibee_cli/__init__.py +1 -1
- ibee_cli-0.6.0/src/ibee_cli/billing_selection.py +67 -0
- ibee_cli-0.6.0/src/ibee_cli/commands/__init__.py +22 -0
- ibee_cli-0.6.0/src/ibee_cli/commands/block_storage.py +142 -0
- ibee_cli-0.6.0/src/ibee_cli/commands/buckets.py +408 -0
- ibee_cli-0.6.0/src/ibee_cli/commands/cdn.py +251 -0
- ibee_cli-0.6.0/src/ibee_cli/commands/compute.py +110 -0
- ibee_cli-0.6.0/src/ibee_cli/commands/firewalls.py +226 -0
- ibee_cli-0.6.0/src/ibee_cli/commands/gpus.py +732 -0
- ibee_cli-0.6.0/src/ibee_cli/commands/load_balancers.py +206 -0
- ibee_cli-0.6.0/src/ibee_cli/commands/ops.py +23 -0
- ibee_cli-0.6.0/src/ibee_cli/commands/registries.py +558 -0
- ibee_cli-0.6.0/src/ibee_cli/commands/reserved_ips.py +176 -0
- ibee_cli-0.6.0/src/ibee_cli/commands/secrets.py +496 -0
- ibee_cli-0.6.0/src/ibee_cli/commands/vms.py +732 -0
- ibee_cli-0.6.0/src/ibee_cli/commands/vpcs.py +424 -0
- {ibee_cli-0.5.2 → ibee_cli-0.6.0}/src/ibee_cli/context.py +14 -24
- ibee_cli-0.6.0/src/ibee_cli/helpers.py +73 -0
- {ibee_cli-0.5.2 → ibee_cli-0.6.0}/src/ibee_cli/main.py +13 -42
- ibee_cli-0.6.0/src/ibee_cli/render.py +420 -0
- ibee_cli-0.6.0/src/ibee_cli.egg-info/PKG-INFO +189 -0
- {ibee_cli-0.5.2 → ibee_cli-0.6.0}/src/ibee_cli.egg-info/SOURCES.txt +5 -8
- {ibee_cli-0.5.2 → ibee_cli-0.6.0}/src/ibee_cli.egg-info/requires.txt +2 -1
- {ibee_cli-0.5.2 → ibee_cli-0.6.0}/tests/test_cli_core.py +35 -6
- ibee_cli-0.6.0/tests/test_command_behaviour.py +199 -0
- ibee_cli-0.6.0/tests/test_contract_commands.py +241 -0
- ibee_cli-0.5.2/PKG-INFO +0 -149
- ibee_cli-0.5.2/README.md +0 -124
- ibee_cli-0.5.2/src/ibee_cli/commands/__init__.py +0 -0
- ibee_cli-0.5.2/src/ibee_cli/commands/billing.py +0 -44
- ibee_cli-0.5.2/src/ibee_cli/commands/block_storage.py +0 -186
- ibee_cli-0.5.2/src/ibee_cli/commands/buckets.py +0 -222
- ibee_cli-0.5.2/src/ibee_cli/commands/cdn.py +0 -243
- ibee_cli-0.5.2/src/ibee_cli/commands/compute.py +0 -46
- ibee_cli-0.5.2/src/ibee_cli/commands/console.py +0 -63
- ibee_cli-0.5.2/src/ibee_cli/commands/firewalls.py +0 -220
- ibee_cli-0.5.2/src/ibee_cli/commands/gpus.py +0 -8
- ibee_cli-0.5.2/src/ibee_cli/commands/load_balancers.py +0 -238
- ibee_cli-0.5.2/src/ibee_cli/commands/networking.py +0 -408
- ibee_cli-0.5.2/src/ibee_cli/commands/ops.py +0 -53
- ibee_cli-0.5.2/src/ibee_cli/commands/reserved_ips.py +0 -120
- ibee_cli-0.5.2/src/ibee_cli/commands/secrets.py +0 -581
- ibee_cli-0.5.2/src/ibee_cli/commands/vm_lifecycle.py +0 -849
- ibee_cli-0.5.2/src/ibee_cli/commands/vms.py +0 -8
- ibee_cli-0.5.2/src/ibee_cli/helpers.py +0 -238
- ibee_cli-0.5.2/src/ibee_cli/render.py +0 -430
- ibee_cli-0.5.2/src/ibee_cli.egg-info/PKG-INFO +0 -149
- ibee_cli-0.5.2/tests/test_networking_commands.py +0 -268
- ibee_cli-0.5.2/tests/test_secret_store_commands.py +0 -190
- ibee_cli-0.5.2/tests/test_storage_commands.py +0 -252
- ibee_cli-0.5.2/tests/test_vm_commands.py +0 -201
- {ibee_cli-0.5.2 → ibee_cli-0.6.0}/LICENSE +0 -0
- {ibee_cli-0.5.2 → ibee_cli-0.6.0}/setup.cfg +0 -0
- {ibee_cli-0.5.2 → ibee_cli-0.6.0}/src/ibee_cli.egg-info/dependency_links.txt +0 -0
- {ibee_cli-0.5.2 → ibee_cli-0.6.0}/src/ibee_cli.egg-info/entry_points.txt +0 -0
- {ibee_cli-0.5.2 → ibee_cli-0.6.0}/src/ibee_cli.egg-info/top_level.txt +0 -0
ibee_cli-0.6.0/PKG-INFO
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ibee-cli
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: Official command-line interface for the IBEE Solutions cloud platform
|
|
5
|
+
Author-email: IBEE Solutions <support@ibee.ai>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://ibee.ai
|
|
8
|
+
Project-URL: Documentation, https://ibee.ai/docs/api-reference
|
|
9
|
+
Project-URL: Repository, https://github.com/devs-ibee/ibee-cli
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: ibee<0.7,>=0.6.0
|
|
17
|
+
Requires-Dist: httpx>=0.27
|
|
18
|
+
Requires-Dist: typer>=0.12
|
|
19
|
+
Requires-Dist: click>=8.1
|
|
20
|
+
Requires-Dist: rich>=13.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
23
|
+
Requires-Dist: build; extra == "dev"
|
|
24
|
+
Requires-Dist: pyyaml>=6.0; extra == "dev"
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# IBEE Solutions CLI
|
|
28
|
+
|
|
29
|
+
Official command-line interface for the IBEE Solutions cloud platform, built on the
|
|
30
|
+
[`ibee` Python SDK](https://github.com/devs-ibee/ibee-python). It has one command per
|
|
31
|
+
operation of the IBEE public API (contract 0.7.1, 225 operations): each command makes
|
|
32
|
+
that operation's one SDK call and prints the server's answer. The server decides
|
|
33
|
+
prices, eligibility, limits and states; the CLI checks nothing before sending.
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install ibee-cli
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Requires Python 3.10+.
|
|
42
|
+
|
|
43
|
+
## Authentication
|
|
44
|
+
|
|
45
|
+
Create an API token in the portal under **Settings > API Tokens**, then:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
export IBEE_TOKEN="ibee_prod_key_xxxxxxxxxxxx"
|
|
49
|
+
export IBEE_WORKSPACE_ID="710995"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Both can also be passed per command with `--token` and `--workspace`. The workspace is
|
|
53
|
+
sent as every operation's `workspace_id`.
|
|
54
|
+
|
|
55
|
+
## Commands
|
|
56
|
+
|
|
57
|
+
`ibee --help` lists the groups (`vms`, `gpus`, `ops`, `compute`, `block-storage`,
|
|
58
|
+
`buckets`, `cdn`, `secrets`, `vpcs`, `reserved-ips`, `firewalls`, `load-balancers`,
|
|
59
|
+
`registries`); [COMMANDS.md](COMMANDS.md) lists every command with its API operation,
|
|
60
|
+
and `ibee COMMAND --help` shows each option's description from the contract.
|
|
61
|
+
|
|
62
|
+
Every command follows the contract, field for field:
|
|
63
|
+
|
|
64
|
+
- path parameters are arguments, in path order (`ibee vms get VM_ID`);
|
|
65
|
+
- every query parameter, header and request-body field is an option of the same name
|
|
66
|
+
(`ssh_key_ids` is `--ssh-key-ids`); the contract's required fields are required
|
|
67
|
+
options;
|
|
68
|
+
- booleans are `--name/--no-name`; arrays of strings or numbers repeat the option
|
|
69
|
+
(`--tags a --tags b`); objects and arrays of objects take JSON, and a JSON value of
|
|
70
|
+
`@FILE` reads the file, `@-` standard input (`--rules @rules.json`);
|
|
71
|
+
- `X-Idempotency-Key` (and Container Registry's `Idempotency-Key`) is
|
|
72
|
+
`--idempotency-key`; without it the SDK sends a new random key.
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
ibee compute sites
|
|
76
|
+
ibee compute plans --vm-type cloud --site-id SITE_ID
|
|
77
|
+
ibee compute images --vm-type cloud --site-id SITE_ID
|
|
78
|
+
|
|
79
|
+
ibee vms create --name web-1 --site-id SITE_ID --plan-id PLAN_ID --template-id IMAGE_ID \
|
|
80
|
+
--os-type linux --os-distro ubuntu --cpu 2 --ram-mb 4096 --disk-gb 50 \
|
|
81
|
+
--billing-interval HOURLY --ssh-keys "$(cat ~/.ssh/id_ed25519.pub)"
|
|
82
|
+
ibee ops get OPERATION_ID
|
|
83
|
+
ibee vms list --limit 20
|
|
84
|
+
ibee vms resize VM_ID --cpu 4 --ram-mb 8192
|
|
85
|
+
ibee vms delete VM_ID --public-ip-action release --yes
|
|
86
|
+
|
|
87
|
+
ibee buckets create --name assets --region in-south-2
|
|
88
|
+
ibee buckets cors set assets --rules @cors.json
|
|
89
|
+
ibee buckets credentials create --name ci --permission-type object_rw
|
|
90
|
+
ibee secrets create STORE_ID --secret-name db --value '{"password": "..."}'
|
|
91
|
+
ibee registries tokens create REGISTRY_ID --token-name ci-push --permission PULL_PUSH
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### VM creates: `--billing-interval`
|
|
95
|
+
|
|
96
|
+
`vms create` and `gpus create` need the contract's `billing_catalog` (a
|
|
97
|
+
`ComputeBillingSelection`). Pass it as JSON with `--billing-catalog`, or pass
|
|
98
|
+
`--billing-interval HOURLY|MONTHLY`: the CLI then reads the `--plan-id` plan from
|
|
99
|
+
`GET /compute/plans` (with the create's `vm_type` and `site_id`), copies its
|
|
100
|
+
`billing_catalog` and merges in the whole `billing_options` entry for that interval,
|
|
101
|
+
exactly as the portal does. Nothing else is filled in: CPU, RAM, disk, OS and the
|
|
102
|
+
other fields are sent as you give them. `MONTHLY` is a one-month commitment (the API
|
|
103
|
+
answers `409 VM_COMMITTED` to a delete or resize before it ends).
|
|
104
|
+
|
|
105
|
+
## Global options
|
|
106
|
+
|
|
107
|
+
| Option | Environment variable | Meaning |
|
|
108
|
+
| --- | --- | --- |
|
|
109
|
+
| `--token` | `IBEE_TOKEN` (or `IBEE_API_TOKEN`) | API token |
|
|
110
|
+
| `--workspace`, `-w` | `IBEE_WORKSPACE_ID` | Workspace ID (`workspace_id`) |
|
|
111
|
+
| `--dev` | `IBEE_ENV=dev` | Use the development environment |
|
|
112
|
+
| `--base-url` | `IBEE_BASE_URL`, `IBEE_ENDPOINT` | Custom API endpoint |
|
|
113
|
+
| `-o`, `--output` | `IBEE_OUTPUT` | `json` (default), `yaml`, `table` or `id` |
|
|
114
|
+
| `--json` | | Same as `-o json` |
|
|
115
|
+
| `--yes`, `-y` | `IBEE_ASSUME_YES=1` | Answer yes to every confirmation |
|
|
116
|
+
|
|
117
|
+
The endpoint is chosen in this order: `--base-url`, `IBEE_BASE_URL`, `IBEE_ENDPOINT`,
|
|
118
|
+
`--dev`, `IBEE_ENV`; the default is production, `https://api.ibee.ai/v1`.
|
|
119
|
+
|
|
120
|
+
## Output
|
|
121
|
+
|
|
122
|
+
The server's answer is printed as JSON by default. `-o yaml` prints it as YAML,
|
|
123
|
+
`-o table` as a table (one row per item of a list, or one row per field of an
|
|
124
|
+
object) and `-o id` one identifier per line (for a list, the value the API takes for
|
|
125
|
+
each item, such as a bucket's name). An empty answer (HTTP 204) prints nothing.
|
|
126
|
+
`registries sboms download` writes the document to standard output.
|
|
127
|
+
|
|
128
|
+
Destructive commands (every delete, revoke, archive, purge, restore and volume
|
|
129
|
+
detach) ask for confirmation; `--yes` (or the global `--yes`) skips it.
|
|
130
|
+
|
|
131
|
+
## Errors
|
|
132
|
+
|
|
133
|
+
Every error prints the HTTP status and the server's fields as sent:
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
Error: HTTP 409
|
|
137
|
+
code: VM_COMMITTED
|
|
138
|
+
message: ...
|
|
139
|
+
request_id: 6f1c2e...
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
With `-o json` the same fields, plus the raw `body`, are printed on stderr as
|
|
143
|
+
`{"error": {...}}`. A success answer the SDK cannot read (it does not match the
|
|
144
|
+
contract) is printed the same way, as received, with exit code 1.
|
|
145
|
+
|
|
146
|
+
## Exit codes
|
|
147
|
+
|
|
148
|
+
| Code | Meaning |
|
|
149
|
+
| --- | --- |
|
|
150
|
+
| 0 | Success |
|
|
151
|
+
| 1 | Declined confirmation, an answer that does not match the contract, or another error |
|
|
152
|
+
| 2 | Usage or configuration error (missing option, token or workspace, bad JSON, unsafe endpoint); nothing was sent |
|
|
153
|
+
| 4 | Network error (no HTTP answer) |
|
|
154
|
+
| 10, 11, 12, 13, 14 | HTTP 400, 401, 402, 403, 404 |
|
|
155
|
+
| 15, 16, 17, 18 | HTTP 409, 422, 423, 429 |
|
|
156
|
+
| 19 | HTTP 5xx |
|
|
157
|
+
|
|
158
|
+
## Retries and idempotency keys
|
|
159
|
+
|
|
160
|
+
The SDK retries reads on 429, 502, 503 and 504, and writes that carry an idempotency
|
|
161
|
+
key on 429 and 503, never on a billing or admission answer; VM creates are never
|
|
162
|
+
retried. After a retryable failure the CLI prints `Retry safely with:
|
|
163
|
+
--idempotency-key KEY` so the command can be repeated without doing the write twice.
|
|
164
|
+
|
|
165
|
+
## Development
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
pip install "ibee @ git+https://github.com/devs-ibee/ibee-python@main" # or the SDK branch you need
|
|
169
|
+
pip install -e ".[dev]"
|
|
170
|
+
python scripts/generate_commands.py --check # the commands match contract/ibee-cloud.yaml
|
|
171
|
+
python scripts/check_sdk_calls.py # every SDK method has a command, and only those are called
|
|
172
|
+
pytest -q
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The command modules in `src/ibee_cli/commands/` and `COMMANDS.md` are generated from
|
|
176
|
+
`contract/ibee-cloud.yaml` (a copy of the public API contract) by
|
|
177
|
+
`scripts/generate_commands.py`; after updating the contract, run the script and commit
|
|
178
|
+
what it writes. The hand-written parts are the global options (`context.py`), output
|
|
179
|
+
and errors (`render.py`), the shared request helpers (`helpers.py`) and the VM
|
|
180
|
+
`billing_catalog` convenience (`billing_selection.py`).
|
|
181
|
+
|
|
182
|
+
CI runs the tests on Python 3.10-3.12 with the ibee-python branch of the same name (or
|
|
183
|
+
ibee from PyPI), and the "SDK drift" check against ibee from PyPI (once a release in
|
|
184
|
+
the CLI's range exists) and ibee-python `main` (or its branch of the same name).
|
|
185
|
+
|
|
186
|
+
## Related
|
|
187
|
+
|
|
188
|
+
- [Python SDK](https://github.com/devs-ibee/ibee-python): `pip install ibee`
|
|
189
|
+
- [API documentation](https://ibee.ai/docs/api-reference)
|
ibee_cli-0.6.0/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# IBEE Solutions CLI
|
|
2
|
+
|
|
3
|
+
Official command-line interface for the IBEE Solutions cloud platform, built on the
|
|
4
|
+
[`ibee` Python SDK](https://github.com/devs-ibee/ibee-python). It has one command per
|
|
5
|
+
operation of the IBEE public API (contract 0.7.1, 225 operations): each command makes
|
|
6
|
+
that operation's one SDK call and prints the server's answer. The server decides
|
|
7
|
+
prices, eligibility, limits and states; the CLI checks nothing before sending.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install ibee-cli
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requires Python 3.10+.
|
|
16
|
+
|
|
17
|
+
## Authentication
|
|
18
|
+
|
|
19
|
+
Create an API token in the portal under **Settings > API Tokens**, then:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
export IBEE_TOKEN="ibee_prod_key_xxxxxxxxxxxx"
|
|
23
|
+
export IBEE_WORKSPACE_ID="710995"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Both can also be passed per command with `--token` and `--workspace`. The workspace is
|
|
27
|
+
sent as every operation's `workspace_id`.
|
|
28
|
+
|
|
29
|
+
## Commands
|
|
30
|
+
|
|
31
|
+
`ibee --help` lists the groups (`vms`, `gpus`, `ops`, `compute`, `block-storage`,
|
|
32
|
+
`buckets`, `cdn`, `secrets`, `vpcs`, `reserved-ips`, `firewalls`, `load-balancers`,
|
|
33
|
+
`registries`); [COMMANDS.md](COMMANDS.md) lists every command with its API operation,
|
|
34
|
+
and `ibee COMMAND --help` shows each option's description from the contract.
|
|
35
|
+
|
|
36
|
+
Every command follows the contract, field for field:
|
|
37
|
+
|
|
38
|
+
- path parameters are arguments, in path order (`ibee vms get VM_ID`);
|
|
39
|
+
- every query parameter, header and request-body field is an option of the same name
|
|
40
|
+
(`ssh_key_ids` is `--ssh-key-ids`); the contract's required fields are required
|
|
41
|
+
options;
|
|
42
|
+
- booleans are `--name/--no-name`; arrays of strings or numbers repeat the option
|
|
43
|
+
(`--tags a --tags b`); objects and arrays of objects take JSON, and a JSON value of
|
|
44
|
+
`@FILE` reads the file, `@-` standard input (`--rules @rules.json`);
|
|
45
|
+
- `X-Idempotency-Key` (and Container Registry's `Idempotency-Key`) is
|
|
46
|
+
`--idempotency-key`; without it the SDK sends a new random key.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
ibee compute sites
|
|
50
|
+
ibee compute plans --vm-type cloud --site-id SITE_ID
|
|
51
|
+
ibee compute images --vm-type cloud --site-id SITE_ID
|
|
52
|
+
|
|
53
|
+
ibee vms create --name web-1 --site-id SITE_ID --plan-id PLAN_ID --template-id IMAGE_ID \
|
|
54
|
+
--os-type linux --os-distro ubuntu --cpu 2 --ram-mb 4096 --disk-gb 50 \
|
|
55
|
+
--billing-interval HOURLY --ssh-keys "$(cat ~/.ssh/id_ed25519.pub)"
|
|
56
|
+
ibee ops get OPERATION_ID
|
|
57
|
+
ibee vms list --limit 20
|
|
58
|
+
ibee vms resize VM_ID --cpu 4 --ram-mb 8192
|
|
59
|
+
ibee vms delete VM_ID --public-ip-action release --yes
|
|
60
|
+
|
|
61
|
+
ibee buckets create --name assets --region in-south-2
|
|
62
|
+
ibee buckets cors set assets --rules @cors.json
|
|
63
|
+
ibee buckets credentials create --name ci --permission-type object_rw
|
|
64
|
+
ibee secrets create STORE_ID --secret-name db --value '{"password": "..."}'
|
|
65
|
+
ibee registries tokens create REGISTRY_ID --token-name ci-push --permission PULL_PUSH
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### VM creates: `--billing-interval`
|
|
69
|
+
|
|
70
|
+
`vms create` and `gpus create` need the contract's `billing_catalog` (a
|
|
71
|
+
`ComputeBillingSelection`). Pass it as JSON with `--billing-catalog`, or pass
|
|
72
|
+
`--billing-interval HOURLY|MONTHLY`: the CLI then reads the `--plan-id` plan from
|
|
73
|
+
`GET /compute/plans` (with the create's `vm_type` and `site_id`), copies its
|
|
74
|
+
`billing_catalog` and merges in the whole `billing_options` entry for that interval,
|
|
75
|
+
exactly as the portal does. Nothing else is filled in: CPU, RAM, disk, OS and the
|
|
76
|
+
other fields are sent as you give them. `MONTHLY` is a one-month commitment (the API
|
|
77
|
+
answers `409 VM_COMMITTED` to a delete or resize before it ends).
|
|
78
|
+
|
|
79
|
+
## Global options
|
|
80
|
+
|
|
81
|
+
| Option | Environment variable | Meaning |
|
|
82
|
+
| --- | --- | --- |
|
|
83
|
+
| `--token` | `IBEE_TOKEN` (or `IBEE_API_TOKEN`) | API token |
|
|
84
|
+
| `--workspace`, `-w` | `IBEE_WORKSPACE_ID` | Workspace ID (`workspace_id`) |
|
|
85
|
+
| `--dev` | `IBEE_ENV=dev` | Use the development environment |
|
|
86
|
+
| `--base-url` | `IBEE_BASE_URL`, `IBEE_ENDPOINT` | Custom API endpoint |
|
|
87
|
+
| `-o`, `--output` | `IBEE_OUTPUT` | `json` (default), `yaml`, `table` or `id` |
|
|
88
|
+
| `--json` | | Same as `-o json` |
|
|
89
|
+
| `--yes`, `-y` | `IBEE_ASSUME_YES=1` | Answer yes to every confirmation |
|
|
90
|
+
|
|
91
|
+
The endpoint is chosen in this order: `--base-url`, `IBEE_BASE_URL`, `IBEE_ENDPOINT`,
|
|
92
|
+
`--dev`, `IBEE_ENV`; the default is production, `https://api.ibee.ai/v1`.
|
|
93
|
+
|
|
94
|
+
## Output
|
|
95
|
+
|
|
96
|
+
The server's answer is printed as JSON by default. `-o yaml` prints it as YAML,
|
|
97
|
+
`-o table` as a table (one row per item of a list, or one row per field of an
|
|
98
|
+
object) and `-o id` one identifier per line (for a list, the value the API takes for
|
|
99
|
+
each item, such as a bucket's name). An empty answer (HTTP 204) prints nothing.
|
|
100
|
+
`registries sboms download` writes the document to standard output.
|
|
101
|
+
|
|
102
|
+
Destructive commands (every delete, revoke, archive, purge, restore and volume
|
|
103
|
+
detach) ask for confirmation; `--yes` (or the global `--yes`) skips it.
|
|
104
|
+
|
|
105
|
+
## Errors
|
|
106
|
+
|
|
107
|
+
Every error prints the HTTP status and the server's fields as sent:
|
|
108
|
+
|
|
109
|
+
```text
|
|
110
|
+
Error: HTTP 409
|
|
111
|
+
code: VM_COMMITTED
|
|
112
|
+
message: ...
|
|
113
|
+
request_id: 6f1c2e...
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
With `-o json` the same fields, plus the raw `body`, are printed on stderr as
|
|
117
|
+
`{"error": {...}}`. A success answer the SDK cannot read (it does not match the
|
|
118
|
+
contract) is printed the same way, as received, with exit code 1.
|
|
119
|
+
|
|
120
|
+
## Exit codes
|
|
121
|
+
|
|
122
|
+
| Code | Meaning |
|
|
123
|
+
| --- | --- |
|
|
124
|
+
| 0 | Success |
|
|
125
|
+
| 1 | Declined confirmation, an answer that does not match the contract, or another error |
|
|
126
|
+
| 2 | Usage or configuration error (missing option, token or workspace, bad JSON, unsafe endpoint); nothing was sent |
|
|
127
|
+
| 4 | Network error (no HTTP answer) |
|
|
128
|
+
| 10, 11, 12, 13, 14 | HTTP 400, 401, 402, 403, 404 |
|
|
129
|
+
| 15, 16, 17, 18 | HTTP 409, 422, 423, 429 |
|
|
130
|
+
| 19 | HTTP 5xx |
|
|
131
|
+
|
|
132
|
+
## Retries and idempotency keys
|
|
133
|
+
|
|
134
|
+
The SDK retries reads on 429, 502, 503 and 504, and writes that carry an idempotency
|
|
135
|
+
key on 429 and 503, never on a billing or admission answer; VM creates are never
|
|
136
|
+
retried. After a retryable failure the CLI prints `Retry safely with:
|
|
137
|
+
--idempotency-key KEY` so the command can be repeated without doing the write twice.
|
|
138
|
+
|
|
139
|
+
## Development
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
pip install "ibee @ git+https://github.com/devs-ibee/ibee-python@main" # or the SDK branch you need
|
|
143
|
+
pip install -e ".[dev]"
|
|
144
|
+
python scripts/generate_commands.py --check # the commands match contract/ibee-cloud.yaml
|
|
145
|
+
python scripts/check_sdk_calls.py # every SDK method has a command, and only those are called
|
|
146
|
+
pytest -q
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The command modules in `src/ibee_cli/commands/` and `COMMANDS.md` are generated from
|
|
150
|
+
`contract/ibee-cloud.yaml` (a copy of the public API contract) by
|
|
151
|
+
`scripts/generate_commands.py`; after updating the contract, run the script and commit
|
|
152
|
+
what it writes. The hand-written parts are the global options (`context.py`), output
|
|
153
|
+
and errors (`render.py`), the shared request helpers (`helpers.py`) and the VM
|
|
154
|
+
`billing_catalog` convenience (`billing_selection.py`).
|
|
155
|
+
|
|
156
|
+
CI runs the tests on Python 3.10-3.12 with the ibee-python branch of the same name (or
|
|
157
|
+
ibee from PyPI), and the "SDK drift" check against ibee from PyPI (once a release in
|
|
158
|
+
the CLI's range exists) and ibee-python `main` (or its branch of the same name).
|
|
159
|
+
|
|
160
|
+
## Related
|
|
161
|
+
|
|
162
|
+
- [Python SDK](https://github.com/devs-ibee/ibee-python): `pip install ibee`
|
|
163
|
+
- [API documentation](https://ibee.ai/docs/api-reference)
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ibee-cli"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.6.0"
|
|
8
8
|
description = "Official command-line interface for the IBEE Solutions cloud platform"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -18,7 +18,7 @@ classifiers = [
|
|
|
18
18
|
"Environment :: Console",
|
|
19
19
|
]
|
|
20
20
|
dependencies = [
|
|
21
|
-
"ibee>=0.
|
|
21
|
+
"ibee>=0.6.0,<0.7",
|
|
22
22
|
"httpx>=0.27",
|
|
23
23
|
"typer>=0.12",
|
|
24
24
|
"click>=8.1",
|
|
@@ -26,7 +26,7 @@ dependencies = [
|
|
|
26
26
|
]
|
|
27
27
|
|
|
28
28
|
[project.optional-dependencies]
|
|
29
|
-
dev = ["pytest>=7.0", "build"]
|
|
29
|
+
dev = ["pytest>=7.0", "build", "pyyaml>=6.0"]
|
|
30
30
|
|
|
31
31
|
[project.scripts]
|
|
32
32
|
ibee = "ibee_cli.main:app"
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""The CLI's one convenience: a VM create's ``billing_catalog`` from ``GET /compute/plans``.
|
|
2
|
+
|
|
3
|
+
The contract's ``ComputeBillingSelection`` (``billing_catalog`` of ``POST
|
|
4
|
+
/compute/cloud-vms`` and ``POST /compute/gpu-vms``) is the chosen plan's
|
|
5
|
+
``billing_catalog`` with one entry of its ``billing_options`` merged in. With
|
|
6
|
+
``--billing-interval HOURLY|MONTHLY``, ``vms create`` and ``gpus create`` do that with
|
|
7
|
+
the server's own data, as the portal does: read the ``--plan-id`` plan from ``GET
|
|
8
|
+
/compute/plans`` (``vm_type`` and ``site_id`` of the create), copy its
|
|
9
|
+
``billing_catalog`` and merge in the whole ``billing_options`` entry whose
|
|
10
|
+
``billing_interval`` is the one asked for (``billing_interval``, ``committed``,
|
|
11
|
+
``commitment_period``, ``commitment_months``, ``committed_hours``, ``price_unit``,
|
|
12
|
+
``unit_price_minor``...), keeping the catalog's ``price_currency``. Nothing is
|
|
13
|
+
invented or checked here: the server validates the selection and decides the price.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from typing import Any, Optional
|
|
19
|
+
|
|
20
|
+
from .context import fail_usage
|
|
21
|
+
from .helpers import json_arg
|
|
22
|
+
from .render import items, to_data
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def vm_billing_catalog(
|
|
26
|
+
client: Any,
|
|
27
|
+
workspace_id: str,
|
|
28
|
+
vm_type: str,
|
|
29
|
+
plan_id: str,
|
|
30
|
+
site_id: Optional[str],
|
|
31
|
+
billing_catalog: Optional[str],
|
|
32
|
+
billing_interval: Optional[str],
|
|
33
|
+
) -> Any:
|
|
34
|
+
"""The ``billing_catalog`` to send: ``--billing-catalog`` as given, or built for ``--billing-interval``."""
|
|
35
|
+
if billing_catalog is not None and billing_interval is not None:
|
|
36
|
+
fail_usage("Use --billing-catalog or --billing-interval, not both.")
|
|
37
|
+
if billing_catalog is not None:
|
|
38
|
+
return json_arg(billing_catalog, "--billing-catalog")
|
|
39
|
+
if billing_interval is None:
|
|
40
|
+
fail_usage(
|
|
41
|
+
"billing_catalog is required: pass --billing-interval HOURLY|MONTHLY (built from the plan in "
|
|
42
|
+
"GET /compute/plans) or --billing-catalog JSON."
|
|
43
|
+
)
|
|
44
|
+
interval = str(billing_interval).strip().upper()
|
|
45
|
+
answer = client.compute_catalog.list_compute_plans(
|
|
46
|
+
workspace_id=workspace_id, vm_type=vm_type, **({"site_id": site_id} if site_id else {})
|
|
47
|
+
)
|
|
48
|
+
plans = items(to_data(answer), "plans") or []
|
|
49
|
+
plan = next((p for p in plans if isinstance(p, dict) and str(p.get("plan_id")) == str(plan_id)), None)
|
|
50
|
+
where = f"GET /compute/plans?vm_type={vm_type}" + (f"&site_id={site_id}" if site_id else "")
|
|
51
|
+
if plan is None:
|
|
52
|
+
fail_usage(f"Plan {plan_id} is not in {where}, so its billing_catalog cannot be read.")
|
|
53
|
+
catalog = plan.get("billing_catalog")
|
|
54
|
+
if not isinstance(catalog, dict):
|
|
55
|
+
fail_usage(f"Plan {plan_id} in {where} has no billing_catalog.")
|
|
56
|
+
options = [o for o in catalog.get("billing_options") or [] if isinstance(o, dict)]
|
|
57
|
+
option = next((o for o in options if str(o.get("billing_interval")).upper() == interval), None)
|
|
58
|
+
if option is None:
|
|
59
|
+
offered = ", ".join(str(o.get("billing_interval")) for o in options) or "none"
|
|
60
|
+
fail_usage(f"Plan {plan_id} has no {interval} entry in billing_catalog.billing_options (offered: {offered}).")
|
|
61
|
+
selection = {**catalog, **option}
|
|
62
|
+
if "price_currency" in catalog:
|
|
63
|
+
selection["price_currency"] = catalog["price_currency"]
|
|
64
|
+
return selection
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
__all__ = ["vm_billing_catalog"]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Generated by scripts/generate_commands.py from contract/ibee-cloud.yaml (IBEE Solutions API 0.7.1).
|
|
2
|
+
# Do not edit by hand: change the contract or the generator and run the script again.
|
|
3
|
+
"""The command groups, in `ibee --help` order."""
|
|
4
|
+
|
|
5
|
+
from . import block_storage, buckets, cdn, compute, firewalls, gpus, load_balancers, ops, registries, reserved_ips, secrets, vms, vpcs
|
|
6
|
+
|
|
7
|
+
#: (CLI name, Typer app) of every command group.
|
|
8
|
+
GROUPS = [
|
|
9
|
+
('vms', vms.app),
|
|
10
|
+
('gpus', gpus.app),
|
|
11
|
+
('ops', ops.app),
|
|
12
|
+
('compute', compute.app),
|
|
13
|
+
('block-storage', block_storage.app),
|
|
14
|
+
('buckets', buckets.app),
|
|
15
|
+
('cdn', cdn.app),
|
|
16
|
+
('secrets', secrets.app),
|
|
17
|
+
('vpcs', vpcs.app),
|
|
18
|
+
('reserved-ips', reserved_ips.app),
|
|
19
|
+
('firewalls', firewalls.app),
|
|
20
|
+
('load-balancers', load_balancers.app),
|
|
21
|
+
('registries', registries.app),
|
|
22
|
+
]
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Generated by scripts/generate_commands.py from contract/ibee-cloud.yaml (IBEE Solutions API 0.7.1).
|
|
2
|
+
# Do not edit by hand: change the contract or the generator and run the script again.
|
|
3
|
+
"""``ibee block-storage``: Block Storage volumes and plans (one command per contract operation)."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from typing import Optional
|
|
8
|
+
|
|
9
|
+
import typer
|
|
10
|
+
|
|
11
|
+
from ..helpers import compact, confirm, sdk, workspace
|
|
12
|
+
from ..render import emit, handle_api_errors
|
|
13
|
+
|
|
14
|
+
app = typer.Typer(help='Block Storage volumes and plans', no_args_is_help=True)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@app.command('plans', help="List block storage plans.\n\nReturns the block storage plans with their sizes, performance and prices, as the portal's Create Volume page shows them. Pick a `sku_code` for createBlockVolume. Requires scope: block-storage.read.\n\nAPI: GET /block-storage/plans (listBlockStoragePlans).", short_help='List block storage plans')
|
|
18
|
+
@handle_api_errors
|
|
19
|
+
def list_block_storage_plans(
|
|
20
|
+
ctx: typer.Context,
|
|
21
|
+
site_id: Optional[str] = typer.Option(None, '--site-id', show_default=False, help='Return only plans offered at this site.'),
|
|
22
|
+
currency: Optional[str] = typer.Option(None, '--currency', show_default=False, help='Price currency. Default `INR`.'),
|
|
23
|
+
billing_interval: Optional[str] = typer.Option(None, '--billing-interval', show_default=False, help='Billing interval of the listed prices. Default `MONTHLY`. One of: HOURLY, MONTHLY.'),
|
|
24
|
+
) -> None:
|
|
25
|
+
client = sdk(ctx)
|
|
26
|
+
result = client.block_storage.list_block_storage_plans(
|
|
27
|
+
**compact(
|
|
28
|
+
workspace_id=workspace(ctx),
|
|
29
|
+
site_id=site_id,
|
|
30
|
+
currency=currency,
|
|
31
|
+
billing_interval=billing_interval,
|
|
32
|
+
),
|
|
33
|
+
)
|
|
34
|
+
emit(result, collection='items')
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@app.command('list', help='List block-storage volumes.\n\nLists the block storage volumes in a workspace, with their size, status, and attached VM. Requires scope: block-storage.read.\n\nAPI: GET /block-storage/volumes (listBlockVolumes).', short_help='List block-storage volumes')
|
|
38
|
+
@handle_api_errors
|
|
39
|
+
def list_block_volumes(
|
|
40
|
+
ctx: typer.Context,
|
|
41
|
+
) -> None:
|
|
42
|
+
client = sdk(ctx)
|
|
43
|
+
result = client.block_storage.list_block_volumes(**compact(workspace_id=workspace(ctx)))
|
|
44
|
+
emit(result, id_field='id')
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@app.command('create', help='Create block-storage volume.\n\nThe public edge resolves authoritative pricing from the server-owned product catalog and validates billing before forwarding this request to the existing portal volume flow. Client-supplied price or billing catalog objects are not accepted. Asynchronous: the response carries the volume operation; poll `GET /block-storage/volumes/{volume_id}/operations` until its `status` is `succeeded` or `failed`.\n\nAPI: POST /block-storage/volumes (createBlockVolume).', short_help='Create block-storage volume')
|
|
48
|
+
@handle_api_errors
|
|
49
|
+
def create_block_volume(
|
|
50
|
+
ctx: typer.Context,
|
|
51
|
+
name: str = typer.Option(..., '--name', show_default=False, help='Display name of the volume (1-255 characters).'),
|
|
52
|
+
size_gb: int = typer.Option(..., '--size-gb', show_default=False, help='Size in GB (1-10000).'),
|
|
53
|
+
site_id: str = typer.Option(..., '--site-id', show_default=False, help='Site to create the volume at.'),
|
|
54
|
+
site_name: Optional[str] = typer.Option(None, '--site-name', show_default=False, help='Display name of that site, as shown in the portal.'),
|
|
55
|
+
sku_code: Optional[str] = typer.Option(None, '--sku-code', show_default=False, help='Optional public selector returned by the server-owned Block Storage catalog. The edge resolves all price and catalog metadata; callers cannot submit pricing.'),
|
|
56
|
+
volume_class: Optional[str] = typer.Option(None, '--volume-class', show_default=False, help='Performance class of the volume. - `capacity`: lowest cost per GB. - `balanced`: general purpose. - `performance`: highest throughput and IOPS. Default `balanced`.'),
|
|
57
|
+
replica_count: Optional[int] = typer.Option(None, '--replica-count', show_default=False, help='Number of synchronous replicas kept for the volume (1-5). Default 2.'),
|
|
58
|
+
backup_enabled: Optional[bool] = typer.Option(None, '--backup-enabled/--no-backup-enabled', show_default=False, help='Whether volume backups are enabled. Default true.'),
|
|
59
|
+
idempotency_key: Optional[str] = typer.Option(None, '--idempotency-key', show_default=False, help='Caller-chosen key that makes a retried request return the original operation instead of starting a new one.'),
|
|
60
|
+
) -> None:
|
|
61
|
+
client = sdk(ctx)
|
|
62
|
+
result = client.block_storage.create_block_volume(
|
|
63
|
+
**compact(
|
|
64
|
+
workspace_id=workspace(ctx),
|
|
65
|
+
name=name,
|
|
66
|
+
size_gb=size_gb,
|
|
67
|
+
site_id=site_id,
|
|
68
|
+
site_name=site_name,
|
|
69
|
+
sku_code=sku_code,
|
|
70
|
+
volume_class=volume_class,
|
|
71
|
+
replica_count=replica_count,
|
|
72
|
+
backup_enabled=backup_enabled,
|
|
73
|
+
idempotency_key=idempotency_key,
|
|
74
|
+
),
|
|
75
|
+
)
|
|
76
|
+
emit(result)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@app.command('get', help='Get block-storage volume.\n\nReturns a block storage volume, including its size, status, and the VM it is attached to. Requires scope: block-storage.read.\n\nAPI: GET /block-storage/volumes/{volume_id} (getBlockVolume).', short_help='Get block-storage volume')
|
|
80
|
+
@handle_api_errors
|
|
81
|
+
def get_block_volume(
|
|
82
|
+
ctx: typer.Context,
|
|
83
|
+
volume_id: str = typer.Argument(..., metavar='VOLUME_ID', show_default=False, help='Workspace-owned block-volume ID.'),
|
|
84
|
+
) -> None:
|
|
85
|
+
client = sdk(ctx)
|
|
86
|
+
result = client.block_storage.get_block_volume(volume_id, **compact(workspace_id=workspace(ctx)))
|
|
87
|
+
emit(result)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@app.command('delete', help='Delete block-storage volume.\n\nPermanently deletes a block storage volume and its data. Asynchronous: the response carries the volume operation; poll `GET /block-storage/volumes/{volume_id}/operations` until its `status` is `succeeded` or `failed`. Requires scope: block-storage.write.\n\nAPI: DELETE /block-storage/volumes/{volume_id} (deleteBlockVolume).', short_help='Delete block-storage volume')
|
|
91
|
+
@handle_api_errors
|
|
92
|
+
def delete_block_volume(
|
|
93
|
+
ctx: typer.Context,
|
|
94
|
+
volume_id: str = typer.Argument(..., metavar='VOLUME_ID', show_default=False, help='Workspace-owned block-volume ID.'),
|
|
95
|
+
force: Optional[bool] = typer.Option(None, '--force/--no-force', show_default=False, help='Delete the volume even if it is still attached. Default false.'),
|
|
96
|
+
yes: bool = typer.Option(False, '--yes', '-y', help='Do not ask for confirmation.'),
|
|
97
|
+
) -> None:
|
|
98
|
+
confirm(ctx, yes, f'Delete block-storage volume {volume_id}?')
|
|
99
|
+
client = sdk(ctx)
|
|
100
|
+
result = client.block_storage.delete_block_volume(
|
|
101
|
+
volume_id,
|
|
102
|
+
**compact(
|
|
103
|
+
workspace_id=workspace(ctx),
|
|
104
|
+
force=force,
|
|
105
|
+
),
|
|
106
|
+
)
|
|
107
|
+
emit(result)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
@app.command('operations', help='List block-volume operations.\n\nLists the operations run on a block storage volume and their status. Requires scope: block-storage.read.\n\nAPI: GET /block-storage/volumes/{volume_id}/operations (listBlockVolumeOperations).', short_help='List block-volume operations')
|
|
111
|
+
@handle_api_errors
|
|
112
|
+
def list_block_volume_operations(
|
|
113
|
+
ctx: typer.Context,
|
|
114
|
+
volume_id: str = typer.Argument(..., metavar='VOLUME_ID', show_default=False, help='Workspace-owned block-volume ID.'),
|
|
115
|
+
) -> None:
|
|
116
|
+
client = sdk(ctx)
|
|
117
|
+
result = client.block_storage.list_block_volume_operations(volume_id, **compact(workspace_id=workspace(ctx)))
|
|
118
|
+
emit(result)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
@app.command('resize', help='Resize block-storage volume.\n\nBlock volumes can only be increased in size. Asynchronous: the response carries the volume operation; poll `GET /block-storage/volumes/{volume_id}/operations` until its `status` is `succeeded` or `failed`.\n\nAPI: POST /block-storage/volumes/{volume_id}/resize (resizeBlockVolume).', short_help='Resize block-storage volume')
|
|
122
|
+
@handle_api_errors
|
|
123
|
+
def resize_block_volume(
|
|
124
|
+
ctx: typer.Context,
|
|
125
|
+
volume_id: str = typer.Argument(..., metavar='VOLUME_ID', show_default=False, help='Workspace-owned block-volume ID.'),
|
|
126
|
+
new_size_gb: int = typer.Option(..., '--new-size-gb', show_default=False, help='New size in GB.'),
|
|
127
|
+
vm_state: Optional[str] = typer.Option(None, '--vm-state', show_default=False, help='Current power state of the VM, when the caller knows it. - `running` - `stopped` - `suspended`'),
|
|
128
|
+
allow_online: Optional[bool] = typer.Option(None, '--allow-online/--no-allow-online', show_default=False, help='Permit the resize while the volume is attached to a running VM. Default false.'),
|
|
129
|
+
idempotency_key: Optional[str] = typer.Option(None, '--idempotency-key', show_default=False, help='Caller-chosen key that makes a retried request return the original operation instead of starting a new one.'),
|
|
130
|
+
) -> None:
|
|
131
|
+
client = sdk(ctx)
|
|
132
|
+
result = client.block_storage.resize_block_volume(
|
|
133
|
+
volume_id,
|
|
134
|
+
**compact(
|
|
135
|
+
workspace_id=workspace(ctx),
|
|
136
|
+
new_size_gb=new_size_gb,
|
|
137
|
+
vm_state=vm_state,
|
|
138
|
+
allow_online=allow_online,
|
|
139
|
+
idempotency_key=idempotency_key,
|
|
140
|
+
),
|
|
141
|
+
)
|
|
142
|
+
emit(result)
|