Code Monkey home page Code Monkey logo

statuscake's Introduction

#StatusCake API wrapper

StatusCake is a monitoring service that monitors website/servers over HTTP/TCP/PING.

This project wraps most endpoints StatusCake has to offer.

Install

Via Composer

composer require JulienCr/statuscake

Usage

Setting up the client:

$statusCake = new StatusCake\Client(`USER', 'TOKEN');

Checking if the credentials are valid:

$statusCake->validAccount(); // return true or false

Getting basic account info:

$statusCake->account();

Tests

These are actually your monitors, each test would represent a website you're monitoring.

Each returned test will be parsed into a class StatusCake\Test, all the properties are documented in there, be sure to check it out.

Creating a test

To create a test you need to initialise StatusCake\Test. There are just a few properties that are actually required; websiteName, websiteURL, testType.

$test = new StatusCake\Test();

// Required parameters
$test->websiteName = 'HappyDemon';
$test->websiteURL = 'http://happydemon.xyz';
$test->testType = StatusCake\Test::TYPE_HTTP;

// I'm a little impatient, so I'd like more frequest checks (every 2 minutes)
$test->checkRate = 120;

// Save everything
$statusCake->updateTest($test);

Updating a test

Updating is done in the same way:

// I've changed my mind, let's check every 5 minutes
$test->checkRate = 300;

// Save the change
$statusCake->updateTest($test);

Deleting a test

$statusCake->deleteTest($test);

Retrieving tests

Retrieving a list of existing tests is simple:

$tests = $statusCake->getTests();

Retrieving a test's period

A period of data is two time stamps in which status has remained the same.

$periods = $test->getPeriods();

Retrieving a test's performance data

Retrieves a list of checks performed for the current site (this statusCake users with a premium account).

$periods = $test->getPerformance();

Retrieve a test's previously sent alerts

Retrieves a list of alerts that have, previously, been sent.

$periods = $test->getAlerts();

Contact Groups

One of the properties tests could need assigned is contact groups. You can retrieve and manage them through the API as wel.

The same principles as Tests are applied here, meaning every contact group will be loaded in a StatusCake\ContactGroup class (check the class definition for more info on the properties).

A few helper functions are included to work with email addresses.

Creating a contact group

$contactGroup = new StatusCake\ContactGroup();

// The only required parameter
$contactGroup->groupName = 'personal mail';

// let's add an email to get notifications
$contactGroup->addEmail('[email protected]');

// Save everything
$statusCake->updateContactGroup($contactGroup);

Updating a contact group

// I've changed my mind, different email
$contactGroup->removeEmail('[email protected]');
$contactGroup->addEmail('[email protected]');

// Which is the same as doing
$contactGroup->email = ['[email protected]']

// Save everything
$statusCake->updateContactGroup($contactGroup);

Deleting a contact group

$statusCake->deleteContactGroup($contactGroup);

statuscake's People

Contributors

bravadomizzou avatar christophluehr avatar juliencr avatar onlime 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.