0.0.6 • Published 8 years ago

appc-registry-sdk v0.0.6

Weekly downloads
11
License
LicenseRef-LICENS...
Repository
github
Last release
8 years ago

Appcelerator Registry SDK for Node.js

This is a node module which provides a JavaScript API for accessing the Appcelerator Registry.

Build Status

Installation

You can install via npm or directly include the library in your node application.

Once installed, you can use the module by requiring it.

NOTE: You must set the baseurl to the correct URL location of the server endpoint.

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';

Security

To enable, you must first login using the API login. After a successful login, you must call API.session = result.session where result is the return value from the login API call.

Example code:

var api = new API("login");
API.baseurl = "http://localhost:8080";
api.body({"username":"foo@bar.com","password":"arrowrocks"});
api.send(function(err,resp,body){
	if (err) { throw err; }
	API.session = body.session;
	api = new API("whoami");
	api.send(function(err,resp,body){
		if (err) { throw err; }
		console.log(body);
	});
});

APIs

login

API for login

POST /api/login

API Parameters

NameDescriptionTypeOptional
usernameusernamebodyyes
passwordpasswordbodyyes
org_idorganization idbodyyes
ipaddressthe machine ip addressbodyyes
fingerprintthe machine unique idbodyyes
fingerprint_descriptionthe machine descriptionbodyyes

API Result session

NameDescriptionType
usernameusernamestring
passwordpasswordstring
org_idorganization idnumber
org_nameorganization namestring
sessionencrypted session tokenstring
ipaddressthe machine ip addressstring
fingerprintthe machine unique idstring
fingerprint_descriptionthe machine descriptionstring
expiryexpiration timestamp in millisecondsnumber
firstnamefirst name of the userstring
lastnamelast name of the userstring
sidsession sidstring
dashboarddashboard url used for sessionstring

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('login');
api.body({
	"username": "",
	"password": "",
	"org_id": "",
	"ipaddress": "",
	"fingerprint": "",
	"fingerprint_description": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

listOrganizations

API for determing the logged in user organizations

GET /api/orgs

API Result org

NameDescriptionType
org_idthe organization guidnumber
namethe name of the organizationstring
activethe active flag for the organizationboolean

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('listOrganizations');
api.send(function(err,resp,json){
	console.log(json);
});

switchLoggedInOrg

API for switching a logged in user org

PUT /api/org

API Parameters

NameDescriptionTypeOptional
org_idthe organization idbodyno

API Result org

NameDescriptionType
org_idthe organization guidnumber
namethe name of the organizationstring
activethe active flag for the organizationboolean

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('switchLoggedInOrg');
api.body({
	"org_id": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

whoami

API for determing the logged in user

GET /api/whoami

API Result session

NameDescriptionType
usernameusernamestring
passwordpasswordstring
org_idorganization idnumber
org_nameorganization namestring
sessionencrypted session tokenstring
ipaddressthe machine ip addressstring
fingerprintthe machine unique idstring
fingerprint_descriptionthe machine descriptionstring
expiryexpiration timestamp in millisecondsnumber
firstnamefirst name of the userstring
lastnamelast name of the userstring
sidsession sidstring
dashboarddashboard url used for sessionstring

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('whoami');
api.send(function(err,resp,json){
	console.log(json);
});

listComponents

API for fetching all the components

GET /api/component

API Parameters

NameDescriptionTypeOptional
limitmax number of components to returnqueryyes

API Result component

NameDescriptionType
created_datedate the component was publisheddate
file_idforeign key to the file objectstring
filesizethe component file sizenumber
parts_countthe component count in the case of split filesnumber
parts_indexthe component index in the case of split filesnumber
parts_totalthe component total size in the case of split filesnumber
parts_shasumthe component sha of the part in the case of split filesnumber
shasumthe component sha1string
namethe name of the componentstring
componentthe full component namestring
descriptionthe description of the componentstring
versionthe version of the componentstring
version_sortablethe field that is used for sorting by versionnumber
typethe metadata type of the componentstring
subtypethe component plugin subtypestring
ownersthe owners of the componentarray
orgsthe orgs of the componentarray
usersthe users of the componentarray
accessthe access type such as private, public, etcstring
authorthe component author namestring
author_idthe component author user guidstring
author_usernamethe component author usernamestring
unpublishedreturn true if the component has been unpublishedboolean
package_jsonthe contents of the package.jsonstring

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('listComponents');
api.json({
	"limit": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

getComponent

API for fetching all the components

GET /api/component/:type/:nameversion

API Parameters

NameDescriptionTypeOptional
typetype of the component to get the detailspathno
nameversionname and version of the component to get the detailspathno

API Result component

NameDescriptionType
created_datedate the component was publisheddate
file_idforeign key to the file objectstring
filesizethe component file sizenumber
parts_countthe component count in the case of split filesnumber
parts_indexthe component index in the case of split filesnumber
parts_totalthe component total size in the case of split filesnumber
parts_shasumthe component sha of the part in the case of split filesnumber
shasumthe component sha1string
namethe name of the componentstring
componentthe full component namestring
descriptionthe description of the componentstring
versionthe version of the componentstring
version_sortablethe field that is used for sorting by versionnumber
typethe metadata type of the componentstring
subtypethe component plugin subtypestring
ownersthe owners of the componentarray
orgsthe orgs of the componentarray
usersthe users of the componentarray
accessthe access type such as private, public, etcstring
authorthe component author namestring
author_idthe component author user guidstring
author_usernamethe component author usernamestring
unpublishedreturn true if the component has been unpublishedboolean
package_jsonthe contents of the package.jsonstring

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('getComponent');
api.params({
	"type": "",
	"nameversion": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

plugins

API for listing plugins

GET /api/plugin/:type/:subtype

API Parameters

NameDescriptionTypeOptional
typethe type of componentpathno
subtypethe subtype of the pluginpathno

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('plugins');
api.params({
	"type": "",
	"subtype": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

publish

API for publishing a component

POST /api/publish

API Parameters

NameDescriptionTypeOptional
filefile to publishbodyno
package.jsoncontents of the package.jsonbodyno
parts_countthe component count in the case of split filesbodyyes
parts_indexthe component index in the case of split filesbodyyes
parts_totalthe component total in the case of split filesbodyyes
parts_shasumthe component sha of the part in the case of split filesbodyyes
shasumthe component sha1bodyno
forceoverwrite if already published with the same versionbodyyes
subtypethe subtype of the componentbodyyes

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('publish');
api.body({
	"file": "",
	"package.json": "",
	"parts_count": "",
	"parts_index": "",
	"parts_total": "",
	"parts_shasum": "",
	"shasum": "",
	"force": "",
	"subtype": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

search

API for searching for components

GET /api/search/:term/:filter?

API Parameters

NameDescriptionTypeOptional
termthe search termpathno
filterthe search term filterpathyes

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('search');
api.params({
	"term": "",
	"filter": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

unpublish

API for unpublishing a published component

GET /api/unpublish/:type/:name/:version

API Parameters

NameDescriptionTypeOptional
typetype of the componentpathno
namename of the componentpathno
versionversion of the componentpathno

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('unpublish');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

getAccess

API for getting component access level

GET /api/access/:type/:name/:version

API Parameters

NameDescriptionTypeOptional
typethe type of the componentpathno
namethe name of the componentpathno
versionthe version of the componentpathno

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('getAccess');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

setAccess

API for setting component access level

PUT /api/access/:type/:name/:version

API Parameters

NameDescriptionTypeOptional
typethe type of the componentpathno
namethe name of the componentpathno
versionthe version of the componentpathno
accessthe access of the componentbodyno

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('setAccess');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.body({
	"access": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

getAppc

API for listing the AppC packages

GET /api/appc/install/:version?

API Parameters

NameDescriptionTypeOptional
versionthe version of the packagepathyes

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('getAppc');
api.params({
	"version": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

listAppc

API for listing the AppC packages

GET /api/appc/list

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('listAppc');
api.send(function(err,resp,json){
	console.log(json);
});

installs

API for getting a list of components locations to install

GET /api/install

API Parameters

NameDescriptionTypeOptional
componentscomponents to installbodyno

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('installs');
api.body({
	"components": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

install

API for installing a specific component

GET /api/install/:token

API Parameters

NameDescriptionTypeOptional
tokenthe one-time install tokenpathno

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('install');
api.params({
	"token": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

addOrg

API for adding an org for a component

POST /api/org/:type/:name/:version

API Parameters

NameDescriptionTypeOptional
typethe type of the componentpathno
namethe name of the componentpathno
versionthe version of the componentpathno
org_idthe org_id to addbodyno

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('addOrg');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.body({
	"org_id": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

deleteOrg

API for removing an org from a component

DELETE /api/org/:type/:name/:version

API Parameters

NameDescriptionTypeOptional
typethe type of the componentpathno
namethe name of the componentpathno
versionthe version of the componentpathno
org_idthe org_id to removebodyno

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('deleteOrg');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.body({
	"org_id": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

getOrg

API for getting the orgs for a component

GET /api/org/:type/:name/:version

API Parameters

NameDescriptionTypeOptional
typethe type of the componentpathno
namethe name of the componentpathno
versionthe version of the componentpathno

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('getOrg');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

addOwner

API for adding an owner to a component

POST /api/owner/:type/:name/:version

API Parameters

NameDescriptionTypeOptional
typethe type of the componentpathno
namethe name of the componentpathno
versionthe version of the componentpathno
userthe user to addbodyno

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('addOwner');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.body({
	"user": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

deleteOwner

API for removing an owner of a component

DELETE /api/owner/:type/:name/:version

API Parameters

NameDescriptionTypeOptional
typethe type of the componentpathno
namethe name of the componentpathno
versionthe version of the componentpathno
userthe user to removebodyno

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('deleteOwner');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.body({
	"user": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

getOwner

API for getting the owners of a component

GET /api/owner/:type/:name/:version

API Parameters

NameDescriptionTypeOptional
typethe type of the componentpathno
namethe name of the componentpathno
versionthe version of the componentpathno

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('getOwner');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

addUser

API for adding a user to a component

POST /api/user/:type/:name/:version

API Parameters

NameDescriptionTypeOptional
typethe type of the componentpathno
namethe name of the componentpathno
versionthe version of the componentpathno
userthe user to addbodyno

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('addUser');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.body({
	"user": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

deleteUser

API for removing a user from a component

DELETE /api/user/:type/:name/:version

API Parameters

NameDescriptionTypeOptional
typethe type of the componentpathno
namethe name of the componentpathno
versionthe version of the componentpathno
userthe user to removebodyno

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('deleteUser');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.body({
	"user": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

getUser

API for getting users of a component

GET /api/user/:type/:name/:version

API Parameters

NameDescriptionTypeOptional
typethe type of the componentpathno
namethe name of the componentpathno
versionthe version of the componentpathno

Usage Example

var API = require('appc-registry-sdk');
API.baseurl = 'http://localhost:8080';
var api = new API('getUser');
api.params({
	"type": "",
	"name": "",
	"version": ""
});
api.send(function(err,resp,json){
	console.log(json);
});

Other SDK APIs

The following additional APIs are available:

API.baseurl

Set the base url for the Arrow server.

Usage Example

API.baseurl = 'http://localhost:8080';

api.json

Set the JSON body.

Usage Example

api.json({
	foo: true
});

api.body

Set the body. The body can include one or more files (provide a valid file path as the value) to automatically send multipart/form-data. To specify a file for uploading, pass an instance of a stream.Readable.

Usage Example

api.body({
	file: fs.createReadStream('/path/to/myfile.json'),
	name: 'this is a name'
});

api.query

Set query parameters for the URL. These will automatically be appended correctly to the request URL.

Usage Example

api.query({
	pretty_json: true
});

api.params

Set URL parameters in the request URL.

Usage Example

api.params({
	username: 'test'
});

api.header

Add an HTTP request headers.

Usage Example

api.header('X-Foo','Bar');

You can add multiple headers by chaining the methods:

api.header('X-Foo','Bar')
	.header('X-Bar','Foo');

API.debug

Turn on/off debug logging.

Usage Example

API.debug = false;

You can set either by passing debug in API constructor as part of the config object (first parameter) or by setting the environment variable DEBUG to arrow:sdk.

Usage Example

var api = new API({debug:true},'/api/login');
DEBUG=arrow:sdk node app

Events

The following events can also be listened to:

  • error: fired when an error occurs during an API request
  • response: fired when an API response is received
  • timeout: fired when an API request times out

Usage Example

var api = new API('myapi')
	.on('error',function(err){
		console.error("An error occurred.",err);
	})
	.on('timeout',function(err){
		console.error("A timeout occurred.",err);
	})
	.on('response',function(resp,json){
		console.log(json);
	})
	.send({
		username: 'foo',
		password: 'bar'
	});

Dependencies

To use this library, you must add an appropriate npm dependency for the request library. It can be any of the following compatible modules:

Add the appropriate request module to your package.json dependencies.

Notes

This SDK was generated using the Appcelerator Arrow SDK generator. Generated on Fri Feb 13 2015 08:41:07 GMT-0800 (PST) by jhaynie@appcelerator.com.

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago