-
Notifications
You must be signed in to change notification settings - Fork 1
API client integration notes
Casey Flynn edited this page Jun 17, 2014
·
1 revision
api branch builds Build List Page - /anandkumar/filibuster/master - has a listing of builds for an environment API: fetch the project - user.fetchProjects by username and project name get the env - API: var project = project.fetchProject(function () { var envData = project.toJSON().environments.filter(hasProps({name:'master'}))[0]; var environment = project.newEnvironment(envData); x = new Environment(); var builds = environment.fetchBuilds(function () { builds.models // are build models }) }); Build Page - /anandkumar/filibuster/master/build/:id - most complex page - you can edit build files and create new builds - you can rebuild - create a new build from a build - shows logs if in progress, shows all logs if complete - [launch instance button] API: var project = project.fetchProject(function () { var envData = project.toJSON().environments.filter(hasProps({name:'master'}))[0]; var environment = project.newEnvironment(envData); x = new Environment(); var build = environment.fetchBuild(urlParam.buildId, function (err, body) { var rootDirFiles = build.fetchFiles({ Prefix: '/' }, function () { }); // var dockerfile = build.fetchFile('/Dockerfile', function () { // }); }); }); [launch instance] - button var instance = user.createInstance({ build: buildId }, function (err) { window.location = '/instances/'+instance.id(); }); Instance Page - /instances/:id (just like our current container pages except supports multiple containers (full instance)) - create an instance from a build (create containers for all build images (versions)) API: var instance = user.fetchInstance(userParam.instanceId, function () { var build = environment.fetchBuild(urlParam.buildId, function (err, body) { // ask bryan abt the format if this is wrong~~ var rootDirFiles = build.fetchFiles({ Prefix: '/' }, function () { // [checkout dockerfile schema below..] // listings do not have file content // lazy load nested dirs // lazy load content (see below) // when you click on a file build.fetchFile(path, cb); // will fetch the content for the file { Key:'/Dockerfile', Content'FROM ubuntu', Prefix:'/' ?isDir? } file.update({ Content:'new content' }, function (err) { // handle errors }); }); }); var containers = instance.fetchContainers(function () { // probably want to use a async each or soemthing var container = containers[0]; // technically these only have one.. for now var rootDirFiles = container.fetchFiles({ path: '/' }, function () { // [{ name:'server.js', content:'hello', path:'/', isDir: false }] var file = rootDirFiles.models[0]; file.update({content:'new content'}, function (err) { // handle errors }); }) }); }); // Casey suggest how we should store what tabs are open ////// model.fetch() // internally model.attrs = body model.attrs.something = { foo:'bar' }; project.attrs.environment = { }