1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the hogosha-monitor package |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2016 Guillaume Cavana |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* Feel free to edit as you please, and have fun. |
12
|
|
|
* |
13
|
|
|
* @author Guillaume Cavana <[email protected]> |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace Hogosha\Monitor\Pusher; |
17
|
|
|
|
18
|
|
|
use Hogosha\Monitor\Model\Result; |
19
|
|
|
use Hogosha\Sdk\Api\Client; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Class AbstractPusher. |
23
|
|
|
*/ |
24
|
|
|
abstract class AbstractPusher implements PusherInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* $client. |
28
|
|
|
* |
29
|
|
|
* @var Client |
30
|
|
|
*/ |
31
|
|
|
protected $client; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* $options. |
35
|
|
|
* |
36
|
|
|
* @var array |
37
|
|
|
*/ |
38
|
|
|
protected $options; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Constructor. |
42
|
|
|
* |
43
|
|
|
* @param array $options |
44
|
|
|
*/ |
45
|
|
|
public function __construct(array $options) |
46
|
|
|
{ |
47
|
|
|
$this->options = $options; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* getDefaultFailedIncidentMessage. |
52
|
|
|
* |
53
|
|
|
* @return string Default message used to create a incident when a failure as occured |
54
|
|
|
*/ |
55
|
|
|
public function getDefaultFailedIncidentMessage() |
56
|
|
|
{ |
57
|
|
|
return $this->options['default_failed_incident_message']; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* getDefaultResolvedIncidentMessage. |
62
|
|
|
* |
63
|
|
|
* @return string Default message used to create a incident when a service is resolved as occured |
64
|
|
|
*/ |
65
|
|
|
public function getDefaultResolvedIncidentMessage() |
66
|
|
|
{ |
67
|
|
|
return $this->options['default_resolved_incident_message']; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* getClient. |
72
|
|
|
* |
73
|
|
|
* @return Client |
74
|
|
|
*/ |
75
|
|
|
public function getClient() |
76
|
|
|
{ |
77
|
|
|
return new Client( |
78
|
|
|
[ |
79
|
|
|
'username' => $this->options['username'], |
80
|
|
|
'password' => $this->options['password'], |
81
|
|
|
'base_uri' => $this->options['base_uri'], |
82
|
|
|
] |
83
|
|
|
); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* push. |
88
|
|
|
* |
89
|
|
|
* @param Result $result |
90
|
|
|
* |
91
|
|
|
* @return mixed |
92
|
|
|
*/ |
93
|
|
|
abstract public function push(Result $result); |
94
|
|
|
} |
95
|
|
|
|