gasper_api
v1.0.1
Published
Handles_authentication_creation_management_of_applications_databases_users_and_also_provides_a_superuser_API__brbr_Only_a_superuser_can_avail_the_superuser_API__A_superuser_can_grant_revoke_superuser_privileges_to_other_users__A_default__superuser_is_crea
Downloads
6
Readme
gasper_api
GasperApi - JavaScript client for gasper_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. 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. We recommend using OpenAPI-Generator for generating clients.
This SDK is automatically generated by the OpenAPI Generator 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
Installation
For Node.js
npm
To publish the library as a npm, please follow the procedure in "Publishing npm packages".
Then install it via:
npm install gasper_api --save
Finally, you need to build the module:
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:
npm install
Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR
:
npm link
To use the link you just defined in your project, switch to the directory you want to use your gasper_api from, and run:
npm link /path/to/<JAVASCRIPT_CLIENT_DIR>
Finally, you need to build the module:
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:
npm install GIT_USER_ID/GIT_REPO_ID --save
For browser
The library also works in the browser environment via npm and browserify. 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):
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:
module: {
rules: [
{
parser: {
amd: false
}
}
]
}
Getting Started
Please follow the installation instruction and execute the following JS code:
var GasperApi = require('gasper_api');
var defaultClient = GasperApi.ApiClient.instance;
// Configure Bearer (JWT) access token for authorization: bearerAuth
var bearerAuth = defaultClient.authentications['bearerAuth'];
bearerAuth.accessToken = "YOUR ACCESS TOKEN"
var api = new GasperApi.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 ------------ | ------------- | ------------- | ------------- GasperApi.AdminApi | deleteAppByAdmin | DELETE /admin/apps/{app} | Delete an application GasperApi.AdminApi | deleteDbByAdmin | DELETE /admin/dbs/{db} | Delete a single database GasperApi.AdminApi | deleteUserByAdmin | DELETE /admin/users/{userEmail} | Delete a single user GasperApi.AdminApi | fetchAppByAdmin | GET /admin/apps/{app} | Fetch a single application GasperApi.AdminApi | fetchAppsByAdmin | GET /admin/apps | Fetch all applications with/without a filter defined by query params GasperApi.AdminApi | fetchDbByAdmin | GET /admin/dbs/{db} | Fetch a single database GasperApi.AdminApi | fetchDbsByAdmin | GET /admin/dbs | Fetch all databases with/without a filter defined by query params GasperApi.AdminApi | fetchNodeByAdmin | GET /admin/nodes/{type} | Fetch bind addresses(IP:Port) of a single microservice on all nodes GasperApi.AdminApi | fetchNodesByAdmin | GET /admin/nodes | Fetch bind addresses(IP:Port) of all microservices on all nodes GasperApi.AdminApi | fetchUserByAdmin | GET /admin/users/{userEmail} | Fetch a single user GasperApi.AdminApi | fetchUsersByAdmin | GET /admin/users | Fetch all users with/without a filter defined by query params GasperApi.AdminApi | grantSuperuserPrivilege | PATCH /admin/users/{userEmail}/grant | Grant superuser privileges to a single user GasperApi.AdminApi | revokeSuperuserPrivilege | PATCH /admin/users/{userEmail}/revoke | Revoke superuser privileges from a single user GasperApi.AppsApi | createApp | POST /apps/{language} | Create an application GasperApi.AppsApi | deleteAppByUser | DELETE /apps/{app} | Delete an application owned by a user GasperApi.AppsApi | fetchAppByUser | GET /apps/{app} | Fetch a single application owned by a user GasperApi.AppsApi | fetchAppsByUser | GET /apps | Fetch all applications owned by a user GasperApi.AppsApi | fetchLogsByUser | GET /apps/{app}/logs | Fetch logs of an application GasperApi.AppsApi | rebuildAppByUser | PATCH /apps/{app}/rebuild | Rebuild an application GasperApi.AppsApi | transferAppByUser | PATCH /apps/{app}/transfer/{userEmail} | Transfer ownership of an application to another user GasperApi.AppsApi | updateAppByUser | PUT /apps/{app} | Update an application owned by a user GasperApi.AuthApi | login | POST /auth/login | Login to get a Bearer token GasperApi.AuthApi | refresh | GET /auth/refresh | Refresh JWT token using existing token GasperApi.AuthApi | register | POST /auth/register | Register a user GasperApi.DbsApi | createDB | POST /dbs/{databaseType} | Create a database GasperApi.DbsApi | deleteDbByUser | DELETE /dbs/{db} | Delete a single database owned by a user GasperApi.DbsApi | fetchDbByUser | GET /dbs/{db} | Fetch a single database owned by a user GasperApi.DbsApi | fetchDbsByUser | GET /dbs | Fetch all databases owned by a user GasperApi.DbsApi | transferDbByUser | PATCH /dbs/{db}/transfer/{userEmail} | Transfer ownership of a database to another user
Documentation for Models
- GasperApi.Application
- GasperApi.Context
- GasperApi.CreatedApplication
- GasperApi.CreatedDatabase
- GasperApi.CreatedUser
- GasperApi.Database
- GasperApi.Git
- GasperApi.InlineResponse200
- GasperApi.InlineResponse2001
- GasperApi.InlineResponse2001Resources
- GasperApi.InlineResponse2002
- GasperApi.InlineResponse2003
- GasperApi.InlineResponse2004
- GasperApi.InlineResponse2005
- GasperApi.InlineResponse2006
- GasperApi.InlineResponse2007
- GasperApi.InlineResponse2008
- GasperApi.InlineResponse2009
- GasperApi.InlineResponse400
- GasperApi.InlineResponse401
- GasperApi.InlineResponse500
- GasperApi.Login
- GasperApi.LoginResponse
- GasperApi.User
Documentation for Authorization
bearerAuth
- Type: Bearer authentication (JWT)