2017 © Pedro Peláez
 

symfony-bundle commons-uptime-robot-bundle

Symfony bundle for service-oriented client for UptimeRobot API v2.0

image

20steps/commons-uptime-robot-bundle

Symfony bundle for service-oriented client for UptimeRobot API v2.0

  • Wednesday, July 19, 2017
  • by helmuthva
  • Repository
  • 4 Watchers
  • 2 Stars
  • 161 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

20steps/uptime-robot-bundle (twentystepsCommonsUptimeRobotBundle)

About

The 20steps UptimeRobot Bundle contains a service-oriented client for UptimeRobot API v2.0., (*1)

Use the bundle in scenarios where you want to automatically create monitors, alert contacts etc. at UptimeRobot.com for your given application or services or as part of your deployment process to automatically manage maintenance windows., (*2)

The Bundle is licensed under the LGPL license version 3.0., (*3)

Installation

Prerequisites: * Install Composer, the dependency manager used by modern PHP applications. * Setup your Symfony 3 based application * Use PHP >= 7.0 as a runtime, (*4)

  1. Add the bundle to your composer.json and download a matching version by calling
composer require 20steps/commons-uptime-robot-bundle
  1. Configure the API key of your account at UptimeRobot.com in your config.yml
twentysteps_commons_uptime_robot:
    api_key: "Your API Key"

Usage

The following code shows how to create a monitor with the client., (*5)

<?php


use twentysteps\Commons\UptimeRobotBundle\API;
use twentysteps\Commons\UptimeRobotBundle\Model;

class MyService {

    /**
     * @var UptimeRobotAPI
     */
    private $uptimeRobotAPI;

    /**
     * inject dependency to uptimeRobotAPI via your services.yml
     * the uptimeRobotAPI is a service itself with the id "twentysteps_commons.uptime_robot.api"
     */
    public function __construct(UptimeRobotAPI $uptimeRobotAPI) {
        $this->uptimeRobotAPI = $uptimeRobotAPI;
    }

    /**
     * create a monitor
     * @return \Psr\Http\Message\ResponseInterface|Error|Monitor
     */
    public function createMonitorForMyResource() {
        $parameters = [
            'friendly_name' => 'My Monitor,
            'url' => 'https://my-host.com/my-path'
        ];
        $response = $this->uptimeRobotAPI->monitor()->create($parameters);
        if ($response instanceof MonitorResponse) {
            /**
             * @var $response MonitorResponse
             */
            if ($response->getStat()=='ok') {
                return $response->getMonitor();
            } else {
                return $response->getError();
            }
        }
        return $response;
    }
}

The bundle provides some useful commands below the twentysteps:commons:uptime-robot namespace., (*6)

Eg. to list all monitors and their stati simply call, (*7)

bin/console twentysteps:commons:uptime-robot:monitor:list

Hints

  • In case your application uses multiple accounts at UptimeRobot you can dynamically change the api key as follows
<?php


$this->uptimeRobotAPI->setApiKey($myApiKey);

  • Cp. section "parameters" of [UptimeRobot API Documentation][7] for an explanation of parameters.
  • The UptimeRobot API has been enhanced by some extra utility methods such as api->monitor()->findOneByUrl(..), api->monitor->createOrUpdate(..), api->monitor->pauseByUrl(), api->monitor->resumeByUrl() etc.

Authors

20steps - Digital Full Service Boutique, (*8)

The Versions

19/07 2017

dev-master

9999999-dev https://github.com/20steps/commons-uptime-robot-bundle

Symfony bundle for service-oriented client for UptimeRobot API v2.0

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

symfony2 sf2 sf3 symfony3 20steps swagger symfony uptimerobot openapi sf httplug

19/07 2017

v1.0.4

1.0.4.0 https://github.com/20steps/commons-uptime-robot-bundle

Symfony bundle for service-oriented client for UptimeRobot API v2.0

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

symfony2 sf2 sf3 symfony3 20steps swagger symfony uptimerobot openapi sf httplug

19/07 2017

v1.0.3

1.0.3.0 https://github.com/20steps/commons-uptime-robot-bundle

Symfony bundle for service-oriented client for UptimeRobot API v2.0

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

symfony2 sf2 sf3 symfony3 20steps swagger symfony uptimerobot openapi sf httplug

19/07 2017

v1.0.2

1.0.2.0 https://github.com/20steps/commons-uptime-robot-bundle

Symfony bundle for service-oriented client for UptimeRobot API v2.0

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

symfony2 sf2 sf3 symfony3 20steps swagger symfony uptimerobot openapi sf httplug

19/07 2017

v1.0.1

1.0.1.0 https://github.com/20steps/commons-uptime-robot-bundle

Symfony bundle for service-oriented client for UptimeRobot API v2.0

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

symfony2 sf2 sf3 symfony3 20steps swagger symfony uptimerobot openapi sf httplug

19/07 2017

v1.0.0

1.0.0.0 https://github.com/20steps/commons-uptime-robot-bundle

Symfony bundle for service-oriented client for UptimeRobot API v2.0

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

symfony2 sf2 sf3 symfony3 20steps swagger symfony uptimerobot openapi sf httplug