Code Monkey home page Code Monkey logo

pagerduty's Introduction

PagerDuty

Library for interacting with PagerDuty REST API

currently only implements Events/Integration API:

http://developer.pagerduty.com/documentation/integration/events

Composer Install:

"nmcquay/pagerduty": "0.1.*"

Examples:

Events:

$evt = new \PagerDuty\Event();
// service key found at https://<your subdomain>.pagerduty.com/services
$evt->setServiceKey('32 char GUID') 
    ->setDescription('an example description')
    //incident key will get set automatically by pagerduty response if not set here
    //->setIncidentKey('example001') //optional
    ->setClient('Example Client') //optional
    ->setClientUrl('http://www.example.com') //optional
    ->setDetails( array('test' => 1) ) //optional
    //setDetail will add/alter a key to the details object
    ->setDetail( 'appended Detail key', 'with a value' ); //optional
$resp = $evt->trigger();

var_dump( $resp, $evt->toArray(), $evt->getIncidentKey() );

//now assuming everything worked, you should have triggered a pagerduty event
//we can acknowledge the event:
$resp = $evt->acknowledge();
var_dump( $resp );

//and we can resolve the event:
$resp = $evt->resolve();
var_dump( $resp );

// acknowledge() and resolve() require an incident_key to exist before 
// calling them

// You can also initialize an event using the same JSON format pageduty
// accepts (as a PHP array):
$evtB = new \PagerDuty\Event( array(    
      "service_key" => "32 char GUID",
      "incident_key" => "srv01/HTTP",
      "description" => "FAILURE on machine srv01.example.com",
      "client" => "Sample Monitoring Service",
      "client_url" => "https://monitoring.example.com",
      "details" => array(
          "ping time" => "1500ms",
          "load avg" => "0.75"
      )
) );
$evtB->trigger();

pagerduty's People

Contributors

baileylo avatar nmcquay avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.