https://github.com/sdslabs/gasper-api-client
API Client for Gasper in javascript
https://github.com/sdslabs/gasper-api-client
Last synced: 1 day ago
JSON representation
API Client for Gasper in javascript
- Host: GitHub
- URL: https://github.com/sdslabs/gasper-api-client
- Owner: sdslabs
- Created: 2019-10-28T18:32:15.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-12-14T06:58:58.000Z (over 5 years ago)
- Last Synced: 2025-02-23T20:32:06.235Z (over 1 year ago)
- Language: JavaScript
- Size: 205 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gasper_kaze_api
GasperKazeApi - JavaScript client for gasper_kaze_api
Handles authentication, creation/management of applications, databases, users and also provides a superuser API.
Only a superuser can avail the superuser API. A superuser can **grant/revoke** superuser privileges to other users. A default superuser is created every time a Gasper instance is launched whose credentials are defined in the `admin` section of `config.toml`, the main configuration file. A sample configuration file is available [here](https://github.com/sdslabs/gasper/blob/develop/config.sample.toml#L37).
**Note:-** Normally the applications and databases can only be managed by their owners but the superuser can bypass that check.
**PS:-** If you want to programmatically generate a client for this API, you can find the corresponding OpenAPI specifications [here](https://github.com/sdslabs/gasper/tree/develop/docs/content/api/specs). We recommend using [OpenAPI-Generator](https://openapi-generator.tech/) for generating clients.
This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
- API version: 1.0
- Package version: 1.0
- Build package: org.openapitools.codegen.languages.JavascriptClientCodegen
For more information, please visit [https://chat.sdslabs.co](https://chat.sdslabs.co)
## Installation
### For [Node.js](https://nodejs.org/)
#### npm
To publish the library as a [npm](https://www.npmjs.com/), please follow the procedure in ["Publishing npm packages"](https://docs.npmjs.com/getting-started/publishing-npm-packages).
Then install it via:
```shell
npm install gasper_kaze_api --save
```
Finally, you need to build the module:
```shell
npm run build
```
##### Local development
To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing `package.json` (and this README). Let's call this `JAVASCRIPT_CLIENT_DIR`. Then run:
```shell
npm install
```
Next, [link](https://docs.npmjs.com/cli/link) it globally in npm with the following, also from `JAVASCRIPT_CLIENT_DIR`:
```shell
npm link
```
To use the link you just defined in your project, switch to the directory you want to use your gasper_kaze_api from, and run:
```shell
npm link /path/to/
```
Finally, you need to build the module:
```shell
npm run build
```
#### git
If the library is hosted at a git repository, e.g.https://github.com/GIT_USER_ID/GIT_REPO_ID
then install it via:
```shell
npm install GIT_USER_ID/GIT_REPO_ID --save
```
### For browser
The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following
the above steps with Node.js and installing browserify with `npm install -g browserify`,
perform the following (assuming *main.js* is your entry file):
```shell
browserify main.js > bundle.js
```
Then include *bundle.js* in the HTML pages.
### Webpack Configuration
Using Webpack you may encounter the following error: "Module not found: Error:
Cannot resolve module", most certainly you should disable AMD loader. Add/merge
the following section to your webpack config:
```javascript
module: {
rules: [
{
parser: {
amd: false
}
}
]
}
```
## Getting Started
Please follow the [installation](#installation) instruction and execute the following JS code:
```javascript
var GasperKazeApi = require('gasper_kaze_api');
var defaultClient = GasperKazeApi.ApiClient.instance;
// Configure Bearer (JWT) access token for authorization: bearerAuth
var bearerAuth = defaultClient.authentications['bearerAuth'];
bearerAuth.accessToken = "YOUR ACCESS TOKEN"
var api = new GasperKazeApi.AdminApi()
var authorization = Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9; // {String} Bearer Token Authentication
var app = "app_example"; // {String} The name of the application
api.deleteAppByAdmin(authorization, app).then(function(data) {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
```
## Documentation for API Endpoints
All URIs are relative to *http://localhost:3000*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*GasperKazeApi.AdminApi* | [**deleteAppByAdmin**](docs/AdminApi.md#deleteAppByAdmin) | **DELETE** /admin/apps/{app} | Delete an application
*GasperKazeApi.AdminApi* | [**deleteDbByAdmin**](docs/AdminApi.md#deleteDbByAdmin) | **DELETE** /admin/dbs/{db} | Delete a single database
*GasperKazeApi.AdminApi* | [**deleteUserByAdmin**](docs/AdminApi.md#deleteUserByAdmin) | **DELETE** /admin/users/{userEmail} | Delete a single user
*GasperKazeApi.AdminApi* | [**fetchAppByAdmin**](docs/AdminApi.md#fetchAppByAdmin) | **GET** /admin/apps/{app} | Fetch a single application
*GasperKazeApi.AdminApi* | [**fetchAppsByAdmin**](docs/AdminApi.md#fetchAppsByAdmin) | **GET** /admin/apps | Fetch all applications with/without a filter defined by query params
*GasperKazeApi.AdminApi* | [**fetchDbByAdmin**](docs/AdminApi.md#fetchDbByAdmin) | **GET** /admin/dbs/{db} | Fetch a single database
*GasperKazeApi.AdminApi* | [**fetchDbsByAdmin**](docs/AdminApi.md#fetchDbsByAdmin) | **GET** /admin/dbs | Fetch all databases with/without a filter defined by query params
*GasperKazeApi.AdminApi* | [**fetchNodeByAdmin**](docs/AdminApi.md#fetchNodeByAdmin) | **GET** /admin/nodes/{type} | Fetch bind addresses(IP:Port) of a single microservice on all nodes
*GasperKazeApi.AdminApi* | [**fetchNodesByAdmin**](docs/AdminApi.md#fetchNodesByAdmin) | **GET** /admin/nodes | Fetch bind addresses(IP:Port) of all microservices on all nodes
*GasperKazeApi.AdminApi* | [**fetchUserByAdmin**](docs/AdminApi.md#fetchUserByAdmin) | **GET** /admin/users/{userEmail} | Fetch a single user
*GasperKazeApi.AdminApi* | [**fetchUsersByAdmin**](docs/AdminApi.md#fetchUsersByAdmin) | **GET** /admin/users | Fetch all users with/without a filter defined by query params
*GasperKazeApi.AdminApi* | [**grantSuperuserPrivilege**](docs/AdminApi.md#grantSuperuserPrivilege) | **PATCH** /admin/users/{userEmail}/grant | Grant superuser privileges to a single user
*GasperKazeApi.AdminApi* | [**revokeSuperuserPrivilege**](docs/AdminApi.md#revokeSuperuserPrivilege) | **PATCH** /admin/users/{userEmail}/revoke | Revoke superuser privileges from a single user
*GasperKazeApi.AppsApi* | [**createApp**](docs/AppsApi.md#createApp) | **POST** /apps/{language} | Create an application
*GasperKazeApi.AppsApi* | [**deleteAppByUser**](docs/AppsApi.md#deleteAppByUser) | **DELETE** /apps/{app} | Delete an application owned by a user
*GasperKazeApi.AppsApi* | [**fetchAppByUser**](docs/AppsApi.md#fetchAppByUser) | **GET** /apps/{app} | Fetch a single application owned by a user
*GasperKazeApi.AppsApi* | [**fetchAppsByUser**](docs/AppsApi.md#fetchAppsByUser) | **GET** /apps | Fetch all applications owned by a user
*GasperKazeApi.AppsApi* | [**fetchLogsByUser**](docs/AppsApi.md#fetchLogsByUser) | **GET** /apps/{app}/logs | Fetch logs of an application
*GasperKazeApi.AppsApi* | [**fetchMetricsByUser**](docs/AppsApi.md#fetchMetricsByUser) | **GET** /apps/{app}/metrics | Fetch metrics of an application
*GasperKazeApi.AppsApi* | [**fetchTerminalByUser**](docs/AppsApi.md#fetchTerminalByUser) | **GET** /apps/{app}/term | Fetch a browser terminal instance for an application owned by a user
*GasperKazeApi.AppsApi* | [**rebuildAppByUser**](docs/AppsApi.md#rebuildAppByUser) | **PATCH** /apps/{app}/rebuild | Rebuild an application
*GasperKazeApi.AppsApi* | [**transferAppByUser**](docs/AppsApi.md#transferAppByUser) | **PATCH** /apps/{app}/transfer/{userEmail} | Transfer ownership of an application to another user
*GasperKazeApi.AppsApi* | [**updateAppByUser**](docs/AppsApi.md#updateAppByUser) | **PUT** /apps/{app} | Update an application owned by a user
*GasperKazeApi.AuthApi* | [**login**](docs/AuthApi.md#login) | **POST** /auth/login | Login to get a Bearer token
*GasperKazeApi.AuthApi* | [**refresh**](docs/AuthApi.md#refresh) | **GET** /auth/refresh | Refresh JWT token using existing token
*GasperKazeApi.AuthApi* | [**register**](docs/AuthApi.md#register) | **POST** /auth/register | Register a user
*GasperKazeApi.DbsApi* | [**createDB**](docs/DbsApi.md#createDB) | **POST** /dbs/{databaseType} | Create a database
*GasperKazeApi.DbsApi* | [**deleteDbByUser**](docs/DbsApi.md#deleteDbByUser) | **DELETE** /dbs/{db} | Delete a single database owned by a user
*GasperKazeApi.DbsApi* | [**fetchDbByUser**](docs/DbsApi.md#fetchDbByUser) | **GET** /dbs/{db} | Fetch a single database owned by a user
*GasperKazeApi.DbsApi* | [**fetchDbsByUser**](docs/DbsApi.md#fetchDbsByUser) | **GET** /dbs | Fetch all databases owned by a user
*GasperKazeApi.DbsApi* | [**transferDbByUser**](docs/DbsApi.md#transferDbByUser) | **PATCH** /dbs/{db}/transfer/{userEmail} | Transfer ownership of a database to another user
*GasperKazeApi.UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user | Delete user
*GasperKazeApi.UserApi* | [**fetchUser**](docs/UserApi.md#fetchUser) | **GET** /user | Fetch logged in user's info
*GasperKazeApi.UserApi* | [**updatePassword**](docs/UserApi.md#updatePassword) | **PUT** /user/password | Update the password of the logged in user
## Documentation for Models
- [GasperKazeApi.Application](docs/Application.md)
- [GasperKazeApi.Context](docs/Context.md)
- [GasperKazeApi.CreatedApplication](docs/CreatedApplication.md)
- [GasperKazeApi.CreatedDatabase](docs/CreatedDatabase.md)
- [GasperKazeApi.CreatedUser](docs/CreatedUser.md)
- [GasperKazeApi.Database](docs/Database.md)
- [GasperKazeApi.Git](docs/Git.md)
- [GasperKazeApi.InlineObject](docs/InlineObject.md)
- [GasperKazeApi.InlineResponse200](docs/InlineResponse200.md)
- [GasperKazeApi.InlineResponse2001](docs/InlineResponse2001.md)
- [GasperKazeApi.InlineResponse20010](docs/InlineResponse20010.md)
- [GasperKazeApi.InlineResponse20011](docs/InlineResponse20011.md)
- [GasperKazeApi.InlineResponse20012](docs/InlineResponse20012.md)
- [GasperKazeApi.InlineResponse20013](docs/InlineResponse20013.md)
- [GasperKazeApi.InlineResponse20014](docs/InlineResponse20014.md)
- [GasperKazeApi.InlineResponse2001Resources](docs/InlineResponse2001Resources.md)
- [GasperKazeApi.InlineResponse2002](docs/InlineResponse2002.md)
- [GasperKazeApi.InlineResponse2003](docs/InlineResponse2003.md)
- [GasperKazeApi.InlineResponse2004](docs/InlineResponse2004.md)
- [GasperKazeApi.InlineResponse2005](docs/InlineResponse2005.md)
- [GasperKazeApi.InlineResponse2006](docs/InlineResponse2006.md)
- [GasperKazeApi.InlineResponse2007](docs/InlineResponse2007.md)
- [GasperKazeApi.InlineResponse2008](docs/InlineResponse2008.md)
- [GasperKazeApi.InlineResponse2009](docs/InlineResponse2009.md)
- [GasperKazeApi.InlineResponse400](docs/InlineResponse400.md)
- [GasperKazeApi.InlineResponse401](docs/InlineResponse401.md)
- [GasperKazeApi.InlineResponse500](docs/InlineResponse500.md)
- [GasperKazeApi.Login](docs/Login.md)
- [GasperKazeApi.LoginResponse](docs/LoginResponse.md)
- [GasperKazeApi.Metrics](docs/Metrics.md)
- [GasperKazeApi.User](docs/User.md)
## Documentation for Authorization
### bearerAuth
- **Type**: Bearer authentication (JWT)