**Language / Язык:** [English](content-library.md) | [Русский](../ru/domains/content-library.md)

# Content library

Local content libraries, library items, upload/download sessions, and OVF
deploy:
[`app/vsphere/rest/content_rest.py`](../../app/vsphere/rest/content_rest.py),
[`nfc_rest.py`](../../app/vsphere/rest/nfc_rest.py),
[`app/vsphere/domain/content.py`](../../app/vsphere/domain/content.py).

## Endpoints

| Method | Path | Notes |
|---|---|---|
| GET | `/api/content/library` | List library ids |
| POST | `/api/content/local-library` | Create a local library |
| GET/POST | `/api/content/library/item` | List / create items (`?library_id=`) |
| POST | `/api/vcenter/ovf/library-item/{item_id}` | Deploy OVF item → new `VirtualMachine` + task |
| POST | `/api/content/library/item/update-session[/{session_id}[/file]]` | Push-upload flow (Ansible/Terraform-style) |
| GET/POST | `/api/content/library/item/download-session[/{session_id}[/file]]` | Pull-download flow |
| GET/PUT/POST | `/nfc/{lease}` \| `/nfc/{lease}/files/{filename}` \| `/nfc/{lease}/complete` | HttpNfcLease-style transfer endpoints for the SOAP import path |

## Highlights

- Libraries/items persist in `vsphere_libraries` / `vsphere_library_items`;
  the seed creates two libraries ("Local Content", "Published Templates")
  with OVF-typed items (`ubuntu-22.04`, `centos-stream-9`, `golden-image`).
- Update/download sessions persist in PostgreSQL (`vsphere_transfer_sessions`,
  migration `012`) and model the file-transfer handshake — not a real
  byte-for-byte OVF/VMDK store. HttpNfcLease rows live in `vsphere_nfc_leases`.
- `deploy_ovf_from_library` creates a real `VirtualMachine` row and returns a
  task id, mirroring the SOAP `ImportVApp_Task` / `CreateImportSpec` +
  `HttpNfcLease*` flow used by govc-style `ovf.import`.
- Requires `ContentLibrary.CreateLocalLibrary` / `.AddLibraryItem` to create,
  and `VirtualMachine.Provisioning.DeployTemplate` to deploy.

See [SOAP / VIM](soap.md) for the HttpNfcLease progress/complete/abort
operations used by upload-heavy clients.
