mosaic-rest-js
About
This is a js library for Backbase REST API.
Example:
nodejs
var BBRest =var bbrest =portal: 'myPortal';
AMD module
// list portalsbbrest;// add portalbbrest;// update portalbbrest;// list 5 items from catalogbbrest;
Automation:
npm install // install nodejs dependencies
bower install // install bower dependecies
gulp node // build node distribution file
gulp jquery // build browser jQuery based ditribution file
gulp angular // build browser Angular based ditribution file
gulp min // minify browser distribution files
gulp test-node // run node tests (requires running portal)
gulp test-jq // run jQuery phantomjs tests (requires running portal)
gulp test-ng // run Angular phantomjs tests (requires running portal)
BBRest methods
constructor(config:Object)
BBRest Constructor.
- config - extends default configuration
configuration defaults:
scheme: 'http'host: 'localhost'port: '7777'context: 'portalserver'username: 'admin'password: 'admin'portal: null // name of the targeted portal,plugin: null // function to pre-process data
server()
Prepares request on server domain. API Reference
- returns instance of the BBReq
Valid Requests, returning promises:
bbrest; // returns list of portalsbbrest; // creates a portalbbrest; // updates portal(s)
portal()
Prepares request on portal domain. API Reference
- returns instance of the BBReq
Valid Requests, returning promises:
bbrest; // updates portalbbrest; // deletes the portalbbrest; // returns portal databbrest; // returns portal rightsbbrest; // updates portal rightsbbresttags; // returns portal tagsbbresttags; // creates a tagbbresttags'myTag'; // deletes a tag
catalog(item)
Prepares request on server catalog. API Reference
- item - name of the item in server catalog
- returns instance of the BBReq
Valid Requests, returning promises:
bbrest; // returns server catalogbbrest; // add item(s) to server catalogbbrest; // updates item(s) in server catalogbbrest; // batch delete items from the server catalogbbrest; // returns item from the server catalogbbrest; // deletes item from the server catalog
portalCatalog(item)
Prepares request on portal catalog. API Reference
- item - name of the item in porta catalog
- returns instance of the BBReq
Valid Requests, returning promises:
bbrest; // returns portal catalogbbrest; // add item(s) to portal catalogbbrest; // updates item(s) in portal catalogbbrest; // batch delete items from the portal catalogbbrest; // returns item from the portal catalogbbrest; // deletes item from the portal catalog
page(name:String)
Prepares page request. API Reference
- name - name of the page to target
- returns instance of the BBReq
Valid Requests, returning promises:
bbrest; // returns portal pagesbbrest; // creates page(s)bbrest; // updates page(s)bbrest; // returns pagebbrest; // updates pagebbrest; // deletes pagebbrest; // returns page rightsbbrest; // updates page rights
container(name:String)
Prepares container request. API Reference
- name - name of the container to target
- returns instance of the BBReq
Valid Requests, returning promises:
bbrest; // returns portal containersbbrest; // creates a container(s)bbrest; // updates container(s)bbrest; // returns containerbbrest; // updates containerbbrest; // deletes containerbbrest; // returns container rightsbbrest; // updates container rights
widget(name:String)
Prepares widget request. API Reference
- name - name of the widget to target
- returns instance of the BBReq
Valid Requests, returning promises:
bbrest; // returns portal widgetsbbrest; // creates a widget(s)bbrest; // updates widget(s)bbrest; // returns widgetbbrest; // updates widgetbbrest; // deletes widgetbbrest; // returns widget rightsbbrest; // updates widget rights
link(name:String)
Prepares link request. API Reference
- name - name of the link to target
- returns instance of the BBReq
Valid Requests, returning promises:
bbrestlink; // returns portal linksbbrestlink; // creates link(s)bbrestlink; // updates link(s)bbrestlink'name'; // returns linkbbrestlink'name'; // updates linkbbrestlink'name'; // deletes linkbbrestlink'name'; // returns link rightsbbrestlink'name'; // updates link rights
template(name:String)
Prepares template request. API Reference
- name - name of the template to target
- returns instance of the BBReq
Valid Requests, returning promises:
bbrest; // returns portal templatesbbrest; // creates template(s)bbrest; // returns templatebbrest; // updates templatebbrest; // returns template rightsbbrest; // updates template rights
user(name:String, showGroups:Boolean, groupName:String)
Prepares user request. API Reference
- name - name of the user to target
- showGroups - if true, user groups are targeted
- groupName - name of the group to delete user from
- returns instance of the BBReq
Valid Requests, returning promises:
bbrest; // returns list of usersbbrest; // creates a userbbrest; // returns userbbrest; // updates userbbrest; // deletes userbbrest; // returns groups that user belongs tobbrest; // adds user to group(s)bbrest; // removes user from a group
group(name:String, showUsers:Boolean)
Prepares group request. API Reference
- name - name of the group to target
- showUsers - if true, group's users are targeted
- returns instance of the BBReq
Valid Requests, returning promises:
bbrest; // returns list of groupsbbrest; // creates a groupbbrest; // returns groupbbrest; // updates groupbbrest; // deletes groupbbrest; // returns users that belong to a groupbbrest; // adds user(s) to groupbbrest; // removes user from a group
audit(meta:Boolean)
Prepares audit trails request. API Reference
- meta - if true, targets audit metadat, otherwise it targets audit events
- returns instance of the BBReq
Valid Requests, returning promises:
bbrest; // returns auditEventsbbrest; // returns auditMetaData
cache(type:String)
Prepares cache request. API Reference
- type - possible values: global, widget, chrome, closure, url, web, gmodel
- returns instance of the BBReq
Valid Requests, returning promises:
bbrest; // sends all of the below requests one by onebbrest;bbrest;bbrest;bbrest;bbrest;bbrest;bbrest;bbrest;bbrest;bbrest;bbrest;bbrest;bbrest;bbrest;bbrest;bbrest;
You can get bookmarklet to delete all caches at once.
auto(data)
Performs POST or PUT request by finding the right BBRest method from the data.
- data - if string, represents path of the xml file which content will be sent. If object, it is first sent to config.plugin function
- returns promise with response value
Valid Request, returning promises:
bbrest;
import()
Imports portal. API Reference
- returns instance of the BBReq
Valid Requests, returning promises:
bbrest; // imports xmlbbrest; // uploads and imports zip archive
export(uuid:String)
Exports portal. API Reference
- uuid - id of the exported file on the server. Use when you need to download file
- returns instance of the BBReq
To get archive of the portal from the server, you need to make 2 requests. In first one, we send type of export and get back the id of exported archive in response. With second request we pass that id and local path where archive will be downloaded.
Valid Requests, returning promises:
// export as xml in responsebbrest;// prepare file exportbbrest// data is xml or js object if plugin is usedvar id = databodyexportResponseidentifier; // get id of the archivereturn bbrest; // returns promise
BBReq methods
rights()
Modifies request to target rights.
- returns instance of the BBReq
tag(name:String)
Modifies request to target tags
- returns instance of the BBReq
query(obj:Object)
Defines modifiers. API Reference
- obj - object with querystring values to be appended to the uri
- returns instance of the BBReq
file(path:String)
Defines path to the file where export is downloaded.
- returns instance of the BBReq
get()
Performs GET request
- returns promise with response value
post(data)
Performs POST request
- data - if string, represents path of the xml file which content will be sent. If object, it is first sent to config.plugin function
- returns promise with response value
bbrestconfig {return jxon; // converts js object in jxon notation to XML string which will be posted}bbrest;
put(data)
Performs PUT request
- data - if string, represents path of the xml file which content will be sent. If object, it is first sent to config.plugin function
- returns promise with response value
delete(data)
Performs DELETE request
- data - if string, represents path of the xml file which content will be sent. If object, it is first sent to config.plugin function
- returns promise with response value
response value:
error: // true if is errorstatusCode: // http status codestatusInfo: // http status code description or error inforbody: // contains body of the server response,href: // request location,method: // request method,reqBody: // request body,file: // file name,headers: // response headers