A wrapper around Yast.com API.
All library methods returns a Promise.
yast.auth.login(username, password)
yast.user.info(credentials) yast.user.updatePassword(credentials, newPassword)
yast.settings.list(credentials) yast.settings.update(credentials, settingName, settingValue)
yast.records.add(credentials, record) yast.records.update(credentials, record) yast.records.remove(credentials, id) yast.records.search(credentials, params) yast.records.types(credentials)
yast.projects.add(credentials, project) yast.projects.update(credentials, project) yast.projects.remove(credentials, id) yast.projects.list(credentials)
yast.folders.add(credentials, folder) yast.folders.update(credentials, folder) yast.folders.remove(credentials, id) yast.folders.list(credentials)
var yast = require('yast-lib');
// Log in
var user = "username";
var password = "password"
yast.login(username, password).then(function(response){
var credentials = {
user: user,
hash: response.hash
}
// Print name of user
yast.user.info(credentials)
.then(function(info){
console.log("Hi, my name is " + info.name);
});
// Add new project to first folder found
yast.folders.list(credentials)
.then(function(folders){
return folders[0]; // take first folder
})
.then(function(firstFolder){
var newProject = {
parentId: firstFolder.id
name: "My new project"
};
return yast.projects.add(newProject)
}).then(function(project){
console.log("Created new project " + newProject.name);
});
});