1 | <?php |
||
7 | class PagerDutyMessage |
||
8 | { |
||
9 | const EVENT_TRIGGER = 'trigger'; |
||
10 | const EVENT_RESOLVE = 'resolve'; |
||
11 | |||
12 | protected $payload = []; |
||
13 | protected $meta = []; |
||
14 | |||
15 | 18 | public function __construct() |
|
16 | { |
||
17 | 18 | Arr::set($this->meta, 'event_action', self::EVENT_TRIGGER); |
|
18 | |||
19 | 18 | Arr::set($this->payload, 'source', gethostname()); |
|
20 | 18 | Arr::set($this->payload, 'severity', 'critical'); |
|
21 | 18 | } |
|
22 | |||
23 | 18 | public function routingKey($value) |
|
24 | { |
||
25 | 18 | return $this->setMeta('routing_key', $value); |
|
26 | } |
||
27 | |||
28 | 2 | public function resolve() |
|
29 | { |
||
30 | 2 | return $this->setMeta('event_action', self::EVENT_RESOLVE); |
|
31 | } |
||
32 | |||
33 | 4 | public function dedupKey($key) |
|
34 | { |
||
35 | 4 | return $this->setMeta('dedup_key', $key); |
|
36 | } |
||
37 | |||
38 | 8 | public function summary($value) |
|
39 | { |
||
40 | 8 | return $this->setPayload('summary', $value); |
|
41 | } |
||
42 | |||
43 | 16 | public function source($value) |
|
44 | { |
||
45 | 16 | return $this->setPayload('source', $value); |
|
46 | } |
||
47 | |||
48 | 2 | public function severity($value) |
|
49 | { |
||
50 | 2 | return $this->setPayload('severity', $value); |
|
51 | } |
||
52 | |||
53 | 2 | public function timestamp($value) |
|
54 | { |
||
55 | 2 | return $this->setPayload('timestamp', $value); |
|
56 | } |
||
57 | |||
58 | 2 | public function component($value) |
|
59 | { |
||
60 | 2 | return $this->setPayload('component', $value); |
|
61 | } |
||
62 | |||
63 | public function group($value) |
||
67 | |||
68 | 2 | public function setClass($value) |
|
69 | { |
||
70 | 2 | return $this->setPayload('class', $value); |
|
71 | } |
||
72 | |||
73 | 2 | public function addCustomDetail($key, $value) |
|
74 | { |
||
75 | 2 | return $this->setPayload("custom_details.$key", $value); |
|
76 | } |
||
77 | |||
78 | 18 | protected function setPayload($key, $value) |
|
84 | |||
85 | 18 | protected function setMeta($key, $value) |
|
91 | |||
92 | 18 | public function toArray() |
|
96 | } |
||
97 |