Skip to content

Commit ea3b34e

Browse files
committed
* Added dedicated ping metrics method
1 parent f1a0b66 commit ea3b34e

File tree

1 file changed

+2
-66
lines changed

1 file changed

+2
-66
lines changed

src/eCloud/MonitoringClient.php

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -6,70 +6,6 @@
66
use UKFast\SDK\Traits\PageItems;
77
use UKFast\SDK\eCloud\Entities\Instance;
88

9-
class MonitoringClient extends Client implements ClientEntityInterface
10-
{
11-
use PageItems;
12-
13-
protected $collectionPath = 'v2/monitoring';
14-
15-
public function getEntityMap()
16-
{
17-
return [
18-
'id' => 'id',
19-
'name' => 'name',
20-
];
21-
}
22-
23-
/**
24-
* @param $data
25-
* @return Instance
26-
*/
27-
public function loadEntity($data)
28-
{
29-
return new Instance(
30-
$this->apiToFriendly($data, $this->getEntityMap())
31-
);
32-
}
33-
34-
/**
35-
* @param string $vmId
36-
* @return array|string
37-
* @throws \GuzzleHttp\Exception\GuzzleException
38-
*/
39-
public function getAvailableMetrics(string $vmId)
40-
{
41-
try {
42-
$data = $this->get($this->collectionPath . "/{$vmId}");
43-
} catch (\Exception $e) {
44-
return [];
45-
}
46-
return $data->getBody()->getContents();
47-
}
48-
49-
/**
50-
* @param int $widgetId
51-
* @param $additionalQueryParams
52-
* @return array|string
53-
* @throws \GuzzleHttp\Exception\GuzzleException
54-
*/
55-
public function getMetrics(int $widgetId, $additionalQueryParams)
56-
{
57-
try {
58-
$data = $this->get($this->collectionPath . "/{$widgetId}/widget?{$additionalQueryParams}");
59-
} catch (\Exception $e) {
60-
return [];
61-
}
62-
return $data->getBody()->getContents();
63-
}
64-
65-
66-
67-
namespace UKFast\SDK\eCloud;
68-
69-
use UKFast\SDK\Entities\ClientEntityInterface;
70-
use UKFast\SDK\Traits\PageItems;
71-
use UKFast\SDK\eCloud\Entities\Instance;
72-
739
class MonitoringClient extends Client implements ClientEntityInterface
7410
{
7511
use PageItems;
@@ -116,7 +52,7 @@ public function getAvailableMetrics(string $vmId)
11652
* @return array|string
11753
* @throws \GuzzleHttp\Exception\GuzzleException
11854
*/
119-
public function getMetrics(string $widgetId, $additionalQueryParams)
55+
public function getMetrics(int $widgetId, $additionalQueryParams)
12056
{
12157
try {
12258
$data = $this->get($this->collectionPath . "/{$widgetId}/widget?{$additionalQueryParams}");
@@ -130,7 +66,7 @@ public function getMetrics(string $widgetId, $additionalQueryParams)
13066
* @param int $pingId
13167
* @param int $instanceId
13268
* @param $additionalQueryParams
133-
* @return array|string
69+
* @return string
13470
* @throws \GuzzleHttp\Exception\GuzzleException
13571
*/
13672
public function getPingMetrics(int $pingId, int $instanceId, $additionalQueryParams)

0 commit comments

Comments
 (0)