binarybuilds / cronbuzz-php
Official php client for cronbuzz API
Requires
- ext-curl: *
- ext-json: *
This package is auto-updated.
Last update: 2024-10-29 06:18:43 UTC
README
This is the official php client for cronbuzz API. Use this client to manage your cronbuzz monitors or send pings from your cron jobs easily.
Installation
This package can be installed using composer.
composer require binarybuilds/cronbuzz-php
Sending Pings from your cron jobs
Use the following code to automatically send proper pings to cronbuzz.
\BinaryBuilds\CronBuzzPHP\CronBuzzTask::run('your-monitor-uuid', function (){ // Add your code here });
The above code will
- send a ping to cronbuzz informing the cron job execution has started
- wraps your code inside a
try
catch
block - sends a ping when your code completes executing.
- If any exception occurred during the execution of your code,
catch
block will catch the execution, Send a ping to cronbuzz informing the cron job failed executing. It will also include the error message. - Re-throws the exception, So you can handle the exceptions as usually.
If for any reason the above code does not work for you, Or if you prefer to send pings manually, Use the below code.
$run = new \BinaryBuilds\CronBuzzPHP\Run( 'your-monitor-uuid' ); $run->start(); try{ // Add your code here $run->complete(); }catch (\Exception $exception){ $run->fail( $exception->getMessage() ); // Handle your exceptions here }
Using API
Authorization
Before you make any requests to the API, You must authenticate using your API key.
This step is not required for sending pings from your cron jobs.
Add the below lines at the beginning of your code.
\BinaryBuilds\CronBuzzPHP\CronBuzzAPI::setTeamKey('your-team-key'); \BinaryBuilds\CronBuzzPHP\CronBuzzAPI::setApiKey('your-api-token');
You can retrieve your team key from the team settings page, and your api token from the profile page.
Monitors
List Monitors
\BinaryBuilds\CronBuzzPHP\Monitor::list();
Show Monitor
\BinaryBuilds\CronBuzzPHP\Monitor::get( 'monitor id');
Create Monitor
\BinaryBuilds\CronBuzzPHP\Monitor::create( 'monitor name', 'schedule', 'max execution', 'notification lists', 'tags' );
Update Monitor
\BinaryBuilds\CronBuzzPHP\Monitor::update( 'monitor id', 'fields');
Delete Monitor
\BinaryBuilds\CronBuzzPHP\Monitor::delete( 'monitor id');
Pause Monitor
\BinaryBuilds\CronBuzzPHP\Monitor::pause( 'monitor id');
Resume Monitor
\BinaryBuilds\CronBuzzPHP\Monitor::resume( 'monitor id');
Notification Lists
List Notification Lists
\BinaryBuilds\CronBuzzPHP\NotificationList::list();
Show Notification List
\BinaryBuilds\CronBuzzPHP\NotificationList::get( 'list id');
Create Notification List
\BinaryBuilds\CronBuzzPHP\NotificationList::create( 'list name', 'channels');
Notification channels format
[ [ 'type' => 'EMAIL', 'yourname@yourcompany.com'], [ 'type' => 'WEBHOOK', 'https://your-webhook-url.com/'], ]
Update Notification List
\BinaryBuilds\CronBuzzPHP\NotificationList::update( 'list id', 'new name');
Delete Notification List
\BinaryBuilds\CronBuzzPHP\NotificationList::delete( 'list id');
Tags
List Tags
\BinaryBuilds\CronBuzzPHP\Tag::list();
Show Tag
\BinaryBuilds\CronBuzzPHP\Tag::get( 'tag id');
Create Tag
\BinaryBuilds\CronBuzzPHP\Tag::create( 'tag name');
Update Tag
\BinaryBuilds\CronBuzzPHP\Tag::update( 'tag id', 'new name');
Delete Tag
\BinaryBuilds\CronBuzzPHP\Tag::delete( 'tag id');
Security Vulnerabilities
If you found a security vulnerability with in this package, Please do not use the issue tracker. Instead send an email to support@cronbuzz.com
. All security vulnerabilities will be addressed promptly.
License
This package is open-sourced software licensed under the MIT license.