dogapi
Advanced tools
Comparing version 2.4.1 to 2.5.0
@@ -96,2 +96,85 @@ var client = require("../client"); | ||
/*section: screenboard | ||
*comment: update an existing screenboard | ||
*params: | ||
* boardId: the id of the screenboard to update | ||
* 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 | ||
* * prefix: optional, the tag prefix for this variable | ||
* * 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 | ||
* var dogapi = require("dogapi"); | ||
* var options = { | ||
* api_key: "api_key", | ||
* app_key: "app_key" | ||
* }; | ||
* dogapi.initialize(options); | ||
* var boardTitle = "my screenboard"; | ||
* var widgets = [ | ||
* { | ||
* type: "image", | ||
* height: 20, | ||
* width: 32, | ||
* y: 7, | ||
* x: 32, | ||
* url: "https://path/to/image.jpg" | ||
* } | ||
* ]; | ||
* var options = { | ||
* description: "it is super awesome" | ||
* }; | ||
* dogapi.screenboard.update( | ||
* 1234, boardTitle, widgets, options, | ||
* function(err, res){ | ||
* console.dir(res); | ||
* } | ||
* ); | ||
* ``` | ||
*/ | ||
function update(boardId, boardTitle, widgets, options, callback) { | ||
if(arguments.length < 5 && typeof arguments[3] === "function"){ | ||
callback = options; | ||
options = {}; | ||
} | ||
if(typeof options !== "object"){ | ||
options = {}; | ||
} | ||
var params = { | ||
body: { | ||
board_title: boardTitle, | ||
widgets: widgets | ||
} | ||
}; | ||
if(options.description){ | ||
params.body.description = options.description; | ||
} | ||
if(options.templateVariables){ | ||
params.body.template_variables = options.templateVariables; | ||
} | ||
if(options.width){ | ||
params.body.width = options.width; | ||
} | ||
if(options.height){ | ||
params.body.height = options.height; | ||
} | ||
if(options.readOnly){ | ||
params.body.read_only = options.readOnly; | ||
} | ||
client.request("PUT", "/screen", params, callback); | ||
} | ||
/*section: screenboard | ||
*comment: delete an existing screenboard | ||
@@ -187,2 +270,3 @@ *params: | ||
remove: remove, | ||
update: update, | ||
get: get, | ||
@@ -205,2 +289,3 @@ getAll: getAll, | ||
" create <boardTitle> <widgets> create a new screenboard, <widgets> is a json of the graph definition", | ||
" update <boardId> <boardTitle> <widgets> update a screenboard", | ||
" remove <boardId> remove an existing screenboard", | ||
@@ -226,2 +311,22 @@ " get <boardId> get an existing screenboard", | ||
share(args._[4], callback); | ||
} else if (subcommand === "update"){ | ||
var boardId = args._[4]; | ||
var boardTitle = args._[5]; | ||
var widgets = json.parse(args._[6]); | ||
var options = {}; | ||
if(args["description"]) { | ||
options.description = args["description"]; | ||
} | ||
if(args["tmpvars"]){ | ||
options.templateVariables = json.parse(args["tmpvars"]); | ||
} | ||
if(args["width"]){ | ||
options.width = parseInt(args["width"]); | ||
} | ||
if(args["height"]){ | ||
options.height = parseInt(args["height"]); | ||
} | ||
update(boardId, boardTitle, widgets, options, callback); | ||
} else if(subcommand === "create"){ | ||
@@ -228,0 +333,0 @@ var boardTitle = args._[4]; |
{ | ||
"name": "dogapi", | ||
"version": "2.4.1", | ||
"version": "2.5.0", | ||
"description": "Datadog API Node.JS Client", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
184411
3380