Merge pull request #384 from resin-io/features/deviceUrl

Implement `device enableDeviceUrl/disableDeviceUrl/hasDeviceUrl/getDeviceUrl`
This commit is contained in:
Juan Cruz Viotti 2016-08-09 16:45:46 -04:00 committed by GitHub
commit 5ed26250d2
4 changed files with 128 additions and 0 deletions

View File

@ -135,6 +135,58 @@ limitations under the License.
}
};
exports.enableDeviceUrl = {
signature: 'device public-url enable <uuid>',
description: 'enable public URL for a device',
help: 'Use this command to enable public URL for a device\n\nExamples:\n\n $ resin device public-url enable 23c73a1',
permission: 'user',
action: function(params, options, done) {
var resin;
resin = require('resin-sdk');
return resin.models.device.enableDeviceUrl(params.uuid).nodeify(done);
}
};
exports.disableDeviceUrl = {
signature: 'device public-url disable <uuid>',
description: 'disable public URL for a device',
help: 'Use this command to disable public URL for a device\n\nExamples:\n\n $ resin device public-url disable 23c73a1',
permission: 'user',
action: function(params, options, done) {
var resin;
resin = require('resin-sdk');
return resin.models.device.disableDeviceUrl(params.uuid).nodeify(done);
}
};
exports.getDeviceUrl = {
signature: 'device public-url <uuid>',
description: 'gets the public URL of a device',
help: 'Use this command to get the public URL of a device\n\nExamples:\n\n $ resin device public-url 23c73a1',
permission: 'user',
action: function(params, options, done) {
var resin;
resin = require('resin-sdk');
return resin.models.device.getDeviceUrl(params.uuid).then(function(url) {
return console.log(url);
}).nodeify(done);
}
};
exports.hasDeviceUrl = {
signature: 'device public-url status <uuid>',
description: 'Returns true if public URL is enabled for a device',
help: 'Use this command to determine if public URL is enabled for a device\n\nExamples:\n\n $ resin device public-url status 23c73a1',
permission: 'user',
action: function(params, options, done) {
var resin;
resin = require('resin-sdk');
return resin.models.device.hasDeviceUrl(params.uuid).then(function(hasDeviceUrl) {
return console.log(hasDeviceUrl);
}).nodeify(done);
}
};
exports.rename = {
signature: 'device rename <uuid> [newName]',
description: 'rename a resin device',

View File

@ -95,6 +95,14 @@ limitations under the License.
capitano.command(actions.device.reboot);
capitano.command(actions.device.enableDeviceUrl);
capitano.command(actions.device.disableDeviceUrl);
capitano.command(actions.device.getDeviceUrl);
capitano.command(actions.device.hasDeviceUrl);
capitano.command(actions.device.register);
capitano.command(actions.device.move);

View File

@ -186,6 +186,70 @@ exports.reboot =
resin = require('resin-sdk')
resin.models.device.reboot(params.uuid).nodeify(done)
exports.enableDeviceUrl =
signature: 'device public-url enable <uuid>'
description: 'enable public URL for a device'
help: '''
Use this command to enable public URL for a device
Examples:
$ resin device public-url enable 23c73a1
'''
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin.models.device.enableDeviceUrl(params.uuid).nodeify(done)
exports.disableDeviceUrl =
signature: 'device public-url disable <uuid>'
description: 'disable public URL for a device'
help: '''
Use this command to disable public URL for a device
Examples:
$ resin device public-url disable 23c73a1
'''
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin.models.device.disableDeviceUrl(params.uuid).nodeify(done)
exports.getDeviceUrl =
signature: 'device public-url <uuid>'
description: 'gets the public URL of a device'
help: '''
Use this command to get the public URL of a device
Examples:
$ resin device public-url 23c73a1
'''
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin.models.device.getDeviceUrl(params.uuid).then (url) ->
console.log(url)
.nodeify(done)
exports.hasDeviceUrl =
signature: 'device public-url status <uuid>'
description: 'Returns true if public URL is enabled for a device'
help: '''
Use this command to determine if public URL is enabled for a device
Examples:
$ resin device public-url status 23c73a1
'''
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin.models.device.hasDeviceUrl(params.uuid).then (hasDeviceUrl) ->
console.log(hasDeviceUrl)
.nodeify(done)
exports.rename =
signature: 'device rename <uuid> [newName]'
description: 'rename a resin device'

View File

@ -75,6 +75,10 @@ capitano.command(actions.device.init)
capitano.command(actions.device.remove)
capitano.command(actions.device.identify)
capitano.command(actions.device.reboot)
capitano.command(actions.device.enableDeviceUrl)
capitano.command(actions.device.disableDeviceUrl)
capitano.command(actions.device.getDeviceUrl)
capitano.command(actions.device.hasDeviceUrl)
capitano.command(actions.device.register)
capitano.command(actions.device.move)
capitano.command(actions.device.info)