fix endpoint comment format

This commit is contained in:
Arthur Lu 2023-07-10 22:18:08 +00:00
parent 445e702d8d
commit e37969ce3f

View File

@ -22,7 +22,7 @@ const vmidRegexP = "\\d+";
/** /**
* GET - get API version * GET - get API version
* responses: * responses:
* - 200: {version: String} * - 200: {version: string}
*/ */
app.get("/api/version", (req, res) => { app.get("/api/version", (req, res) => {
res.status(200).send({ version: api.version }); res.status(200).send({ version: api.version });
@ -74,8 +74,8 @@ app.get("/api/auth", async (req, res) => {
/** /**
* POST - safer ticket generation using proxmox authentication but adding HttpOnly * POST - safer ticket generation using proxmox authentication but adding HttpOnly
* request: * request:
* - username: String * - username: string
* - password: String * - password: string
* responses: * responses:
* - 200: {auth: true} * - 200: {auth: true}
* - 401: {auth: false} * - 401: {auth: false}
@ -155,11 +155,11 @@ app.get("/api/user/dynamic/resources", async (req, res) => {
/** /**
* GET - get db user configuration by key * GET - get db user configuration by key
* request: * request:
* - key: User config key * - key: string - user config key
* responses: * responses:
* - 200: Object * - 200: Object
* - 401: {auth: false} * - 401: {auth: false}
* - 401: {auth: false, error: String} * - 401: {auth: false, error: string}
*/ */
app.get("/api/user/config/:key", async (req, res) => { app.get("/api/user/config/:key", async (req, res) => {
const params = { const params = {
@ -183,14 +183,14 @@ app.get("/api/user/config/:key", async (req, res) => {
/** /**
* POST - detach mounted disk from instance * POST - detach mounted disk from instance
* request: * request:
* - node: String - vm host node id * - node: string - vm host node id
* -y tpe: String - vm type (lxc, qemu) * -y tpe: string - vm type (lxc, qemu)
* - vmid: Number - vm id number * - vmid: number - vm id number
* - disk: String - disk id (sata0, NOT unused) * - disk: string - disk id (sata0, NOT unused)
* responses: * responses:
* - 200: PVE Task Object * - 200: PVE Task Object
* - 401: {auth: false, path: String} * - 401: {auth: false, path: string}
* - 500: {error: String} * - 500: {error: string}
* - 500: PVE Task Object * - 500: PVE Task Object
*/ */
app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/disk/:disk/detach`, async (req, res) => { app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/disk/:disk/detach`, async (req, res) => {
@ -229,15 +229,15 @@ app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/di
/** /**
* POST - attach unused disk image to instance * POST - attach unused disk image to instance
* request: * request:
* - node: String - vm host node id * - node: string - vm host node id
* - type: String - vm type (lxc, qemu) * - type: string - vm type (lxc, qemu)
* - vmid: Number - vm id number * - vmid: number - vm id number
* - disk: String - disk id (sata0 NOT unused) * - disk: string - disk id (sata0 NOT unused)
* - source: Number - source unused disk number (0 => unused0) * - source: number - source unused disk number (0 => unused0)
* responses: * responses:
* - 200: PVE Task Object * - 200: PVE Task Object
* - 401: {auth: false, path: String} * - 401: {auth: false, path: string}
* - 500: {error: String} * - 500: {error: string}
* - 500: PVE Task Object * - 500: PVE Task Object
*/ */
app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/disk/:disk/attach`, async (req, res) => { app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/disk/:disk/attach`, async (req, res) => {
@ -283,16 +283,16 @@ app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/di
/** /**
* POST - increase size of mounted disk * POST - increase size of mounted disk
* request: * request:
* - node: String - vm host node id * - node: string - vm host node id
* - type: String - vm type (lxc, qemu) * - type: string - vm type (lxc, qemu)
* - vmid: Number - vm id number * - vmid: number - vm id number
* - disk: String - disk id (sata0 NOT unused) * - disk: string - disk id (sata0 NOT unused)
* - size: Number - increase size in GiB * - size: number - increase size in GiB
* responses: * responses:
* - 200: PVE Task Object * - 200: PVE Task Object
* - 401: {auth: false, path: String} * - 401: {auth: false, path: string}
* - 500: {error: String} * - 500: {error: string}
* - 500: {request: Object, error: String} * - 500: {request: Object, error: string}
* - 500: PVE Task Object * - 500: PVE Task Object
*/ */
app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/disk/:disk/resize`, async (req, res) => { app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/disk/:disk/resize`, async (req, res) => {
@ -335,17 +335,17 @@ app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/di
/** /**
* POST - move mounted disk from one storage to another * POST - move mounted disk from one storage to another
* request: * request:
* - node: String - vm host node id * - node: string - vm host node id
* - type: String - vm type (lxc, qemu) * - type: string - vm type (lxc, qemu)
* - vmid: Number - vm id number * - vmid: number - vm id number
* - disk: String - disk id (sata0 NOT unused) * - disk: string - disk id (sata0 NOT unused)
* - storage: String - target storage to move disk * - storage: string - target storage to move disk
* - delete: Number - delete original disk (0, 1) * - delete: number - delete original disk (0, 1)
* responses: * responses:
* - 200: PVE Task Object * - 200: PVE Task Object
* - 401: {auth: false, path: String} * - 401: {auth: false, path: string}
* - 500: {error: String} * - 500: {error: string}
* - 500: {request: Object, error: String} * - 500: {request: Object, error: string}
* - 500: PVE Task Object * - 500: PVE Task Object
*/ */
app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/disk/:disk/move`, async (req, res) => { app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/disk/:disk/move`, async (req, res) => {
@ -401,14 +401,14 @@ app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/di
/** /**
* DELETE - delete unused disk permanently * DELETE - delete unused disk permanently
* request: * request:
* - node: String - vm host node id * - node: string - vm host node id
* - type: String - vm type (lxc, qemu) * - type: string - vm type (lxc, qemu)
* - vmid: Number - vm id number * - vmid: number - vm id number
* - disk: String - disk id (unused0 or ide0) * - disk: string - disk id (unused0 or ide0)
* responses: * responses:
* - 200: PVE Task Object * - 200: PVE Task Object
* - 401: {auth: false, path: String} * - 401: {auth: false, path: string}
* - 500: {error: String} * - 500: {error: string}
* - 500: PVE Task Object * - 500: PVE Task Object
*/ */
app.delete(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/disk/:disk/delete`, async (req, res) => { app.delete(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/disk/:disk/delete`, async (req, res) => {
@ -449,17 +449,17 @@ app.delete(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/
/** /**
* POST - create a new disk in storage of specified size * POST - create a new disk in storage of specified size
* request: * request:
* - node: String - vm host node id * - node: string - vm host node id
* - type: String - vm type (lxc, qemu) * - type: string - vm type (lxc, qemu)
* - vmid: Number - vm id number * - vmid: number - vm id number
* - disk: String - disk id (sata0, ide0, NOT unused) * - disk: string - disk id (sata0, ide0, NOT unused)
* - storage: String - storage to hold disk * - storage: string - storage to hold disk
* - size: Number - size of disk in GiB * - size: number - size of disk in GiB
* - iso: String (optional) - file name to mount as cdrom * - iso: string (optional) - file name to mount as cdrom
* responses: * responses:
* - 200: PVE Task Object * - 200: PVE Task Object
* - 401: {auth: false, path: String} * - 401: {auth: false, path: string}
* - 500: {request: Object, error: String} * - 500: {request: Object, error: string}
* - 500: PVE Task Object * - 500: PVE Task Object
*/ */
app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/disk/:disk/create`, async (req, res) => { app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/disk/:disk/create`, async (req, res) => {
@ -526,17 +526,17 @@ app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/di
/** /**
* POST - create new virtual network interface * POST - create new virtual network interface
* request: * request:
* - node: String - vm host node id * - node: string - vm host node id
* - type: String - vm type (lxc, qemu) * - type: string - vm type (lxc, qemu)
* - vmid: Number - vm id number * - vmid: number - vm id number
* - netid: Number - network interface id number (0 => net0) * - netid: number - network interface id number (0 => net0)
* - rate: Number - new bandwidth rate for interface in MB/s * - rate: number - new bandwidth rate for interface in MB/s
* - name: String, optional - required interface name for lxc only * - name: string, optional - required interface name for lxc only
* responses: * responses:
* - 200: PVE Task Object * - 200: PVE Task Object
* - 401: {auth: false, path: String} * - 401: {auth: false, path: string}
* - 500: {error: String} * - 500: {error: string}
* - 500: {request: Object, error: String} * - 500: {request: Object, error: string}
* - 500: PVE Task Object * - 500: PVE Task Object
*/ */
app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/net/:netid/create`, async (req, res) => { app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/net/:netid/create`, async (req, res) => {
@ -595,16 +595,16 @@ app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/ne
/** /**
* POST - modify virtual network interface * POST - modify virtual network interface
* request: * request:
* - node: String - vm host node id * - node: string - vm host node id
* - type: String - vm type (lxc, qemu) * - type: string - vm type (lxc, qemu)
* - vmid: Number - vm id number * - vmid: number - vm id number
* - netid: Number - network interface id number (0 => net0) * - netid: number - network interface id number (0 => net0)
* - rate: Number - new bandwidth rate for interface in MB/s * - rate: number - new bandwidth rate for interface in MB/s
* responses: * responses:
* - 200: PVE Task Object * - 200: PVE Task Object
* - 401: {auth: false, path: String} * - 401: {auth: false, path: string}
* - 500: {error: String} * - 500: {error: string}
* - 500: {request: Object, error: String} * - 500: {request: Object, error: string}
* - 500: PVE Task Object * - 500: PVE Task Object
*/ */
app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/net/:netid/modify`, async (req, res) => { app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/net/:netid/modify`, async (req, res) => {
@ -653,14 +653,14 @@ app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/ne
/** /**
* DELETE - delete virtual network interface * DELETE - delete virtual network interface
* request: * request:
* - node: String - vm host node id * - node: string - vm host node id
* - type: String - vm type (lxc, qemu) * - type: string - vm type (lxc, qemu)
* - vmid: Number - vm id number * - vmid: number - vm id number
* - netid: Number - network interface id number (0 => net0) * - netid: number - network interface id number (0 => net0)
* responses: * responses:
* - 200: PVE Task Object * - 200: PVE Task Object
* - 401: {auth: false, path: String} * - 401: {auth: false, path: string}
* - 500: {error: String} * - 500: {error: string}
* - 500: PVE Task Object * - 500: PVE Task Object
*/ */
app.delete(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/net/:netid/delete`, async (req, res) => { app.delete(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/net/:netid/delete`, async (req, res) => {
@ -695,14 +695,14 @@ app.delete(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/
/** /**
* GET - get instance pcie device data * GET - get instance pcie device data
* request: * request:
* - node: String - vm host node id * - node: string - vm host node id
* - type: String - vm type (lxc, qemu) * - type: string - vm type (lxc, qemu)
* - vmid: Number - vm id number to destroy * - vmid: number - vm id number to destroy
* - hostpci: String - hostpci number * - hostpci: string - hostpci number
* responses: * responses:
* - 200: PVE PCI Device Object * - 200: PVE PCI Device Object
* - 401: {auth: false, path: String} * - 401: {auth: false, path: string}
* - 500: {error: String} * - 500: {error: string}
*/ */
app.get(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/pci/:hostpci`, async (req, res) => { app.get(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/pci/:hostpci`, async (req, res) => {
const params = { const params = {
@ -739,12 +739,12 @@ app.get(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/pci
/** /**
* GET - get available pcie devices given node and user * GET - get available pcie devices given node and user
* request: * request:
* - node: String - vm host node id * - node: string - vm host node id
* responses: * responses:
* - 200: PVE PCI Device Object * - 200: PVE PCI Device Object
* - 401: {auth: false} * - 401: {auth: false}
* - 401: {auth: false, path: String} * - 401: {auth: false, path: string}
* - 500: {error: String} * - 500: {error: string}
*/ */
app.get(`/api/:node(${nodeRegexP})/pci`, async (req, res) => { app.get(`/api/:node(${nodeRegexP})/pci`, async (req, res) => {
const params = { const params = {
@ -775,16 +775,16 @@ app.get(`/api/:node(${nodeRegexP})/pci`, async (req, res) => {
/** /**
* POST - modify existing instance pci device * POST - modify existing instance pci device
* request: * request:
* - node: String - vm host node id * - node: string - vm host node id
* - type: String - vm type (lxc, qemu) * - type: string - vm type (lxc, qemu)
* - vmid: Number - vm id number to destroy * - vmid: number - vm id number to destroy
* - hostpci: String - hostpci number * - hostpci: string - hostpci number
* - device: String - new device id * - device: string - new device id
* - pcie: Boolean - whether to use pci express or pci * - pcie: Boolean - whether to use pci express or pci
* response: * response:
* - 200: PVE Task Object * - 200: PVE Task Object
* - 401: {auth: false, path: String} * - 401: {auth: false, path: string}
* - 500: {request: Object, error: String} * - 500: {request: Object, error: string}
* - 500: PVE Task Object * - 500: PVE Task Object
*/ */
app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/pci/:hostpci/modify`, async (req, res) => { app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/pci/:hostpci/modify`, async (req, res) => {
@ -859,15 +859,15 @@ app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/pc
/** /**
* POST - add new instance pci device * POST - add new instance pci device
* request: * request:
* - node: String - vm host node id * - node: string - vm host node id
* - type: String - vm type (lxc, qemu) * - type: string - vm type (lxc, qemu)
* - vmid: Number - vm id number to destroy * - vmid: number - vm id number to destroy
* - device: String - new device id * - device: string - new device id
* - pcie: Boolean - whether to use pci express or pci * - pcie: Boolean - whether to use pci express or pci
* response: * response:
* - 200: PVE Task Object * - 200: PVE Task Object
* - 401: {auth: false, path: String} * - 401: {auth: false, path: string}
* - 500: {request: Object, error: String} * - 500: {request: Object, error: string}
* - 500: PVE Task Object * - 500: PVE Task Object
*/ */
app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/pci/create`, async (req, res) => { app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/pci/create`, async (req, res) => {
@ -938,14 +938,14 @@ app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/pc
/** /**
* DELETE - delete instance pci device * DELETE - delete instance pci device
* request: * request:
* - node: String - vm host node id * - node: string - vm host node id
* - type: String - vm type (lxc, qemu) * - type: string - vm type (lxc, qemu)
* - vmid: Number - vm id number to destroy * - vmid: number - vm id number to destroy
* - hostpci: String - hostpci number * - hostpci: string - hostpci number
* response: * response:
* - 200: PVE Task Object * - 200: PVE Task Object
* - 401: {auth: false, path: String} * - 401: {auth: false, path: string}
* - 500: {request: Object, error: String} * - 500: {request: Object, error: string}
* - 500: PVE Task Object * - 500: PVE Task Object
*/ */
app.delete(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/pci/:hostpci/delete`, async (req, res) => { app.delete(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/pci/:hostpci/delete`, async (req, res) => {
@ -994,17 +994,17 @@ app.delete(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/
/** /**
* POST - set basic resources for vm * POST - set basic resources for vm
* request: * request:
* - node: String - vm host node id * - node: string - vm host node id
* - type: String - vm type (lxc, qemu) * - type: string - vm type (lxc, qemu)
* - vmid: Number - vm id number * - vmid: number - vm id number
* - proctype: String - vm processor type * - proctype: string - vm processor type
* - cores: Number, optional - number of processor cores for instance * - cores: number, optional - number of processor cores for instance
* - memory: Number - amount of memory for instance * - memory: number - amount of memory for instance
* - swap: Number, optional - new amount of swap for instance * - swap: number, optional - new amount of swap for instance
* responses: * responses:
* - 200: PVE Task Object * - 200: PVE Task Object
* - 401: {auth: false, path: String} * - 401: {auth: false, path: string}
* - 500: {request: Object, error: String} * - 500: {request: Object, error: string}
* - 500: PVE Task Object * - 500: PVE Task Object
*/ */
app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/resources`, async (req, res) => { app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/resources`, async (req, res) => {
@ -1059,23 +1059,23 @@ app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/re
/** /**
* POST - create new instance * POST - create new instance
* request: * request:
* - node: String - vm host node id * - node: string - vm host node id
* - type: String - vm type (lxc, qemu) * - type: string - vm type (lxc, qemu)
* - vmid: Number - vm id number for instance * - vmid: number - vm id number for instance
* - hostname: String, optional- hostname for lxc instance * - hostname: string, optional- hostname for lxc instance
* - name: String, optional - hostname for qemu instance * - name: string, optional - hostname for qemu instance
* - cores: Number - number of cores for instance * - cores: number - number of cores for instance
* - memory: Number - amount of memory for instance * - memory: number - amount of memory for instance
* - swap: Number, optional - amount of swap for lxc instance * - swap: number, optional - amount of swap for lxc instance
* - password: String, optional - password for lxc instance * - password: string, optional - password for lxc instance
* - ostemplate: String, optional - os template name for lxc instance * - ostemplate: string, optional - os template name for lxc instance
* - rootfslocation: String, optional - storage name for lxc instance rootfs * - rootfslocation: string, optional - storage name for lxc instance rootfs
* - rootfssize: Number, optional, - size of lxc instance rootfs * - rootfssize: number, optional, - size of lxc instance rootfs
* responses: * responses:
* - 200: PVE Task Object * - 200: PVE Task Object
* - 401: {auth: false, path: String} * - 401: {auth: false, path: string}
* - 500: {error: String} * - 500: {error: string}
* - 500: {request: Object, error: String} * - 500: {request: Object, error: string}
* - 500: PVE Task Object * - 500: PVE Task Object
*/ */
app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/create`, async (req, res) => { app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/create`, async (req, res) => {
@ -1171,12 +1171,12 @@ app.post(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/cr
/** /**
* DELETE - destroy existing instance * DELETE - destroy existing instance
* request: * request:
* - node: String - vm host node id * - node: string - vm host node id
* - type: String - vm type (lxc, qemu) * - type: string - vm type (lxc, qemu)
* - vmid: Number - vm id number to destroy * - vmid: number - vm id number to destroy
* responses: * responses:
* - 200: PVE Task Object * - 200: PVE Task Object
* - 401: {auth: false, path: String} * - 401: {auth: false, path: string}
* - 500: PVE Task Object * - 500: PVE Task Object
*/ */
app.delete(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/delete`, async (req, res) => { app.delete(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/delete`, async (req, res) => {
@ -1196,6 +1196,15 @@ app.delete(`/api/:node(${nodeRegexP})/:type(${typeRegexP})/:vmid(${vmidRegexP})/
await handleResponse(params.node, result, res); await handleResponse(params.node, result, res);
}); });
/**
* GET - get hash of current cluster resources states
* responses:
* - string
*/
app.get(`/cluster/statushash`, async (req, res) => {
});
app.listen(listenPort, () => { app.listen(listenPort, () => {
console.log(`proxmoxaas-api v${api.version} listening on port ${listenPort}`); console.log(`proxmoxaas-api v${api.version} listening on port ${listenPort}`);
}); });