npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-pagerduty

v1.3.6

Published

PagerDuty v2 API Wrapper for Node

Downloads

18,564

Readme

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.