1.0.1 • Published 4 years ago

gasper_api v1.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

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

ClassMethodHTTP requestDescription
GasperApi.AdminApideleteAppByAdminDELETE /admin/apps/{app}Delete an application
GasperApi.AdminApideleteDbByAdminDELETE /admin/dbs/{db}Delete a single database
GasperApi.AdminApideleteUserByAdminDELETE /admin/users/{userEmail}Delete a single user
GasperApi.AdminApifetchAppByAdminGET /admin/apps/{app}Fetch a single application
GasperApi.AdminApifetchAppsByAdminGET /admin/appsFetch all applications with/without a filter defined by query params
GasperApi.AdminApifetchDbByAdminGET /admin/dbs/{db}Fetch a single database
GasperApi.AdminApifetchDbsByAdminGET /admin/dbsFetch all databases with/without a filter defined by query params
GasperApi.AdminApifetchNodeByAdminGET /admin/nodes/{type}Fetch bind addresses(IP:Port) of a single microservice on all nodes
GasperApi.AdminApifetchNodesByAdminGET /admin/nodesFetch bind addresses(IP:Port) of all microservices on all nodes
GasperApi.AdminApifetchUserByAdminGET /admin/users/{userEmail}Fetch a single user
GasperApi.AdminApifetchUsersByAdminGET /admin/usersFetch all users with/without a filter defined by query params
GasperApi.AdminApigrantSuperuserPrivilegePATCH /admin/users/{userEmail}/grantGrant superuser privileges to a single user
GasperApi.AdminApirevokeSuperuserPrivilegePATCH /admin/users/{userEmail}/revokeRevoke superuser privileges from a single user
GasperApi.AppsApicreateAppPOST /apps/{language}Create an application
GasperApi.AppsApideleteAppByUserDELETE /apps/{app}Delete an application owned by a user
GasperApi.AppsApifetchAppByUserGET /apps/{app}Fetch a single application owned by a user
GasperApi.AppsApifetchAppsByUserGET /appsFetch all applications owned by a user
GasperApi.AppsApifetchLogsByUserGET /apps/{app}/logsFetch logs of an application
GasperApi.AppsApirebuildAppByUserPATCH /apps/{app}/rebuildRebuild an application
GasperApi.AppsApitransferAppByUserPATCH /apps/{app}/transfer/{userEmail}Transfer ownership of an application to another user
GasperApi.AppsApiupdateAppByUserPUT /apps/{app}Update an application owned by a user
GasperApi.AuthApiloginPOST /auth/loginLogin to get a Bearer token
GasperApi.AuthApirefreshGET /auth/refreshRefresh JWT token using existing token
GasperApi.AuthApiregisterPOST /auth/registerRegister a user
GasperApi.DbsApicreateDBPOST /dbs/{databaseType}Create a database
GasperApi.DbsApideleteDbByUserDELETE /dbs/{db}Delete a single database owned by a user
GasperApi.DbsApifetchDbByUserGET /dbs/{db}Fetch a single database owned by a user
GasperApi.DbsApifetchDbsByUserGET /dbsFetch all databases owned by a user
GasperApi.DbsApitransferDbByUserPATCH /dbs/{db}/transfer/{userEmail}Transfer ownership of a database to another user

Documentation for Models

Documentation for Authorization

bearerAuth

  • Type: Bearer authentication (JWT)