|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ZoiloMora\ElasticAPM\Events\Common; |
|
4
|
|
|
|
|
5
|
|
|
use ZoiloMora\ElasticAPM\Events\Common\Cloud\Account; |
|
6
|
|
|
use ZoiloMora\ElasticAPM\Events\Common\Cloud\Instance; |
|
7
|
|
|
use ZoiloMora\ElasticAPM\Events\Common\Cloud\Machine; |
|
8
|
|
|
use ZoiloMora\ElasticAPM\Events\Common\Cloud\Project; |
|
9
|
|
|
use ZoiloMora\ElasticAPM\Helper\Encoding; |
|
10
|
|
|
|
|
11
|
|
|
final class Cloud implements \JsonSerializable |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var Account|null |
|
15
|
|
|
*/ |
|
16
|
|
|
private $account; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Cloud availability zone name. e.g. us-east-1a |
|
20
|
|
|
* |
|
21
|
|
|
* @var string|null |
|
22
|
|
|
*/ |
|
23
|
|
|
private $availabilityZone; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var Instance|null |
|
27
|
|
|
*/ |
|
28
|
|
|
private $instance; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var Machine|null |
|
32
|
|
|
*/ |
|
33
|
|
|
private $machine; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var Project|null |
|
37
|
|
|
*/ |
|
38
|
|
|
private $project; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Cloud provider name. e.g. aws, azure, gcp, digitalocean. |
|
42
|
|
|
* |
|
43
|
|
|
* @var string|null |
|
44
|
|
|
*/ |
|
45
|
|
|
private $provider; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Cloud region name. e.g. us-east-1 |
|
49
|
|
|
* |
|
50
|
|
|
* @var string|null |
|
51
|
|
|
*/ |
|
52
|
|
|
private $region; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param string|null $provider |
|
56
|
|
|
* @param Account|null $account |
|
57
|
|
|
* @param string|null $availabilityZone |
|
58
|
|
|
* @param Instance|null $instance |
|
59
|
|
|
* @param Machine|null $machine |
|
60
|
|
|
* @param Project|null $project |
|
61
|
|
|
* @param string|null $region |
|
62
|
|
|
*/ |
|
63
|
3 |
|
public function __construct( |
|
64
|
|
|
$provider = null, |
|
65
|
|
|
Account $account = null, |
|
66
|
|
|
$availabilityZone = null, |
|
67
|
|
|
Instance $instance = null, |
|
68
|
|
|
Machine $machine = null, |
|
69
|
|
|
Project $project = null, |
|
70
|
|
|
$region = null |
|
71
|
|
|
) { |
|
72
|
3 |
|
$this->provider = $provider; |
|
73
|
3 |
|
$this->account = $account; |
|
74
|
3 |
|
$this->availabilityZone = $availabilityZone; |
|
75
|
3 |
|
$this->instance = $instance; |
|
76
|
3 |
|
$this->machine = $machine; |
|
77
|
3 |
|
$this->project = $project; |
|
78
|
3 |
|
$this->region = $region; |
|
79
|
3 |
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @return Account |
|
83
|
|
|
*/ |
|
84
|
1 |
|
public function account() |
|
85
|
|
|
{ |
|
86
|
1 |
|
return $this->account; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @return string|null |
|
91
|
|
|
*/ |
|
92
|
1 |
|
public function availabilityZone() |
|
93
|
|
|
{ |
|
94
|
1 |
|
return $this->availabilityZone; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @return Instance |
|
99
|
|
|
*/ |
|
100
|
1 |
|
public function instance() |
|
101
|
|
|
{ |
|
102
|
1 |
|
return $this->instance; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @return Machine |
|
107
|
|
|
*/ |
|
108
|
1 |
|
public function machine() |
|
109
|
|
|
{ |
|
110
|
1 |
|
return $this->machine; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* @return Project |
|
115
|
|
|
*/ |
|
116
|
1 |
|
public function project() |
|
117
|
|
|
{ |
|
118
|
1 |
|
return $this->project; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @return string|null |
|
123
|
|
|
*/ |
|
124
|
1 |
|
public function provider() |
|
125
|
|
|
{ |
|
126
|
1 |
|
return $this->provider; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* @return string|null |
|
131
|
|
|
*/ |
|
132
|
1 |
|
public function region() |
|
133
|
|
|
{ |
|
134
|
1 |
|
return $this->region; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* @return array |
|
139
|
|
|
*/ |
|
140
|
1 |
|
public function jsonSerialize() |
|
141
|
|
|
{ |
|
142
|
|
|
return [ |
|
143
|
1 |
|
'account' => $this->account, |
|
144
|
1 |
|
'availability_zone' => Encoding::keywordField($this->availabilityZone), |
|
145
|
1 |
|
'instance' => $this->instance, |
|
146
|
1 |
|
'machine' => $this->machine, |
|
147
|
1 |
|
'project' => $this->project, |
|
148
|
1 |
|
'provider' => Encoding::keywordField($this->provider), |
|
149
|
1 |
|
'region' => Encoding::keywordField($this->region), |
|
150
|
1 |
|
]; |
|
151
|
|
|
} |
|
152
|
|
|
} |
|
153
|
|
|
|