garage-admin-sdk-js/README.md

8.7 KiB

garage_administration_api_v0garage_v0_9_0

garage - JavaScript client for garage_administration_api_v0garage_v0_9_0 Administrate your Garage cluster programatically, including status, layout, keys, buckets, and maintainance tasks.

Disclaimer: The API is not stable yet, hence its v0 tag. The API can change at any time, and changes can include breaking backward compatibility. Read the changelog and upgrade your scripts before upgrading. Additionnaly, this specification is very early stage and can contain bugs, especially on error return codes/types that are not tested yet. Do not expect a well finished and polished product!

This SDK is automatically generated by the OpenAPI Generator project:

  • API version: v0.9.0
  • Package version: v0.9.0
  • Build package: org.openapitools.codegen.languages.JavascriptClientCodegen

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 garage_administration_api_v0garage_v0_9_0 --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 garage_administration_api_v0garage_v0_9_0 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/garage-sdk/garage-admin-sdk-js then install it via:

    npm install garage-sdk/garage-admin-sdk-js --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 garage = require('garage_administration_api_v0garage_v0_9_0');

var defaultClient = garage.ApiClient.instance;
// Configure Bearer access token for authorization: bearerAuth
var bearerAuth = defaultClient.authentications['bearerAuth'];
bearerAuth.accessToken = "YOUR ACCESS TOKEN"

var api = new garage.BucketApi()
var allowBucketKeyRequest = new garage.AllowBucketKeyRequest(); // {AllowBucketKeyRequest} Aliases to put on the new bucket 
api.allowBucketKey(allowBucketKeyRequest).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:3903/v1

Class Method HTTP request Description
garage.BucketApi allowBucketKey POST /bucket/allow Allow key
garage.BucketApi createBucket POST /bucket Create a bucket
garage.BucketApi deleteBucket DELETE /bucket Delete a bucket
garage.BucketApi deleteBucketGlobalAlias DELETE /bucket/alias/global Delete a global alias
garage.BucketApi deleteBucketLocalAlias DELETE /bucket/alias/local Delete a local alias
garage.BucketApi denyBucketKey POST /bucket/deny Deny key
garage.BucketApi getBucketInfo GET /bucket Get a bucket
garage.BucketApi listBuckets GET /bucket?list List all buckets
garage.BucketApi putBucketGlobalAlias PUT /bucket/alias/global Add a global alias
garage.BucketApi putBucketLocalAlias PUT /bucket/alias/local Add a local alias
garage.BucketApi updateBucket PUT /bucket Update a bucket
garage.KeyApi addKey POST /key?list Create a new API key
garage.KeyApi deleteKey DELETE /key Delete a key
garage.KeyApi getKey GET /key Get key information
garage.KeyApi importKey POST /key/import Import an existing key
garage.KeyApi listKeys GET /key?list List all keys
garage.KeyApi updateKey POST /key Update a key
garage.LayoutApi addLayout POST /layout Send modifications to the cluster layout
garage.LayoutApi applyLayout POST /layout/apply Apply staged layout
garage.LayoutApi getLayout GET /layout Details on the current and staged layout
garage.LayoutApi revertLayout POST /layout/revert Clear staged layout
garage.NodesApi addNode POST /connect Connect a new node
garage.NodesApi getHealth GET /health Cluster health report
garage.NodesApi getNodes GET /status Describe cluster

Documentation for Models

Documentation for Authorization

bearerAuth

  • Type: Bearer authentication