Please begin using the official PagerDuty repository located here https://github.com/PagerDuty/pdjs
npm install --save node-pagerduty
The --save
tells NPM to automatically add it to your package.json
file
// Import a module
const pdClient = require('node-pagerduty');
const pdapiToken = 'yourapiTokenGoesHere';
const pd = new pdClient(pdapiToken);
let yourId = 'yourScheduleIdGoesHere';
let yourQs = {
time_zone: 'UTC',
since: 'yourSince',
until: 'yourUntil'
};
// Using it to get things done
pd.schedules.getSchedule(yourId, yourQs)
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err);
});
This library also supports the usage of Bearer
tokens generated by OAuth2. To initialize a new pdClient
with a Bearer
token simply pass a second argument of Bearer
for the token type. The whole call would look something like this:
const pd = new pdClient(pdapiToken, 'Bearer');
You can override or add to the request options, allowing for things such as proxying or setting a higher timeout for slower connections. This parameter is optional.
const myCustomOptions = {
"proxy": "https://proxy.example.com",
"headers": {
"Proxy-Authorization": "Basic xxxxxxxxxxxx",
"dont-send-to-proxy": "ok",
"dont-send-to-dest": "ok"
},
"timeout": 10000
};
const pd = new pdClient(pdapiToken, null, myCustomOptions)
All methods follow the official API documentation.
This is a promise based library: (fullfilled, rejected)
https://v2.developer.pagerduty.com/v2/page/api-reference#!/Abilities
abilities.listAbilities()
abilities.testAbility(id)
https://v2.developer.pagerduty.com/v2/page/api-reference#!/Add-ons
addOns.listAddOns(qs)
addOns.installAddOn(payload)
addOns.deleteAddOn(id)
addOns.getAddOn(id)
addOns.updateAddOn(id, payload)
analytics.getIncidentData(id)
analytics.getIncidentsData()
businessServices.listBusinessServices(qs)
businessServices.createBusinessService(payload)
businessServices.deleteBusinessService(id)
businessServices.getBusinessService(id)
businessServices.updateBusinessService(id, payload)
https://api-reference.pagerduty.com/#!/Contextual_Search
contextualSearch.listTags(qs)
contextualSearch.createTag(payload)
contextualSearch.deleteTag(id)
contextualSearch.getTag(id)
contextualSearch.getConnectedEntities(id, entity_type)
contextualSearch.assignTags(entity_type, id, payload)
https://v2.developer.pagerduty.com/v2/page/api-reference#!/Escalation_Policies
escalationPolicies.listEscalationPolicies(qs)
escalationPolicies.createEscalationPolicy(from, payload)
escalationPolicies.deleteEscalationPolicy(id)
escalationPolicies.getEscalationPolicy(id, qs)
escalationPolicies.updateEscalationPolicy(id, payload)
Note: Event Rules endpoint does not work with Bearer tokens. Only Token tokens https://v2.developer.pagerduty.com/docs/global-event-rules-api
eventRules.listEventRules()
eventRules.createEventRule(id, payload)
eventRules.deleteEventRule(id)
eventRules.updateEventRule(id, payload)
https://v2.developer.pagerduty.com/v2/page/api-reference#!/Extension_Schemas
extensionSchemas.listExtensionSchemas()
extensionSchemas.getExtensionVendor(id)
https://v2.developer.pagerduty.com/v2/page/api-reference#!/Extensions
extensions.listExtensions(qs)
extensions.createExtension(payload)
extensions.deleteExtension(id)
extensions.getExtension(id, qs)
extensions.updateExtension(id, payload)
https://v2.developer.pagerduty.com/docs/send-an-event-events-api-v2
events.sendEvent(payload)
https://v2.developer.pagerduty.com/v2/page/api-reference#!/Incidents
incidents.listIncidents(qs)
incidents.createIncident(from, payload)
incidents.manageIncident(from, payload)
incidents.mergeIncidents(id, from, payload)
incidents.getIncident(id)
incidents.updateIncident(id, from, payload)
incidents.listAlerts(id, qs)
incidents.manageAlerts(id, from, payload)
incidents.getAlert(id, alert_id)
incidents.updateAlert(id, alert_id, from, payload)
incidents.listLogEntries(id, qs)
incidents.listNotes(id)
incidents.createNote(id, from, payload)
incidents.createStatusUpdate(id, from, payload)
incidents.createResponderRequest(id, from, payload)
incidents.snoozeIncident(id, from, payload)
https://v2.developer.pagerduty.com/v2/page/api-reference#!/Priorities
priorities.listPriorities()
https://v2.developer.pagerduty.com/v2/page/api-reference#!/Response_Plays
responsePlays.createResponseReplay(payload)
responsePlays.deleteResponseReplay(id)
responsePlays.getResponseReplay(id)
responsePlays.listResponseReplay(qs)
responsePlays.runResponsePlay(id, from, payload)
responsePlays.updateResponseReplay(id, payload)
https://v2.developer.pagerduty.com/v2/page/api-reference#!/Log_Entries
logEntries.listLogEntries(qs)
logEntries.getLogEntry(id, qs)
https://v2.developer.pagerduty.com/v2/page/api-reference#!/Maintenance_Windows
maintenanceWindows.listMaintenanceWindows(qs)
maintenanceWindows.createMaintenanceWindow(from, payload)
maintenanceWindows.deleteMaintenanceWindow(id)
maintenanceWindows.getMaintenanceWindow(id, qs)
maintenanceWindows.updateMaintenanceWindow(id, payload)
https://v2.developer.pagerduty.com/v2/page/api-reference#!/Notifications
notifications.listNotifications(qs)
https://v2.developer.pagerduty.com/v2/page/api-reference#!/On-Calls
onCalls.listAllOnCalls(qs)
https://developer.pagerduty.com/api-reference/reference/REST/openapiv3.json/paths/~1rulesets/get
rulesets.listRulesets(qs)
rulesets.getRuleset(id)
rulesets.createRuleset(payload)
rulesets.updateRuleset(id, payload)
rulesets.deleteRuleset(id)
rulesets.listRulesetRules(id, qs)
rulesets.createRulesetRule(id, payload)
rulesets.getRulesetRule(rulesetId, ruleId)
rulesets.deleteRulesetRule(rulesetId, ruleId)
rulesets.updateRulesetRule(rulesetId, ruleId, payload)
https://v2.developer.pagerduty.com/v2/page/api-reference#!/Schedules
schedules.listSchedule(qs)
schedules.createSchedule(payload)
schedules.previewSchedule(qs, payload)
schedules.deleteSchedule(id)
schedules.getSchedule(id, qs)
schedules.updateSchedule(id, qs, payload)
schedules.listOverrides(id, qs)
schedules.createOverride(id, payload)
schedules.deleteOverride(id, override_id)
schedules.listUsersOnCall(id, qs)
serviceDependencies.associateDependencies(payload)
serviceDependencies.disassociateDependencies(payload)
serviceDependencies.getBusinessServiceDependencies(id)
serviceDependencies.getTechnicalServiceDependencies(id)
https://v2.developer.pagerduty.com/v2/page/api-reference#!/Services
services.listServices(qs)
services.createService(payload)
services.deleteService(id)
services.getService(id, qs)
services.updateService(id, payload)
services.createIntegration(id, payload)
services.viewIntegration(id, integration_id)
services.updateIntegration(id, integration_id, payload)
https://v2.developer.pagerduty.com/v2/page/api-reference#!/Teams
teams.listTeams(qs)
teams.createTeam(payload)
teams.deleteTeam(id, qs)
teams.getTeam(id, qs)
teams.updateTeam(id, payload)
teams.getTeamMembers(id, qs)
teams.removeEscalationPolicy(id, policy_id)
teams.addEscalationPolicy(id, policy_id)
teams.removeUser(id, user_id)
teams.addUser(id, user_id, payload)
https://v2.developer.pagerduty.com/v2/page/api-reference#!/Users
users.listUsers(qs)
users.createUser(from, payload)
users.deleteUser(id)
users.getUser(id, qs)
users.updateUser(id, payload)
users.getCurrentUser(qs)
users.listContactMethods(id)
users.createContactMethod(id, payload)
users.deleteContactMethod(id, contact_method_id)
users.getContactMethod(id, contact_method_id)
users.updateContactMethod(id, contact_method_id, payload)
users.listNotificationRules(id, qs)
users.createNotificationRule(id, payload)
users.deleteNotificationRule(id, rule_id)
users.getNotificationRule(id, rule_id, qs)
users.updateNotificationRule(id, rule_id, payload)
users.deleteAllUserSessions(id)
users.listUserActiveSessions(id)
users.deleteUsersSession(id, type, session_id)
users.getUsersSession(id, type, session_id)
https://v2.developer.pagerduty.com/v2/page/api-reference#!/Vendors
vendors.listVendors()
vendors.getVendor(id)
MIT license. See the LICENSE file for details.