jtl-software / opsgenie-client
Installs: 104 735
Dependents: 3
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 3
Open Issues: 0
Type:project
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.8
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.40
- phpstan/phpstan: ^1.10.46
- phpunit/phpunit: ^10.4.2
- rector/rector: ^0.18.11
README
PHP implementation to connect to OpsGenie Alert API. The implementation is focused on what we require @JTL for our application Alerting.
https://docs.opsgenie.com/docs/alert-api
Features
- Create Alert
- Get specific Alert (by alias) from API
- Close Alert
- Ping Heatbeat
How-To-Use
Create / Get / Close Alert
# named constructor to create a client (for EU) $client = AlertApiClient::createForEUApi(getenv(UPSGENIE_TOKEN)); $alert = new Alert('eazyauction', 'test-alert', 'foo mag bär', 'beer-bar'); $response = $client->createAlert($alert); if($response->isSuccessful()){ // read our former created alert $alert = $client->getAlert(new GetAlertRequest($alert->getAlias())); // close our former created alert $client->closeAlert(new CloseAlertRequest($alert->getAlias())); }
Ping Heartbeat
$token = "xxx-xxx-xxx"; $client = new HeartbeatApiClient(HttpClient::createForEUApi(getenv(UPSGENIE_TOKEN))); do { $result = $client->sendPing(new PingRequest('beat')); var_dump($result, $result->isSuccessful()); sleep(60); } while(true);