Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop PDConnect Install links #13407

Merged
merged 5 commits into from Oct 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
60 changes: 1 addition & 59 deletions LibreNMS/Alert/Transport/Pagerduty.php
Expand Up @@ -25,17 +25,13 @@

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)
{
Expand Down Expand Up @@ -102,22 +98,6 @@ public static function configTemplate()
{
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',
Expand All @@ -129,17 +109,7 @@ public static function configTemplate()
],
],
[
'title' => 'Account',
'type' => 'hidden',
'name' => 'account',
],
[
'title' => 'Service',
'type' => 'hidden',
'name' => 'service_name',
],
[
'title' => 'Integration Key',
'title' => 'Routing Key',
'type' => 'text',
'name' => 'service_key',
],
Expand All @@ -149,32 +119,4 @@ public static function configTemplate()
],
];
}

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');
}
}
}