hew

Interface to the HP Cloud API (unofficial)

Hew

Hew provides a Node.js API for HP Cloud.

Hew API Documentation is at: http://natesilva.github.io/hew/docs/#!/api

The Hew Github repository is at: https://github.com/natesilva/hew

Currently Hew supports a subset of the HP Cloud API:

  • Authentication Tokens
  • Messaging
  • DNS
  • Object Storage
  • CDN (partial)
  • Identity (partial)
npm install hew

Example showing use of the Messaging module:

var Hew = require('hew');
 
var yourRegion = Hew.AuthToken.DEFAULT_REGION;
var yourAccessKey = '';
var yourSecretKey = '';
var yourTenantName = '';
var qname = 'my-test-message-queue';
 
// obtain an authentication token 
var token = new Hew.AuthToken(yourRegion, yourAccessKey, yourSecretKey,
  yourTenantName);
 
// create the Messaging controller 
var messaging = new Hew.Messaging(token);
 
// create a test queue 
messaging.createQueue(qname, function(err) {
  if (err) { return console.error(err); }
  console.log('test queue created');
 
  // send a message 
  var message = { location: 'Palo Alto', temperature: 22, units: 'C' };
  messaging.send(qname, message, function(errmessageId) {
    if (err) { return console.error(err); }
    console.log('message was posted, with ID', messageId);
 
    // receive a message 
    messaging.receive(qname, function(errmessage) {
      if (err) { return console.error(err); }
      console.log('message received:', message.body);
      // prints: { location: 'Palo Alto', temperature: 22, units: 'C' } 
 
      // delete the test queue 
      messaging.deleteQueue(qname, function(err) {
        if (err) { return console.error(err); }
        console.log('test queue deleted');
      });
    });
  });
});

Warning: Do not run unit tests against your production HP Cloud account. Testing will create, update and delete resources in your account, including very large files for testing object storage.

To run unit tests:

  1. Check out the Hew git repo.
  2. Create tests/config.json (an example is provided).
  3. Add the following key to tests/config.json:
    • "i-created-this-account-for-testing-only": true
  4. From the the top of the repo, run npm install.
  5. From the the top of the repo, run npm test.