/
Metric.php
41 lines (32 loc) 路 1.03 KB
/
Metric.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace DivineOmega\CachetPHP\Models;
use DivineOmega\CachetPHP\Factories\MetricPointFactory;
class Metric extends ModelBase
{
public $id;
public $name;
public $description;
public $suffix;
public $display_chart;
public function getAllMetricPoints($sort = null, $order = null)
{
return MetricPointFactory::getAll($this->cachetInstance, $this, $sort, $order);
}
public function delete()
{
$this->cachetInstance->client()->request('metrics/'.$this->id, null, 'DELETE');
}
public function save()
{
$queryParams = [];
$queryParams['name'] = $this->name;
$queryParams['description'] = $this->description;
$queryParams['suffix'] = $this->suffix;
$queryParams['display_chart'] = $this->display_chart;
$this->cachetInstance->client()->request('metrics/'.$this->id, $queryParams, 'PUT');
}
public function createMetricPoint($data)
{
return MetricPointFactory::create($this->cachetInstance, $this, $data);
}
}