Skip to content

Instantly share code, notes, and snippets.

@sunnygleason
Created December 20, 2016 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunnygleason/681b2eba0be409dedaad96e2457ae6cf to your computer and use it in GitHub Desktop.
Save sunnygleason/681b2eba0be409dedaad96e2457ae6cf to your computer and use it in GitHub Desktop.
PubNub DevOps BLOCK w/ PagerDuty
export default (request) => {
const xhr = require('xhr');
const integrationKey = 'YOUR_INTEGRATION_KEY';
const apiUrl = 'https://events.pagerduty.com/generic/2010-04-15/create_event.json';
const description = request.message.description;
const httpOptions = {
method: 'POST',
body: JSON.stringify({
service_key: integrationKey,
event_type: 'trigger',
incident_key: "incident_" + parseInt(Math.random() * 10000),
description: description
})
};
return xhr.fetch(apiUrl, httpOptions)
.then((response) => {
console.log(response);
request.message.result = response;
return request.ok();
})
.catch((e) => {
console.error(e);
return request.ok();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment