Skip to content

kmartin-215/node-pagerduty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED

Please begin using the official PagerDuty repository located here https://github.com/PagerDuty/pdjs

Installation

npm install --save node-pagerduty

The --save tells NPM to automatically add it to your package.json file

Usage

// 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);
   });

OAuth Bearer Tokens

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');

Optional Request Parameters

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)

Methods

All methods follow the official API documentation.

This is a promise based library: (fullfilled, rejected)

Abilities

https://v2.developer.pagerduty.com/v2/page/api-reference#!/Abilities

abilities.listAbilities()
abilities.testAbility(id)

Add-Ons

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

https://developer.pagerduty.com/api-reference/reference/REST/openapiv3.json/paths/~1analytics~1raw~1incidents~1%7Bid%7D/get

analytics.getIncidentData(id)
analytics.getIncidentsData()

Business Services

https://developer.pagerduty.com/api-reference/reference/REST/openapiv3.json/paths/~1business_services/get

businessServices.listBusinessServices(qs)
businessServices.createBusinessService(payload)
businessServices.deleteBusinessService(id)
businessServices.getBusinessService(id)
businessServices.updateBusinessService(id, payload)

Contextual Search

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)

Escalation Policies

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)

Event Rules

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)

Extension Schemas

https://v2.developer.pagerduty.com/v2/page/api-reference#!/Extension_Schemas

extensionSchemas.listExtensionSchemas()
extensionSchemas.getExtensionVendor(id)

Extensions

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)

Events

https://v2.developer.pagerduty.com/docs/send-an-event-events-api-v2

events.sendEvent(payload)

Incidents

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)

Priorities

https://v2.developer.pagerduty.com/v2/page/api-reference#!/Priorities

priorities.listPriorities()

Response Plays

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)

Log Entries

https://v2.developer.pagerduty.com/v2/page/api-reference#!/Log_Entries

logEntries.listLogEntries(qs)
logEntries.getLogEntry(id, qs)

Maintenance Windows

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)

Notifications

https://v2.developer.pagerduty.com/v2/page/api-reference#!/Notifications

notifications.listNotifications(qs)

On-Calls

https://v2.developer.pagerduty.com/v2/page/api-reference#!/On-Calls

onCalls.listAllOnCalls(qs)

Rulesets

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)

Schedules

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)

Service Dependencies

https://developer.pagerduty.com/api-reference/reference/REST/openapiv3.json/paths/~1service_dependencies~1associate/post

serviceDependencies.associateDependencies(payload)
serviceDependencies.disassociateDependencies(payload)
serviceDependencies.getBusinessServiceDependencies(id)
serviceDependencies.getTechnicalServiceDependencies(id)

Services

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)

Teams

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)

Users

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)

Vendors

https://v2.developer.pagerduty.com/v2/page/api-reference#!/Vendors

vendors.listVendors()
vendors.getVendor(id)

License

MIT license. See the LICENSE file for details.