-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from opsgenie/Heartbeat_API
Heartbeat API support in NodeJS SDK
- Loading branch information
Showing
10 changed files
with
174 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"use strict"; | ||
|
||
const restApi = require('../restApi'); | ||
var operations = require('../operations'); | ||
|
||
function heartbeat() { | ||
let baseURL = '/v2/heartbeats/'; | ||
let ops = { | ||
baseURL: baseURL, | ||
/** | ||
* @param data | ||
* @param config | ||
* @param cb | ||
*/ | ||
create: function (data, config, cb) { | ||
restApi.post(baseURL ,data, config, cb); | ||
}, | ||
list: function (data, config, cb) { | ||
restApi.get(baseURL, config, cb); | ||
}, | ||
delete: function (data, config, cb) { | ||
let path = restApi.getPath(baseURL, data, null); | ||
restApi.delete(path, config, cb); | ||
}, | ||
get: function (data, config, cb) { | ||
let path = restApi.getPath(baseURL, data, null); | ||
restApi.get(path, config, cb); | ||
}, | ||
update: function (identifier, data, config, cb) { | ||
let path = restApi.getPath(this.baseURL, identifier, null); | ||
restApi.patch(path, data, config, cb) | ||
}, | ||
ping: function (identifier, data, config, cb) { | ||
let path = restApi.getPath(this.baseURL, identifier, "/ping"); | ||
restApi.get(path, data, config, cb) | ||
}, | ||
enable: function (identifier, config, cb) { | ||
let path = restApi.getPath(this.baseURL, identifier, "/enable"); | ||
restApi.post(path,null, config, cb) | ||
}, | ||
disable: function (identifier, config, cb) { | ||
let path = restApi.getPath(this.baseURL, identifier, "/disable"); | ||
restApi.post(path, null, config, cb) | ||
}, | ||
}; | ||
return ops; | ||
} | ||
|
||
module.exports = heartbeat; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"use strict"; | ||
|
||
require('../configure'); | ||
var opsgenie = require('../../'); | ||
|
||
var get_heartbeat_identifier = { | ||
name : "HeartbeatName", | ||
description: "Sample heartbeat description", | ||
intervalUnit : "minutes", | ||
interval : 10, | ||
enabled : true, | ||
ownerTeam: { | ||
name:"Team 1" | ||
} | ||
}; | ||
|
||
opsgenie.heartbeat.create(get_heartbeat_identifier, function (error, heartbeat) { | ||
if (error) { | ||
console.error(error); | ||
} else { | ||
console.log("heartbeat created"); | ||
console.log(JSON.stringify(heartbeat)); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use strict"; | ||
|
||
require('../configure'); | ||
var opsgenie = require('../../'); | ||
|
||
let identifier = { | ||
identifier: "HeartbeatName", // should be custom to your created incident | ||
}; | ||
|
||
opsgenie.heartbeat.delete(identifier, function (error, heartbeat) { | ||
if (error) { | ||
console.error(error); | ||
} else { | ||
console.log("heartbeat deleted"); | ||
console.log(JSON.stringify(heartbeat)); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use strict"; | ||
|
||
require('../configure'); | ||
var opsgenie = require('../../'); | ||
|
||
let identifier = { | ||
identifier: "HeartbeatName", // should be custom to your created incident | ||
}; | ||
|
||
opsgenie.heartbeat.disable(identifier, function (error, heartbeat) { | ||
if (error) { | ||
console.error(error); | ||
} else { | ||
console.log("heartbeat disabled"); | ||
console.log(heartbeat); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use strict"; | ||
|
||
require('../configure'); | ||
var opsgenie = require('../../'); | ||
|
||
let identifier = { | ||
identifier: "HeartbeatName", // should be custom to your created incident | ||
}; | ||
|
||
opsgenie.heartbeat.enable(identifier, function (error, heartbeat) { | ||
if (error) { | ||
console.error(error); | ||
} else { | ||
console.log("heartbeat enabled"); | ||
console.log(heartbeat); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use strict"; | ||
|
||
require('../configure'); | ||
var opsgenie = require('../../'); | ||
|
||
let identifier = { | ||
identifier: "HeartbeatName", // should be custom to your created incident | ||
}; | ||
|
||
opsgenie.heartbeat.get(identifier, function (error, heartbeat) { | ||
if (error) { | ||
console.error(error); | ||
} else { | ||
console.log("heartbeat information"); | ||
console.log(heartbeat); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"use strict"; | ||
|
||
require('../configure'); | ||
var opsgenie = require('../../'); | ||
|
||
opsgenie.heartbeat.list(null, function (error, heartbeat) { | ||
if (error) { | ||
console.error(error); | ||
} else { | ||
console.log("heartbeat list"); | ||
console.log(JSON.stringify(heartbeat)); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use strict"; | ||
|
||
require('../configure'); | ||
var opsgenie = require('../../'); | ||
|
||
let identifier = { | ||
identifier: "HeartbeatName", // should be custom to your created incident | ||
}; | ||
|
||
opsgenie.heartbeat.ping(identifier, function (error, heartbeat) { | ||
if (error) { | ||
console.error(error); | ||
} else { | ||
console.log("heartbeat pinged"); | ||
console.log(heartbeat); | ||
} | ||
}); |