2017 © Pedro Peláez
 

library pagerduty-client

This is the client for creating events and sending them to PagerDuty by API

image

tonicforhealth/pagerduty-client

This is the client for creating events and sending them to PagerDuty by API

  • Thursday, July 28, 2016
  • by drefixs
  • Repository
  • 2 Watchers
  • 0 Stars
  • 146 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

PagerDuty client

License Build Status Scrutinizer Code Quality Code Coverage SensioLabsInsight, (*1)

PagerDuty is a client lib that provides us with the object interface to use PagerDuty events-api and allows us to extend this lib to use with PagerDuty rest-api v2, (*2)

Simple way to try it with Composer

Installation

if you want to try it, (*3)

mkdir pagerduty-client-app && cd pagerduty-client-app && composer init --stability=dev -n &&  composer require tonicforhealth/pagerduty-client php-http/guzzle6-adapter guzzlehttp/guzzle:~6.1

Usage example

<?php

require __DIR__.'/vendor/autoload.php';

use TonicForHealth\PagerDutyClient\Client\EventClientFactory;
use TonicForHealth\PagerDutyClient\Client\Exception\EventClientTransportException;
use TonicForHealth\PagerDutyClient\Client\Exception\ResponseDataValidationException;
use TonicForHealth\PagerDutyClient\Entity\Event\Event;

$eventClient = EventClientFactory::createEventClient(
    'https://events.pagerduty.com/generic/2010-04-15'
);

$event = new Event();

$event->serviceKey = 'change it to your "Integration Key"';
$event->description = 'FAILURE for production/HTTP on machine srv01.acme.com';

try {
    $response = $eventClient->post($event);
} catch (EventClientTransportException $exception) {
    printf('HTTP Transport problem:%s'."\n", $exception->getMessage());
    exit(1);
} catch (ResponseDataValidationException $exception) {
    printf('Validation response problem:%s'."\n", $exception->getMessage());
    exit(2);
}

var_dump($response);

For existing projects with Composer

Installation

if you already have a project with composer.json check minimum-stability, and if it is higher than dev, change it to dev, (*4)

$ composer config minimum-stability dev

then add tonicforhealth/pagerduty-client, (*5)

$ composer require tonicforhealth/pagerduty-client

also you need to add an http-client with an adapter, or if you have one, you need to find a php-http-padapter for it, (*6)

$ composer require php-http/guzzle6-adapter guzzlehttp/guzzle:~6.1

Advance Usage example

<?php

require __DIR__.'/vendor/autoload.php';

use Http\Client\Common\HttpMethodsClient;
use Http\Discovery\HttpClientDiscovery;
use Http\Discovery\MessageFactoryDiscovery;
use TonicForHealth\PagerDutyClient\Client\EventClient;
use TonicForHealth\PagerDutyClient\Client\Exception\EventClientTransportException;
use TonicForHealth\PagerDutyClient\Client\Exception\ResponseDataValidationException;
use TonicForHealth\PagerDutyClient\Entity\Event\Event;
use TonicForHealth\PagerDutyClient\Entity\Event\EventRepresentation;
use TonicForHealth\PagerDutyClient\RepresentProcessor\RepresentProcessor;
use TonicForHealth\PagerDutyClient\Validation\ValidationResponseFactory;

$representProcessor = new RepresentProcessor();

$eventRepresentation = new EventRepresentation();

$representProcessor->addRepresentation($eventRepresentation);

$validationResponse = ValidationResponseFactory::createValidation('Event');

$httpMethodsClient = new HttpMethodsClient(
    HttpClientDiscovery::find(),
    MessageFactoryDiscovery::find()
);

$eventClient = new EventClient(
    'https://events.pagerduty.com/generic/2010-04-15',
    $httpMethodsClient,
    $representProcessor,
    $validationResponse
);

$event = new Event();

$event->serviceKey = 'change it to your "Integration Key"';
$event->description = 'FAILURE for production/HTTP on machine srv01.acme.com';

try {
    $response = $eventClient->post($event);
} catch (EventClientTransportException $exception) {
    printf('HTTP Transport problem:%s'."\n", $exception->getMessage());
    exit(1);
} catch (ResponseDataValidationException $exception) {
    printf('Validation response problem:%s'."\n", $exception->getMessage());
    exit(2);
}

var_dump($response);

The Versions

28/07 2016

dev-master

9999999-dev

This is the client for creating events and sending them to PagerDuty by API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Gopkalo

api rest client event pagerduty v2 tonicforhealth

27/07 2016

v0.1.0

0.1.0.0

PagerDuty client - This is the client lib for creation events and sent it to PagerDuty by API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Gopkalo

api rest client event pagerduty v2 tonicforhealth