f8d3cbdd59
Add the FastAPI app, PostgreSQL migrations, Docker/Helm packaging, API contracts, docs, client examples, and the unit/integration/compatibility test suite for local client and tooling labs without a real vCenter.
34 lines
1.2 KiB
Markdown
34 lines
1.2 KiB
Markdown
**Language / Язык:** [English](python-requests.md) | [Русский](../ru/examples/python-requests.md)
|
|
|
|
# Python — REST (requests / stdlib)
|
|
|
|
Raw HTTP against the vSphere REST gateway, no vendor SDK required.
|
|
|
|
```bash
|
|
pip install -r examples/python/requirements.txt
|
|
python examples/python/requests_cookbook.py
|
|
```
|
|
|
|
[`requests_cookbook.py`](../../examples/python/requests_cookbook.py)
|
|
demonstrates the shared session → create → wait-for-task → power on → wait →
|
|
power off → delete flow using `requests`, with the session id carried as the
|
|
`vmware-api-session-id` header.
|
|
|
|
For a dependency-free variant using only the standard library (`urllib`),
|
|
see [`vsphere_rest_smoke.py`](../../examples/python/vsphere_rest_smoke.py):
|
|
|
|
```bash
|
|
python examples/python/vsphere_rest_smoke.py https://localhost
|
|
```
|
|
|
|
For a combined REST-create + SOAP-`CreateVM_Task` + guest-filesystem smoke,
|
|
see [`vsphere_lifecycle.py`](../../examples/python/vsphere_lifecycle.py):
|
|
|
|
```bash
|
|
VSPHERE_BASE=https://localhost python examples/python/vsphere_lifecycle.py
|
|
```
|
|
|
|
All three scripts default to `administrator@vsphere.local` / `VMware1!` and
|
|
disable TLS verification for the local self-signed development gateway
|
|
certificate only.
|