node-skytap
This library wraps the Skytap API for use in Node.js applications. It is designed to work with node style callbacks as well as with Promises. This library is still under active development to build out the full feature set of API calls plus additional functions that are common to managing Skytap environments.
Usage
Install the module via NPM
npm install node-skytap
You can then include it as needed
var Skytap = ;
You can obtain your API token
var params = username: 'skytap_username' password: 'sktyap_password'; var token = Skytap
You should make calls using your token, though you can use the password if you so choose.
To obtain a new instance of the API Client, use the init
static function and include your username
and token
.
var skytap = Skytap
You can then use this instance to make calls to the API. Calls support both node callbacks and Promises.
// Using Node callbacksskytapprojects; // Using Promisesskytapprojects
Initializing Skytap API Client
The Skytap.init
method returns a new instance of the Skytap API Client based on the supplied connection information.
If you want to use different credentials per-request you can do so by creating a new instance of the client. For example, to list environments for different users, you can do the following:
// create an API client for user1var user1 = Skytap; // display environments for user1user1environments; var user2 = Skytap; // display environments for user2user2environments;
Skytap Version 2 Methods
You can make requests to Skytap API Version 2 by specifying the version: 'v2'
options when initializing the client.
var skytap = Skytap;
At the time of this change GET requests for many of the APIs are successful. POST/PUT/DELETE calls will result in an error. To use by V1 and V2 simulaneously, you will need to create multiple Skytap API Client instances and make your calls accordingly.
API Reference
Refer to the source code for a full list of function calls and required parameters. Some of the functionality is listed below with examples of usage.
Projects
// List Projects skytapprojects;skytapprojects; // Get a project by idskytapprojects; // Get templates in a projectskytapprojects; // Get environments in a projectskytapprojects; // Add environment to a projectskytapprojects; // Remove environment form a projectskytapprojects; // Add template to a projectskytapprojects; // Remove template from a projectskytapprojects;
Environments
// List environmentsskytapenvironments;skytapenvironments; // List all environments// Notes: this requires Administrator access and iterates over all users// USE WITH CAUTION!skytapenvironmentsallnext; // Get a specific environmentskytapenvironments; // Create an environment from a templateskytapenvironments; // Create an envirnoment from a configurationskytapenvironments; // Update an environmentskytapenvironments; // Delete an environmentskytapenvironments; // Start an environmentskytapenvironmentsstart configuration_id: 1234 next; // Stop an environmentskytapenvironments; // Suspend an environmentskytapenvironments; // Wait for environment statusskytapenvironments;skytapenvironments;skytapenvironments; // Get user_dataskytapenvironments; // Update user_dataskytapenvironments;
Templates
// List of templatesskytaptemplates;skytaptemplates; // List all templates// Notes: this requires Administrator access and iterates over all users// USE WITH CAUTION!skytaptemplatesallnext; // Get a specific templateskytaptemplates; // Create a template from an environmentskytaptemplates; // Update a templateskytaptemplates; // Delete a templateskytaptemplates;
VMs
// Get a VMskytapvms;skytapvms; // Update a VMskytapvms;skytapvms; // Deletes a VMskytapvms;skytapvms; // Get user_dataskytapvms;skytapvms; // Update user_dataskytapvms;skytapvms;
VPNs
// List VPNsskytapvpns;skytapvpns; // Get a VPNskytapvpns; // Attach a VPN to a network on a configurationskytapvpns; // Detach a VPN from a network on a configurationskytapvpns; // Connect a VPN on a network on a configurationskytapvpns; // Disconnect a VPN on a network on a configurationskytapvpns;
Users
// List all accessible usersskytapusers;skytapusers; // Get a userskytapusers;
Usage Reports
// Create a reportskytapusage; // Check a report statusskytapusage; // Retrieve report resultsskytapusage;
Audit Reports
// Create a reportskytapusage; // Check a report statusskytapusage; // Retrieve report resultsskytapusage;
Additional Parameters
Parameters to an API call that aren't recognized will be added to the query string. One use of this is to query an environment without changing its idle time:
environments.get({ configuration_id: 1234, keep_idle: true }
List methods support optional arguments that can be passed. For example, when using the v2 API calls to you can scope requests to the company and apply paging by doing the following:
environments.list({ scope: 'company', offset: 0, count: 100 }, next);
Contributing
Formatting uses spaces instead of tabs and 2-space tabs.
Please use JSHint via the grunt task grunt validate
.
Please add proper unit test coverage in accordance with existing test patterns (API methods do not yet have test coverage or parameter validation).
Change Log
0.7.0
- Adds support for audit report generation/retrieval
0.6.0
- Adds support for report generation/retrieval
0.5.0
- Adds optional option argument to list functions
0.4.1
- Fixes
vms.del
- Fixes
environments.all
promise usage - Added testing to cover api calls
- Additional uri cleanup for
0.4.0
- Added support for list/get of users
- Added support for retrieving all accessible environments and templates
0.3.0
- Added support for V2 API calls
0.2.0
- Added template list/get/create/update/delete
- Added add/remote template from project
0.1.3
- Moved repository to fti-technology
0.1.2
- Added VPN connect/disconnect/attach support
- Added user_data support for environments and vms
- Updated code examples
0.1.1
- Added start/stop/suspend helpers for environments
0.1.0
- Initial release