Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UsersV2.contacts and SchedulesV2 API #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ OpsGenie Node.js SDK covers:
- Heartbeat API
- Incident API
- Escalation API (TODO: will be available soon)
- Schedule API (TODO: will be available soon)
- Schedule API v2
- Schedule Override API (TODO: will be available soon)
- Forwarding Rule API (TODO: will be available soon)
- Integration API (TODO: will be available soon)
Expand Down
4 changes: 3 additions & 1 deletion lib/opsgenie.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ module.exports = function () {
team: require('./resources/Team')(),
incident: require('./incident/Incident')(),
heartbeat: require('./heartbeat/Heartbeat')(),
userV2: require('./userV2/UserV2')()
userV2: require('./userV2/UserV2')(),
schedulesV2: require('./schedulesV2/SchedulesV2')(),

};
};
45 changes: 45 additions & 0 deletions lib/schedulesV2/SchedulesV2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"use strict";


var api = require('./../restApi');

function schedulesV2() {
let baseURL = '/v2/schedules/';
var oncallActionPath = "/on-calls/";
var timelineActionPath = "/timeline";

return {

create: function (data, config, cb) {
api.post(this.baseURL + 'create', data, config, cb);
},
delete: function (data, config, cb) {
let path = api.getPath(baseURL, data, null);
api.delete(path, config, cb);
},
get: function (data, config, cb) {
let path = api.getPath(baseURL, data, null);
api.get(path, config, cb);
},
list: function (params, config, cb) {
var path = api.getPathWithListParams(baseURL, params);
api.get(path, config, cb)
},

getTimeline: function (identifier, params, config, cb) {
var path = api.getPathWithListParams(baseURL + identifier + timelineActionPath, params);
api.get(path, config, cb)
},

oncalls: function (identifier, config, cb) {
var path = api.getPath(baseURL, identifier + oncallActionPath);
api.get(path, config, cb)
},

export: function (params ,config, cb) {
throw (new Error('Not yet supported'));
},
};
}

module.exports = schedulesV2;
14 changes: 13 additions & 1 deletion lib/userV2/UserV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var api = require('./../restApi');

function userV2() {
var baseURL = '/v2/users/';

var contactsActionPath = "/contacts/";
return {
/**
* Gets a specific user from opsgenie based on id or email address
Expand Down Expand Up @@ -48,6 +48,18 @@ function userV2() {
var path = api.getPath(baseURL, identifier, null);
api.delete(path, config, cb)
},

/*
* This request is to get contacts of the user
* (ie. voice/sms/email)
*
* */
contacts: function (identifier, data, config, cb) {
var path = api.getPath(baseURL, identifier + contactsActionPath);
api.get(path, data, config, cb)
},


};
}

Expand Down
15 changes: 15 additions & 0 deletions samples/schedulesV2/get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"use strict";

var opsgenie = require('../../');
require('../configure');

var schedule_identifier = '77caa918-3b8e-4aa8-86fb-b0bf3ef56a0f';

opsgenie.schedulesV2.get(schedule_identifier, {}, function (error, schedules) {
if (error) {
console.error(error);
} else {
console.log(schedules)
}
})

16 changes: 16 additions & 0 deletions samples/schedulesV2/getTimeline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"use strict";

var opsgenie = require('../../');
require('../configure');


var schedule_identifier = '77caa918-3b8e-4aa8-86fb-b0bf3ef56a0f';

opsgenie.schedulesV2.getTimeline(schedule_identifier, {}, function (error, schedules) {
if (error) {
console.error(error);
} else {
console.log(schedules)
}
})

13 changes: 13 additions & 0 deletions samples/schedulesV2/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"use strict";

var opsgenie = require('../../');
require('../configure');

opsgenie.schedulesV2.list({}, {}, function (error, schedules) {
if (error) {
console.error(error);
} else {
console.log(schedules)
}
})

15 changes: 15 additions & 0 deletions samples/schedulesV2/oncalls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"use strict";

var opsgenie = require('../../');
require('../configure');

var schedule_identifier = '77caa918-3b8e-4aa8-86fb-b0bf3ef56a0f';

opsgenie.schedulesV2.oncalls(schedule_identifier, {}, function (error, schedules) {
if (error) {
console.error(error);
} else {
console.log(schedules)
}
})

18 changes: 18 additions & 0 deletions samples/userV2/contacts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use strict";

var opsgenie = require('../../');
require('../configure');


var user_identifier = 'eb387227-4d7c-4ceb-b970-c4ba728af5d0';

opsgenie.userV2.contacts(user_identifier, null , function (error, user) {
if (error) {
console.error(error);
} else {
console.log(user);
}
});