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

splunk-oncall-client

v1.0.0

Published

A library for interacting with the Splunk On-Call REST API

Downloads

13

Readme

Splunk On-Call Client npm version Build Status Coverage Status codecov

The splunk-oncall-client library contains a simple and convenient HTTP client for making requests to the Splunk On-Call (VictorOps) REST API.

Table of contents

Installation

Using NPM:

$ npm install splunk-oncall-client

Using Yarn:

$ yarn add splunk-oncall-client

Usage

Initialize the client

The library exports a SplunkOnCallClient class. All you need to do is instantiate it, and you're ready to go. You'll need an API ID and API key provided by the Splunk On-Call service. You can provide these values as apiId and apiKey options or set these values as environment variables using SPLUNK_ONCALL_API_ID and SPLUNK_ONCALL_API_KEY. By default, the client will use the SPLUNK_ONCALL_API_ID and SPLUNK_ONCALL_API_KEY environment variables if apiId and apiKey are not provided in the options.

Example import methods:

const SplunkOnCallClient = require('splunk-oncall-client');

const client = new SplunkOnCallClient({
  apiId: 'API-ID',
  apiKey: 'API-KEY'
});
import SplunkOnCallClient from 'splunk-oncall-client';

const client = new SplunkOnCallClient({
  apiId: 'API-ID',
  apiKey: 'API-KEY'
});

It is required to set the API ID and API key parameters as either environment variables or as options when instantiating the client. These parameters are necessary to execute SplunkOnCallClient calls. If these parameters are not provided or cannot be determined, then an error is thrown.

Using environment variables in an application:

const SplunkOnCallClient = require('splunk-oncall-client');

// Set the API ID and key as environment variables.
process.env.SPLUNK_ONCALL_API_ID = 'SOME-API-ID';
process.env.SPLUNK_ONCALL_API_KEY = 'SOME-API-KEY';

const client = new SplunkOnCallClient();

Setting environment variables before running an application:

Linux:

$ SPLUNK_ONCALL_API_ID=SOME-API-ID SPLUNK_ONCALL_API_KEY=SOME-API-KEY node app.js

Windows:

> cmd /C "set SPLUNK_ONCALL_API_ID=SOME-API-ID && set SPLUNK_ONCALL_API_KEY=SOME-API-KEY && node app.js"

Options

These are the available options for creating a SplunkOnCallClient instance. If the apiId and apiKey options are not provided, then the SPLUNK_ONCALL_API_ID and SPLUNK_ONCALL_API_KEY environment variables will be used instead.

| Name | Default | Description | | ------------------- | ---------------------------- | --------------------------------------------------------- | | apiId | undefined | Splunk On-Call API ID |
| apiKey | undefined | Splunk On-Call API Key | | timeout | 5000 | Number of milliseconds before the request times out | | baseUrl | https://api.victorops.com | The base URL for the Splunk On-Call REST API | | fullResponse | false | Get the full response instead of just the body | | maxContentLength | 10000 | The max size of the HTTP response content in bytes | | maxBodyLength | 2000 | The max allowed size of the HTTP request body in bytes |

Examples

Create an instance:

const SplunkOnCallClient = require('splunk-oncall-client');

const client = new SplunkOnCallClient({
  apiId: 'API-ID',
  apiKey: 'API-KEY'
});

Get a list of users:

async function getUsers() {
  try {
    const users = await client.users.getUsers();
    return users;
  } catch(err) {
    console.error(err);
  }
}

Get a list of incidents:

async function getIncidents() {
  try {
    const incidents = await client.incidents.getIncidents();
    return incidents;
  } catch(err) {
    console.error(err);
  }
}

Create a new incident:

async function createIncident() {
  try {
    const resp = await client.incidents.createIncident({
      summary: 'Test incident',
      details: 'Something bad happened!!!',
      userName: 'johndoe',
      targets: [
        {
          type: 'User',
          slug: 'johndoe'
        }
      ],
      isMultiResponder: true
    });
    return resp;
  } catch(err) {
    console.error(err);
  }
}

Get a list of teams:

async function getTeams() {
  try {
    const teams = await client.teams.getTeams();
    return teams;
  } catch(err) {
    console.error(err);
  }
}

Documentation

The client instance has a named property for each of the public endpoints in the Splunk On-Call (VictorOps) REST API. Each endpoint property contains methods that correspond to the operations associated with the endpoint (according to the Splunk On-Call API). All named endpoint methods return a Promise which resolves with the response data or rejects with an error. Below are the endpoints and operations included with the client.

Any endpoint operation that takes a query argument expects the value to be an Object that contains the query parameters for that particular endpoint operation. Please refer to the endpoint operation's documentation for the correct query parameters.

On-Call

Incidents

Alerts

Reporting

Users

User Contact Methods

User Paging Policies

Personal Paging Policy Values

Personal Paging Policies

Teams

Escalation Policies

Routing Keys

Scheduled Overrides

Rotations

Webhooks

Chat

Notes

Maintenance Mode

Change Log

The CHANGELOG contains descriptions of notable changes.

License

This software is licensed under the Apache 2 license.