0.3.4 • Published 6 years ago
api-portainer v0.3.4
Portainer Client
This projects exposes the Portainer API (currently for version 1.20.2) as Promise-based JavaScript functions. Currently, only GET based endpoints are implemented, other ones will follow. If I have enough time and motivation, I will also add an OOP abstraction layer.
The package is written in TypeScript (.d.ts
type definitions come bundled with this package)
and compiles to ES5.
Table of contents
Features
- Call Portainer API endpoints using plain JS functions or a class
- Optional encapsulation of authentication and hostname using the
PortainerSession
class
Example
Using the plain functions
const host = 'https://myportainerinstance';
async function main() {
const token = await authenticate(host, 'username', 'password');
const stacks = await stacks.getAll(host, token);
console.log(JSON.stringify(stacks));
}
main();
$ node index.js
[{"Id":3,"Name":"databasestack","Type":2,"EndpointId":1,"SwarmId":"","EntryPoint":"docker-compose.yml","Env":[],"ProjectPath":"/data/compose/3","ResourceControl":{"Id":0,"ResourceId":"","SubResourceIds":null,"Type":0,"UserAccesses":null,"TeamAccesses":null,"Public":false}}]
Using the PortainerSession
class
import PortainerSession from 'portainer-client';
async function main() {
const portainer = await PortainerSession.create('https://portainer.example.com','username', 'password');
const stacks = await portainer.getStacks();
console.log(JSON.stringify(stacks));
}
$ node index.js
[{"Id":3,"Name":"databasestack","Type":2,"EndpointId":1,"SwarmId":"","EntryPoint":"docker-compose.yml","Env":[],"ProjectPath":"/data/compose/3","ResourceControl":{"Id":0,"ResourceId":"","SubResourceIds":null,"Type
0.3.4
6 years ago
0.3.3
6 years ago
0.3.2
6 years ago
0.3.1
6 years ago
0.3.0
6 years ago
0.2.13
6 years ago
0.2.12
6 years ago
0.2.11
6 years ago
0.2.10
6 years ago
0.2.9
6 years ago
0.2.8
6 years ago
0.2.7
6 years ago
0.2.6
6 years ago
0.2.5
6 years ago
0.2.4
6 years ago
0.2.3
6 years ago
0.2.2
6 years ago
0.2.1
6 years ago
0.2.0
6 years ago
0.1.0
6 years ago