diff --git a/LibreNMS/Alert/Transport/Pagerduty.php b/LibreNMS/Alert/Transport/Pagerduty.php index 8a98478896..9837fa013e 100644 --- a/LibreNMS/Alert/Transport/Pagerduty.php +++ b/LibreNMS/Alert/Transport/Pagerduty.php @@ -25,17 +25,13 @@ namespace LibreNMS\Alert\Transport; use GuzzleHttp\Client; use GuzzleHttp\Exception\GuzzleException; -use Illuminate\Http\Request; use LibreNMS\Alert\Transport; use LibreNMS\Enum\AlertState; use LibreNMS\Util\Proxy; -use Log; -use Validator; class Pagerduty extends Transport { protected $name = 'PagerDuty'; - public static $integrationKey = '2fc7c9f3c8030e74aae6'; public function deliverAlert($obj, $opts) { @@ -102,22 +98,6 @@ class Pagerduty extends Transport { return [ 'config' => [ - [ - 'title' => 'Authorize (EU)', - 'descr' => 'Alert with PagerDuty', - 'type' => 'oauth', - 'icon' => 'pagerduty-white.svg', - 'class' => 'btn-success', - 'url' => 'https://connect.eu.pagerduty.com/connect?vendor=' . self::$integrationKey . '&callback=', - ], - [ - 'title' => 'Authorize (US)', - 'descr' => 'Alert with PagerDuty', - 'type' => 'oauth', - 'icon' => 'pagerduty-white.svg', - 'class' => 'btn-success', - 'url' => 'https://connect.pagerduty.com/connect?vendor=' . self::$integrationKey . '&callback=', - ], [ 'title' => 'Service Region', 'name' => 'region', @@ -129,17 +109,7 @@ class Pagerduty extends Transport ], ], [ - 'title' => 'Account', - 'type' => 'hidden', - 'name' => 'account', - ], - [ - 'title' => 'Service', - 'type' => 'hidden', - 'name' => 'service_name', - ], - [ - 'title' => 'Integration Key', + 'title' => 'Routing Key', 'type' => 'text', 'name' => 'service_key', ], @@ -149,32 +119,4 @@ class Pagerduty extends Transport ], ]; } - - public function handleOauth(Request $request) - { - $validator = Validator::make($request->all(), [ - 'account' => 'alpha_dash', - 'service_key' => 'regex:/^[a-fA-F0-9]+$/', - 'service_name' => 'string', - ]); - - if ($validator->fails()) { - Log::error('Pagerduty oauth failed validation.', ['request' => $request->all()]); - - return false; - } - - $config = json_encode($request->only('account', 'service_key', 'service_name')); - - if ($id = $request->get('id')) { - return (bool) dbUpdate(['transport_config' => $config], 'alert_transports', 'transport_id=?', [$id]); - } else { - return (bool) dbInsert([ - 'transport_name' => $request->get('service_name', 'PagerDuty'), - 'transport_type' => 'pagerduty', - 'is_default' => 0, - 'transport_config' => $config, - ], 'alert_transports'); - } - } }