balena-cli/lib/resin/models/device.coffee
2014-11-26 12:38:02 -04:00

24 lines
492 B
CoffeeScript

canvas = require('./_canvas')
_ = require('lodash')
Promise = require('bluebird')
errors = require('../errors/errors')
exports.getAll = (applicationId) ->
return canvas.get
resource: 'device'
options:
filter:
application: applicationId
expand: 'application'
orderby: 'name asc'
.then (devices) ->
if _.isEmpty(devices)
return Promise.reject(new errors.NotAny('devices'))
return devices
exports.remove = (id) ->
return canvas.delete
resource: 'device'
id: id