proxmox-client

1.3.3 • Public • Published

proxmox-client

A node.js client for the Proxmox API

npm downloads npm version NpmLicense Conventional Commits Conventional Commits

(Get) Usage example

const proxmox = require('proxmox-client');
 
proxmox.auth('localhost:8006', 'root@pam!testToken', 'token').then(() => {
  proxmox.get('/nodes').then((res) => {
    if(res.status !== 200) {
      console.log("statusCode is not 200");
    }
    res = JSON.parse(res.text).data;
    console.log(res);
  })
  .catch((err) => {
    console.log('Error:', err);
  });
  }).catch((err) => {
  console.log(err);
});

(Post) Usage example

const proxmox = require('proxmox-client');
 
proxmox.auth('localhost:8006', 'root@pam!testToken', 'token').then(() => {
  proxmox.post('/nodes/testnode/qemu/100/status/reboot', {timeout: 1500}).then((res) => {
    if(res.status !== 200) {
      console.log("statusCode is not 200");
    }
    res = JSON.parse(res.text).data;
    console.log(res);
  })
  .catch((err) => {
    console.log('Error:', err);
  });
  }).catch((err) => {
    console.log(err);
  });
});

API

proxmox.auth(host, user, tokenName, token, realm = 'pam'): Promise

Stores the auth information

proxmox.auth(host, tokenInfo, token): Promise

Stores the auth information

proxmox.get(path): Promise

Sends a GET Request to the defined path and returns a superagent request

proxmox.post(path, body): Promise

Sends a POST Request to the defined path with the defined body and returns a superagent request

proxmox.put(path, body): Promise

Sends a PUT Request to the defined path with the defined body and returns a superagent request

proxmox.delete(path): Promise

Sends a DELETE Request to the defined path and returns a superagent request

proxmox.del(path): Promise

Sends a DELETE Request to the defined path and returns a superagent request

Debugging

You can enable the debug outputs by setting the DEBUG environment variable to 'proxmox:*'.

License

GPL-3.0

Readme

Keywords

Package Sidebar

Install

npm i proxmox-client

Weekly Downloads

4

Version

1.3.3

License

GPL-3.0

Unpacked Size

8.34 kB

Total Files

6

Last publish

Collaborators

  • beefoio