|
|
|
@ -6,14 +6,11 @@ var util = require("util"); |
|
|
|
/*section: screenboard |
|
|
|
*comment: create a new screenboard |
|
|
|
*params: |
|
|
|
* title: the name of the screenboard |
|
|
|
* description: description of the screenboard |
|
|
|
* graphs: | |
|
|
|
* an array of objects which required the following keys |
|
|
|
* * title: the name of the graph |
|
|
|
* * widgets: an array of widgets, see http://docs.datadoghq.com/api/screenboards/ for more info
|
|
|
|
* boardTitle: the name of the screenboard |
|
|
|
* widgets: an array of widgets, see http://docs.datadoghq.com/api/screenboards/ for more info
|
|
|
|
* options: | |
|
|
|
* optional, a object which can contain any of the following keys |
|
|
|
* * description: description of the screenboard |
|
|
|
* * templateVariables: | |
|
|
|
* an array of objects with the following keys |
|
|
|
* * name: the name of the variable |
|
|
|
@ -21,6 +18,7 @@ var util = require("util"); |
|
|
|
* * default: optional, the default value for this tag |
|
|
|
* * width: the width of the screenboard in pixels |
|
|
|
* * height: the height of the screenboard in pixels |
|
|
|
* * readOnly: the read-only status of the screenboard |
|
|
|
* callback: function(err, res) |
|
|
|
*example: | |
|
|
|
* ```javascript
|
|
|
|
@ -30,9 +28,8 @@ var util = require("util"); |
|
|
|
* app_key: "app_key" |
|
|
|
* }; |
|
|
|
* dogapi.initialize(options); |
|
|
|
* var title = "my screenboard"; |
|
|
|
* var description = "it is super awesome"; |
|
|
|
* var graphs = [ |
|
|
|
* var boardTitle = "my screenboard"; |
|
|
|
* var widgets = [ |
|
|
|
* { |
|
|
|
* type: "image", |
|
|
|
* height: 20, |
|
|
|
@ -49,17 +46,18 @@ var util = require("util"); |
|
|
|
* prefix: "host", |
|
|
|
* "default": "host:my-host" |
|
|
|
* } |
|
|
|
* ] |
|
|
|
* ], |
|
|
|
* description: "it is super awesome" |
|
|
|
* }; |
|
|
|
* dogapi.screenboard.create( |
|
|
|
* title, description, graphs, options, |
|
|
|
* boardTitle, widgets, options, |
|
|
|
* function(err, res){ |
|
|
|
* console.dir(res); |
|
|
|
* } |
|
|
|
* ); |
|
|
|
* ```
|
|
|
|
*/ |
|
|
|
function create(title, description, graphs, options, callback){ |
|
|
|
function create(boardTitle, widgets, options, callback){ |
|
|
|
if(arguments.length < 5 && typeof arguments[3] === "function"){ |
|
|
|
callback = options; |
|
|
|
options = {}; |
|
|
|
@ -70,12 +68,14 @@ function create(title, description, graphs, options, callback){ |
|
|
|
|
|
|
|
var params = { |
|
|
|
body: { |
|
|
|
title: title, |
|
|
|
description: description, |
|
|
|
graphs: graphs |
|
|
|
board_title: boardTitle, |
|
|
|
widgets: widgets |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
if(options.description){ |
|
|
|
params.body.description = options.description; |
|
|
|
} |
|
|
|
if(options.templateVariables){ |
|
|
|
params.body.template_variables = options.templateVariables; |
|
|
|
} |
|
|
|
@ -85,6 +85,9 @@ function create(title, description, graphs, options, callback){ |
|
|
|
if(options.height){ |
|
|
|
params.body.height = options.height; |
|
|
|
} |
|
|
|
if(options.readOnly){ |
|
|
|
params.body.read_only = options.readOnly; |
|
|
|
} |
|
|
|
|
|
|
|
client.request("POST", "/screen", params, callback); |
|
|
|
} |
|
|
|
@ -185,7 +188,7 @@ module.exports = { |
|
|
|
share: share, |
|
|
|
getUsage: function(){ |
|
|
|
return [ |
|
|
|
" dogapi screenboard create <title> <description> <graphs> [--tmpvars <templateVariables>] [--width <width>] [--height <height>]", |
|
|
|
" dogapi screenboard create <boardTitle> <widgets> [--description <description>] [--tmpvars <templateVariables>] [--width <width>] [--height <height>]", |
|
|
|
" dogapi screenboard remove <boardId>", |
|
|
|
" dogapi screenboard get <boardId>", |
|
|
|
" dogapi screenboard getall", |
|
|
|
@ -196,12 +199,13 @@ module.exports = { |
|
|
|
return [ |
|
|
|
"Screenboard:", |
|
|
|
" Subcommands:", |
|
|
|
" create <title> <description> <graphs> create a new screenboard, <graphs> is a json of the graph definition", |
|
|
|
" create <boardTitle> <widgets> create a new screenboard, <widgets> is a json of the graph definition", |
|
|
|
" remove <boardId> remove an existing screenboard", |
|
|
|
" get <boardId> get an existing screenboard", |
|
|
|
" getall get all screenboards", |
|
|
|
" share <boardId> get share info for an existing screenboard", |
|
|
|
" Options:", |
|
|
|
" --description <description> a description of the screenboard's content", |
|
|
|
" --tmpvars <templateVariables> json representation of the template variable definition", |
|
|
|
" --width <width> width of the screenboard in pixels", |
|
|
|
" --height <height> height of the screenboard in pixels", |
|
|
|
@ -217,11 +221,13 @@ module.exports = { |
|
|
|
} else if(subcommand === "share"){ |
|
|
|
share(args._[4], callback); |
|
|
|
} else if(subcommand === "create"){ |
|
|
|
var title = args._[4]; |
|
|
|
var description = args._[5]; |
|
|
|
var graphs = json.parse(args._[6]); |
|
|
|
var boardTitle = args._[4]; |
|
|
|
var widgets = json.parse(args._[5]); |
|
|
|
|
|
|
|
var options = {}; |
|
|
|
if(args["description"]) { |
|
|
|
options.description = args["description"]; |
|
|
|
} |
|
|
|
if(args["tmpvars"]){ |
|
|
|
options.templateVariables = json.parse(args["tmpvars"]); |
|
|
|
} |
|
|
|
@ -232,7 +238,7 @@ module.exports = { |
|
|
|
options.height = parseInt(args["height"]); |
|
|
|
} |
|
|
|
|
|
|
|
create(title, description, graphs, options, callback); |
|
|
|
create(boardTitle, widgets, options, callback); |
|
|
|
} else { |
|
|
|
callback("unknown subcommand or arguments try `dogapi screenboard --help` for help", false); |
|
|
|
} |
|
|
|
|