Drop PDConnect Install links (#13407)

* Drop PDConnect Install links

This flow has been removed.

* Update some terminology while I'm here

History time notes just for fun: 
 - it was called "service key" when you could only have one integration per service
 - it was called "integration key" when you could only have integrations on services
 - it's now called "routing key" to be inclusive of account-level routing keys

* Delete some code that should be unused now

* Tidy up imports

* I think these are also unused now
This commit is contained in:
Hannele Kormano
2021-10-22 19:53:36 +02:00
committed by GitHub
co-authored by GitHub
parent 50cf1a49f1
commit 688ec422de
+1 -59
View File
@@ -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');
}
}
}