Skip to content

Commit

Permalink
Merge a2a76f2 into 9bbf8a3
Browse files Browse the repository at this point in the history
  • Loading branch information
ycombinator committed Jan 6, 2015
2 parents 9bbf8a3 + a2a76f2 commit d93ae2e
Show file tree
Hide file tree
Showing 25 changed files with 1,761 additions and 3 deletions.
53 changes: 52 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pkgcloud is a standard library for node.js that abstracts away differences among
* [Load Balancers](#load-balancers----beta) *(beta)*
* [Orchestration](#orchestration----beta) *(beta)*
* [Network](#network----beta) *(beta)*
* [CDN](#cdn----beta) *(beta)*
* _Fine Print_
* [Installation](#installation)
* [Tests](#tests)
Expand All @@ -33,7 +34,7 @@ You can install `pkgcloud` via `npm` or add to it to [dependencies](https://npmj
npm install pkgcloud
```

Currently there are six service types which are handled by pkgcloud:
Currently there are nine service types which are handled by pkgcloud:

* [Compute](#compute)
* [Storage](#storage)
Expand All @@ -43,6 +44,7 @@ Currently there are six service types which are handled by pkgcloud:
* [Load Balancers](#load-balancers----beta) *(beta)*
* [Network](#network----beta) *(beta)*
* [Orchestration](#orchestration----beta) *(beta)*
* [CDN](#cdn----beta) *(beta)*

In our [Roadmap](#roadmap), we plan to add support for more services, such as Queueing, Monitoring, and more. Additionally, we plan to implement more providers for the *beta* services, thus moving them out of *beta*.

Expand Down Expand Up @@ -131,6 +133,9 @@ If a service does not have at least two providers, it is considered a *beta* int
* [HP](docs/providers/hp/network.md)
* [Openstack](docs/providers/openstack/network.md)
* [Rackspace](docs/providers/rackspace/network.md)
* **[CDN](#cdn----beta)**
* [Openstack](docs/providers/openstack/cdn.md)
* [Rackspace](docs/providers/rackspace/cdn.md)

## Compute

Expand Down Expand Up @@ -528,6 +533,52 @@ Each instance of `pkgcloud.orchestration.Client` returned from `pkgcloud.orchest
### Templates
* `client.validateTemplate(template, function (err, template) { })`

## CDN -- Beta

##### Note: CDN is considered Beta until there are multiple providers; presently only Openstack and Rackspace are supported.

The `pkgcloud.cdn` service is designed to allow you to access Openstack Poppy via node.js. You can manage services and flavors from within any node.js application.

To get started with a `pkgcloud.cdn` client just create one:

``` js
var client = require('pkgcloud').cdn.createClient({
//
// The name of the provider (e.g. "openstack")
//
provider: 'provider-name',

//
// ... Provider specific credentials
//
});
```

#### Providers

* [Openstack](docs/providers/openstack/cdn.md)
* [Rackspace](docs/providers/rackspace/cdn.md)

Each instance of `pkgcloud.cdn.Client` returned from `pkgcloud.cdn.createClient` has a set of uniform APIs:

### Base
* `client.getHomeDocument(function (err, homeDocument) { })`
* `client.getPing(function (err) { })`

### Service
* `client.getService(service, function (err, service) { })`
* `client.getServices(options, function (err, services) { })`
* `client.createService(details, function (err, service) { })`
* `client.updateService(service, function (err, service) { })`
* `client.deleteService(service, function (err) { })`

### Service Assets
* `client.deleteServiceCachedAssets(service, assetUrl, function(err) { })`

### Flavors
* `client.getFlavor(flavor, function (err, flavor) { })`
* `client.getFlavors(options, function (err, flavors) { })`

## Installation

``` bash
Expand Down
92 changes: 92 additions & 0 deletions docs/providers/openstack/cdn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
##Using the Openstack CDN provider

Creating a client is straight-forward:

``` js
var openstack = pkgcloud.cdn.createClient({
provider: 'openstack', // required
username: 'your-user-name', // required
password: 'your-password', // required
authUrl: 'your identity service url' // required
});
```

[More options for creating clients](README.md)

### API Methods

## Base

#### `client.getHomeDocument(function (err, homeDocument) { })`
Retrieves the home document, which allows you to navigate the remainder of the
API. Callback is `f(err, homeDocument)` where `homeDocument` is an `Object`.

#### `client.getPing(function (err) { })`
Pings the server for any errors. Callback is `f(err)`.

## Services

#### client.createService(options, callback)
Creates a service with the options specified.

Options are as follows:

```js
{
name: 'my-service-name', // name of service, required
domains: [ ... ], // list of domains for service, required
origins: [ ... ], // list of origins for service, required
caching: [ ... ], // list of caching rules for service, optional
restrictions: [ ... ], // list of restrictions on where service can be accessed from, optional
flavorId: 'cdn' // ID of CDN flavor to use, required
}
```
Callback is `f(err, service)`, where `service` is the created service.

#### client.getServices([options], callback)

Lists all created services. Callback is `f(err, services)` where `services`
is an `Array`.

#### client.getService(service, callback)

Retrieve the created service for the provided service or serviceName. Callback is `f(err,
service)`.

#### client.updateService(service, callback)

Update the provided service.

The following values from the provided service are updatable.

```js
{
name: 'my-service-name', // name of service, required
domains: [ ... ], // list of domains for service, required
origins: [ ... ], // list of origins for service, required
flavorId: 'cdn' // ID of CDN flavor to use, required
}
```

#### client.deleteService(service, callback)

Delete the created service. Callback is `f(err)`.

## Service Assets

#### client.deleteServiceCachedAssets(service, assetUrl, callback)

Purge the service's cached asset (if `assetUrl` is specified) or all cached
assets (if `assetUrl` is not specified). Callback is `f(err)`.

## Flavors

#### client.getFlavors(options, callback)

Lists all available CDN flavors. Callback is `f(err, flavors)` where
`flavors` is an Array.

#### client.getFlavor(flavor, callback)

Retrieve the CDN flavor for a provided flavor or flavorId. Callback is `f(err,
flavor)`.
92 changes: 92 additions & 0 deletions docs/providers/rackspace/cdn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
##Using the Rackspace CDN provider

Creating a client is straight-forward:

``` js
var rackspace = pkgcloud.cdn.createClient({
provider: 'rackspace', // required
username: 'your-user-name', // required
password: 'your-password', // required
authUrl: 'your identity service url' // required
});
```

[More options for creating clients](README.md)

### API Methods

## Base

#### `client.getHomeDocument(function (err, homeDocument) { })`
Retrieves the home document, which allows you to navigate the remainder of the
API. Callback is `f(err, homeDocument)` where `homeDocument` is an `Object`.

#### `client.getPing(function (err) { })`
Pings the server for any errors. Callback is `f(err)`.

## Services

#### client.createService(options, callback)
Creates a service with the options specified.

Options are as follows:

```js
{
name: 'my-service-name', // name of service, required
domains: [ ... ], // list of domains for service, required
origins: [ ... ], // list of origins for service, required
caching: [ ... ], // list of caching rules for service, optional
restrictions: [ ... ], // list of restrictions on where service can be accessed from, optional
flavorId: 'cdn' // ID of CDN flavor to use, required
}
```
Callback is `f(err, service)`, where `service` is the created service.

#### client.getServices([options], callback)

Lists all created services. Callback is `f(err, services)` where `services`
is an `Array`.

#### client.getService(service, callback)

Retrieve the created service for the provided service or serviceName. Callback is `f(err,
service)`.

#### client.updateService(service, callback)

Update the provided service.

The following values from the provided service are updatable.

```js
{
name: 'my-service-name', // name of service, required
domains: [ ... ], // list of domains for service, required
origins: [ ... ], // list of origins for service, required
flavorId: 'cdn' // ID of CDN flavor to use, required
}
```

#### client.deleteService(service, callback)

Delete the created service. Callback is `f(err)`.

## Service Assets

#### client.deleteServiceCachedAssets(service, assetUrl, callback)

Purge the service's cached asset (if `assetUrl` is specified) or all cached
assets (if `assetUrl` is not specified). Callback is `f(err)`.

## Flavors

#### client.getFlavors(options, callback)

Lists all available CDN flavors. Callback is `f(err, flavors)` where
`flavors` is an Array.

#### client.getFlavor(flavor, callback)

Retrieve the CDN flavor for a provided flavor or flavorId. Callback is `f(err,
flavor)`.
53 changes: 53 additions & 0 deletions lib/pkgcloud/openstack/cdn/client/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* flavors.js: Instance methods for working with base resources from Openstack CDN
*
* (C) 2014 Rackspace
* Shaunak Kashyap
* MIT LICENSE
*/

/**
* client.getHomeDocument
*
* @description gets the home document for the CDN service
*
* @param callback
* @return {*}
*/
exports.getHomeDocument = function(callback) {
var requestOptions = {
path: '/'
};

return this._request(requestOptions, function (err, body) {
if (err) {
callback(err);
return;
}

callback(null, body);
});
};

/**
* client.getPing
*
* @description gets the server ping response (status response)
*
* @param callback
* @return {*}
*/
exports.getPing = function(callback) {
var requestOptions = {
path: '/ping'
};

return this._request(requestOptions, function (err) {
if (err) {
callback(err);
return;
}

callback();
});
};

0 comments on commit d93ae2e

Please sign in to comment.