Node-Octane
A Node.js wrapper for the HPE ALM Octane API.
Installation
Install via git clone
$ git clone https://github.com/HPSoftware/alm-octane-js-rest-sdk.git$ cd node-octane$ npm install
Example
var Octane = var octane = protocol: "https" host: <HOST> port: <PORT> shared_space_id: <SHARED_SPACE_ID> workspace_id: <WORKSPACE_ID> octane
Authentication
The Octane API allows to sign in with user credential or API key.
// user credentialoctane // API keyoctane
Query
The Octane REST API supports entities query by filtering values of fields. To filter, use a query statement, which is comprised of at least one query phase.
The client API provides the Query module to help you build the query, rather than writing the complex query statement.
var Query = // query statement: "id EQ 1005"var query = Queryoctanedefects ... // query statement: "name EQ ^test*^" var query = Query // query statement: "user_tags EQ {id EQ 1001}"var query = Query // query statement: "user_tags EQ {id EQ 1001||id EQ 2005}"var query = Query// or use the shorthand or() methodvar query = Query // query statement: "user_tags EQ {id EQ 1001;id EQ 3008}"var query = Query// or use the shorthand and() methodvar query = Query // query statement: "user_tags EQ {id EQ 1001};user_tags EQ {id EQ 3008}"var query = Query// or use the shorthand and() methodvar query = Query// or use the sub queryvar query1 = Queryvar query2 = Queryvar query = query1
Attachment
To create an attachment, you must provide the file's absolute path.
...var attachment = name: 'attachment.txt' file: attachmentFile // the file's absolute path owner_work_item: anWorkItemoctaneattachments...
The attachment has both entity data and binary data.
To get the attachment's entity data, call attachments.get()
; to get its binary data, call attachments.download()
.
...octaneattachments octaneattachments...
Documentation
Client API: https://pages.github.hpe.com/ALMOctane-Hackathon/node-octane/
Update client API
The HPE ALM Octane REST API is fully metadata-driven. When the Octane REST API is updated, you can update the client API from the metadata.
Create octane.json
file for updating client API. It defines the Octane server's configuration and user credential.
$ cat > octane.json << EOHEOH $ node scripts/generate_default_routes.js
The client API is defined in
routes/default.json
file. When you run this script to update the client API, you actually update theroutes/default.json
file.
The
routes/meta.json
file defines the minimal client API. It can't be changed or deleted.
Update client API documentation
When the routes/default.json
file is updated, you'll want to update API annotation file:
$ mkdir -p doc$ node scripts/generate_api_annotations.js
Then you can create the client API documentation:
$ npm install apidoc$ node_modules/.bin/apidoc -f doc/apidoc.js -o apidoc/
Tests
Run all tests
$ npm test
Or run a specific test
$ npm test test/query.js
The octane.json
file is required for running the integration tests. If it doesn't exist, the integration tests will be skipped.
$ cat > octane.json << EOHEOH npm test test/integration