pkgcloud
pkgcloud is a standard library for node.js that abstracts away differences among multiple cloud providers.
Getting Started
Currently there are three service types which are handled by pkgcloud:
In our Roadmap, we plan to add support for DNS and CDN services, but these are not currently available.
Basic APIs for pkgcloud
Services provided by pkgcloud
are exposed in two ways:
- By service type: For example, if you wanted to create an API client to communicate with a compute service you could simply:
var client = require('pkgcloud').compute.createClient({
provider: 'provider-name',
});
- By provider name: For example, if you knew the name of the provider you wished to communicate with you could do so directly:
var client = require('pkgcloud').providers.joyent.compute.createClient({
});
All API clients exposed by pkgcloud
can be instantiated through pkgcloud[serviceType].createClient({ ... })
or pkcloud.providers[provider][serviceType].createClient({ ... })
.
Unified Vocabulary
Due to the differences between the vocabulary for each service provider, pkgcloud uses its own unified vocabulary.
Supported APIs
Supporting every API for every cloud service provider in Node.js is a huge undertaking, but that is the long-term goal of pkgcloud
. Special attention has been made to ensure that each service type has enough providers for a critical mass of portability between providers (i.e. Each service implemented has multiple providers).
Compute
The pkgcloud.compute
service is designed to make it easy to provision and work with VMs. To get started with a pkgcloud.compute
client just create one:
var client = require('pkgcloud').compute.createClient({
provider: 'provider-name',
});
Each compute provider takes different credentials to authenticate; these details about each specific provider can be found below:
Each instance of pkgcloud.compute.Client
returned from pkgcloud.compute.createClient
has a set of uniform APIs:
Server
client.getServers(function (err, servers) { })
client.createServer(options, function (err, server) { })
client.destroyServer(serverId, function (err, server) { })
client.getServer(serverId, function (err, server) { })
client.rebootServer(server, function (err, server) { })
Image
client.getImages(function (err, images) { })
client.getImage(imageId, function (err, image) { })
client.destroyImage(image, function (err, ok) { })
client.createImage(options, function (err, image) { })
Flavor
client.getFlavors(function (err, flavors) { })
client.getFlavor(flavorId, function (err, flavor) { })
Storage
The pkgcloud.storage
service is designed to make it easy to upload and download files to various infrastructure providers. Special attention has been paid so that methods are streams and pipe-capable.
To get started with a pkgcloud.storage
client just create one:
var client = require('pkgcloud').compute.createClient({
provider: 'provider-name',
});
Each compute provider takes different credentials to authenticate; these details about each specific provider can be found below:
Each instance of pkgcloud.storage.Client
returned from pkgcloud.storage.createClient
has a set of uniform APIs:
Container
client.getContainers(function (err, containers) { })
client.createContainer(options, function (err, container) { })
client.destroyContainer(containerName, function (err) { })
client.getContainer(containerName, function (err, container) { })
File
client.upload(options, function (err) { })
client.download(options, function (err) { })
client.getFiles(container, function (err, files) { })
client.getFile(container, file, function (err, server) { })
client.removeFile(container, file, function (err) { })
Both the .upload(options)
and .download(options)
have had careful attention paid to make sure they are pipe and stream capable:
Upload a File
var pkgcloud = require('pkgcloud'),
fs = require('fs');
var client = pkgcloud.storage.createClient({ });
fs.createReadStream('a-file.txt').pipe(client.upload({
container: 'a-container',
remote: 'remote-file-name.txt'
}));
Download a File
var pkgcloud = require('pkgcloud'),
fs = require('fs');
var client = pkgcloud.storage.createClient({ });
client.download({
container: 'a-container',
remote: 'remote-file-name.txt'
}).pipe(fs.createWriteStream('a-file.txt'));
Databases
The pkgcloud.database
service is designed to consistently work with a variety of Database-as-a-Service (DBaaS) providers.
To get started with a pkgcloud.storage
client just create one:
var client = require('pkgcloud').database.createClient({
provider: 'provider-name',
});
Each database provider takes different credentials to authenticate; these details about each specific provider can be found below:
- CouchDB
- MongoDB
- Redis
- MySQL
Due to the various differences in how these DBaaS providers provision databases only a small surface area of the API for instances of pkgcloud.database.Client
returned from pkgcloud.database.createClient
is consistent across all providers:
client.create(options, callback)
All of the individual methods are documented for each DBaaS provider listed above.
Installation
$ npm install pkgcloud
Tests
For run the tests you will need vows@0.7.0
or higher, please install it and then run:
$ npm test
Contribute!
We welcome contribution to pkgcloud
by any and all individuals or organizations. Before contributing please take a look at the Contribution Guidelines in CONTRIBUTING.md.
We are pretty flexible about these guidelines, but the closer you follow them the more likely we are to merge your pull-request.
Roadmap
- Backport latest fixes from
node-cloudfiles
and node-cloudservers
- Include
CDN
and DNS
services. - Implement
fs
compatible file API. - Support additional service providers.
License: MIT