An open API service indexing awesome lists of open source software.

https://github.com/client-api/pve-ts

TypeScript SDK for the Proxmox Virtual Environment (PVE) API.
https://github.com/client-api/pve-ts

js node proxmox pve sdk ts typescript

Last synced: about 1 month ago
JSON representation

TypeScript SDK for the Proxmox Virtual Environment (PVE) API.

Awesome Lists containing this project

README

          

# @clientapi/pve

TypeScript SDK for the Proxmox Virtual Environment (PVE) API. Generated
from the upstream `apidoc.js` via [openapi-generator-cli][gen] with
custom Mustache template overrides.

> **Not an official Proxmox project.** Community SDK derived from the
> upstream `apidoc.js`. Always verify against
> .

## Install

```bash
npm install @clientapi/pve
# or
pnpm add @clientapi/pve
```

## Usage

```ts
import { Configuration, Pve } from '@clientapi/pve';

const cfg = new Configuration({
basePath: 'https://pve1.example.com:8006/api2/json',
apiKey: 'PVEAPIToken=user@realm!tokenid=uuid-secret',
});
const pve = new Pve(cfg);

// Per-tag accessors are lazily instantiated and share the same Configuration.
// `removeOperationIdPrefix=true` strips the tag prefix from method names,
// so the call is `pve.qemu().vmStatus(...)`, not `qemuVmStatus(...)` —
// you're already inside the `qemu` namespace.
const status = await pve.qemu().vmStatus({ node: 'pve1', vmid: 100 });
const nodes = await pve.nodes().index();
```

The unified `Pve` class wraps each per-tag API class
(`QemuApi`, `LxcApi`, `ClusterApi`, `NodesApi`, …) so consumers don't
need to instantiate them individually.

## Compound configs

PVE encodes many fields as CLI-style shorthand strings
(`net0=virtio,bridge=vmbr0,firewall=1`). Round-trip helpers are
emitted for every compound config schema:

```ts
import { PveQemuNetConfigToShorthand, PveQemuNetConfigFromShorthand } from '@clientapi/pve';

const shorthand = PveQemuNetConfigToShorthand({
model: 'virtio',
bridge: 'vmbr0',
firewall: 1,
});
// → 'virtio,bridge=vmbr0,firewall=1'

const parsed = PveQemuNetConfigFromShorthand(shorthand);
```

## Indexed families

Numbered properties (`net0..net31`, `mp0..mp255`, …) are exposed on
every model as a single collapsed `nets` / `mps` / … field:

```ts
const req = {
nets: {
0: 'virtio,bridge=vmbr0',
3: 'e1000,bridge=vmbr1',
},
};
// Wire format: { net0: 'virtio,bridge=vmbr0', net3: 'e1000,bridge=vmbr1' }
```

## License

Apache 2.0 — see [LICENSE](./LICENSE).

[gen]: https://openapi-generator.tech