Provides a minimal wrapper around io.Manager REST APIs to simplify the process of fetching and modifying data stored in io.Manager Server by JavaScript applications.
The changelog can be found here: Changelog
There are two types of APIs exposed by the package:
- AdminAPI - used to fetch or modify any type of data stored in io.Manager Server
- ClientAPI - used to fetch data specific to a single user (e.g. user's applications and layouts); allows updating entities that are owned by the user.
Initialization is similar for both APIs. You should provide an options object that has two required properties:
-
baseUrl
which is the Server API endpoint. -
auth
contains the authentication on the specific authentication.
import { AdminAPI, ClientAPI } from '@interopio/manager-api';
const admin = new AdminAPI({
baseUrl: `http://localhost:3465/`,
auth: {
token: {
bearer: this.auth?.token,
},
},
});
const client = new ClientAPI({
baseUrl: `http://localhost:3465/`,
auth: {
token: {
bearer: this.auth?.token,
},
},
});
Adding Extra Headers
You can add extra headers to be sent with each request by using the headers property of the options object.
const admin = new AdminAPI({
baseUrl: `http://localhost:3465/`,
auth: {
token: {
bearer: this.auth?.token,
},
},
headers: {
'X-Extra-Header': 'value',
},
});
Transforming responses
You can transform incoming responses using the transformResponse method. This method is called with the response object and should return the transformed response.
const admin = new AdminAPI({
baseUrl: `http://localhost:3465/`,
auth: {
token: {
bearer: this.auth?.token,
},
},
transformResponse: (data, headers, status) => {
const responseType = header['content-type'];
if (
responseType &&
responseType.includes('application/json') &&
typeof data === 'string'
) {
return this.parse(data);
} else {
return data;
}
},
});
The AdminAPI allows you to manage any type of entity stored by the server. Operations are exposed as methods attached to sub-properties of the API object. For example, to fetch all applications, you would call the admin.apps.getAll() method.
-
apps
- Manage Applications; -
apps2
- Manage Applications; -
groups
- Manage Groups; -
users
- Manage Users; -
layouts
- Manage Layouts; -
layouts2
- Manage Layouts; -
commands
- Manage Commands; -
sessions
- Manage Sessions; -
machines
- Manage Machines; -
crashes
- Manage Crashes; -
feedbacks
- Manage Feedbacks; -
prefs
- Manage Prefs; -
audit
- Manage AuditAPI; -
server
- Manage ServerAPI; -
systemConfig
- Manage SystemConfigAPI; -
schemas
- Manage SchemaAPI;
The operations in the ClientAPI work in the context of a single user.