Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
franklupo committed Dec 10, 2021
1 parent 654f10b commit cb10d5d
Show file tree
Hide file tree
Showing 11 changed files with 22,508 additions and 105 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# All files
[*]
guidelines = 80

# C# or VB files
[*.{cs,vb}]
guidelines = 80, 120
109 changes: 5 additions & 104 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,104 +1,5 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
/target/
.project
.settings/
.classpath
node_modules/
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "automatic"
}
10 changes: 10 additions & 0 deletions 3rd-party-licenses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# License overview of included 3rd party libraries

The project is licensed under the terms of the [LICENSE.md](LICENSE.md)

However, includes several third-party Open-Source libraries, which are licensed under their own respective Open-Source licenses.

## Libraries directly included

[json.org](https://github.com/stleary/JSON-java)
License: JSON
25 changes: 25 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# License

Copyright (C) Corsinvest Srl

This software is available under two different licenses:

* GNU General Public License version 3 (GPLv3)
* Corsinvest Enterprise License (CEL)

The default cv4pve-api-javascript license, without a valid Corsinvest Enterprise License (CEL) agreement, is the Open-Source GPLv3 license.

## GNU General Public License version 3 (GPLv3)

If you decide to choose the GPLv3 license, you must comply with the following terms:
[GPLv3](gpl-3.0.txt)

## Corsinvest Enterprise License (CEL)

Alternatively, commercial and supported versions of the program - also known as
Enterprise Distributions - must be used in accordance with the terms and conditions
contained in a separate written agreement between you and Corsinvest Srl. For more information about the Corsinvest Enterprise License (CEL) please visit [site](https://www.cv4pve-tools.com)

Please see also (files in this directory):
[GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - gpl-3.0.txt](gpl-3.0.txt)
[Libraries used by cv4pve-api-javascript including their own licenses - 3rd-party-licenses.md](3rd-party-licenses.md)
113 changes: 112 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,113 @@
# cv4pve-api-javascript
Proxmox VE Client API Javascript

Proxmox VE Client API Java

[![License](https://img.shields.io/github/license/Corsinvest/cv4pve-api-javascript.svg)](LICENSE.md) ![GitHub release](https://img.shields.io/github/release/Corsinvest/cv4pve-api-javascript.svg)

[Proxmox VE Api](https://pve.proxmox.com/pve-docs/api-viewer/)

```text
______ _ __
/ ____/___ __________(_)___ _ _____ _____/ /_
/ / / __ \/ ___/ ___/ / __ \ | / / _ \/ ___/ __/
/ /___/ /_/ / / (__ ) / / / / |/ / __(__ ) /_
\____/\____/_/ /____/_/_/ /_/|___/\___/____/\__/
Corsinvest for Proxmox VE Api Client (Made in Italy)
```

## Copyright and License

Copyright: Corsinvest Srl
For licensing details please visit [LICENSE.md](LICENSE.md)

## Commercial Support

This software is part of a suite of tools called cv4pve-tools. If you want commercial support, visit the [site](https://www.cv4pve-tools.com)

## General

The client is generated from a JSON Api on Proxmox VE.

## Result

The result is class **Result** and contain methods:

* **response** returned from Proxmox VE (data,errors,...) JSON
* **responseInError** (bool) : Contains errors from Proxmox VE.
* **statusCode** (int) : Status code of the HTTP response.
* **reasonPhrase** (string): The reason phrase which typically is sent by servers together with the status code.
* **isSuccessStatusCode** (bool) : Gets a value that indicates if the HTTP response was successful.

## Main features

* Easy to learn
* Method named
* Method no named rest (same parameters)
* getRest
* setRest
* createRest
* deleteRest
* Full method generated from documentation
* Comment any method and parameters
* Parameters indexed eg [n] is structured in array index and value
* Tree structure
* await client.nodes.get('pve1').qemu.vmlist().response
* Return data Proxmox VE
* Debug show information
* Return result
* Request
* Response
* Status
* Last result action
* Wait task finish task
* waitForTaskToFinish
* taskIsRunning
* getExitStatusTask
* Method directly access
* get
* set
* create
* delete
* Login return bool if access
* Return Result class more information
* Minimal dependency library
* ClientBase lite function
* Form Proxmox VE 6.2 support Api Token for user

## Api token

From version 6.2 of Proxmox VE is possible to use [Api token](https://pve.proxmox.com/pve-docs/pveum-plain.html).
This feature permit execute Api without using user and password.
If using **Privilege Separation** when create api token remember specify in permission.
Format USER@REALM!TOKENID=UUID

## Usage

```javascript
const pve = require('./src');

async function foo() {
var client = new pve.PveClient('10.92.90.101', 8006);
//client.logEnabled = true;
//client.apiToken = '';

var login = await client.login('root', process.env.PVE_PASSWORD, 'pam');
if (login) {
console.log((await client.get('/version')).response);
console.log((await client.version.version()).response);

console.log((await client.get('/nodes')).response);
console.log((await client.nodes.index()).response);

console.log((await client.get('/nodes/cv-pve01/qemu')).response);
console.log((await client.nodes.get('cv-pve01').qemu.vmlist(0)).response);

console.log((await client.get('/nodes/cv-pve01/qemu/103/config/')).response);
console.log((await client.nodes.get('cv-pve01').qemu.get(103).config.vmConfig()).response);

console.log((await client.get('/nodes/cv-pve01/qemu/103/snapshot/')).response);
console.log((await client.nodes.get('cv-pve01').qemu.get(103).snapshot.snapshotList()).response);
}
}
```
Loading

0 comments on commit cb10d5d

Please sign in to comment.