mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
41 lines
1011 B
PHP
41 lines
1011 B
PHP
<?php
|
|
|
|
namespace LibreNMS\Alert\Transport;
|
|
|
|
use LibreNMS\Alert\Transport;
|
|
use LibreNMS\Exceptions\AlertTransportDeliveryException;
|
|
use LibreNMS\Util\Http;
|
|
|
|
class JiraServiceManagement extends Transport
|
|
{
|
|
public function deliverAlert(array $alert_data): bool
|
|
{
|
|
$url = $this->config['jsm-url'];
|
|
|
|
$res = Http::client()->post($url, $alert_data);
|
|
|
|
if ($res->successful()) {
|
|
return true;
|
|
}
|
|
|
|
throw new AlertTransportDeliveryException($alert_data, $res->status(), $res->body(), '', $alert_data);
|
|
}
|
|
|
|
public static function configTemplate(): array
|
|
{
|
|
return [
|
|
'config' => [
|
|
[
|
|
'title' => 'Webhook URL',
|
|
'name' => 'jsm-url',
|
|
'descr' => 'Jira Service Management Webhook URL',
|
|
'type' => 'text',
|
|
],
|
|
],
|
|
'validation' => [
|
|
'jsm-url' => 'required|url',
|
|
],
|
|
];
|
|
}
|
|
}
|