1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sjdaws\NewRelicApi\Application; |
4
|
|
|
|
5
|
|
|
use Sjdaws\NewRelicApi\Application; |
6
|
|
|
|
7
|
|
|
class Deployments extends Application |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Record a new deployment |
11
|
|
|
* |
12
|
|
|
* @param string $revision |
13
|
|
|
* @param string $changelog |
14
|
|
|
* @param string $description |
15
|
|
|
* @param string $user |
16
|
|
|
* @throws Exception If appId is missing or any parameters is not a string or too long |
17
|
|
|
* @throws GuzzleHttp\Exception\ClientException Exception thrown by Guzzle |
18
|
|
|
* @return GuzzleHttp\Psr7\Stream The guzzle response body |
19
|
|
|
*/ |
20
|
|
|
public function add($revision, $changelog = '', $description = '', $user = '') |
21
|
|
|
{ |
22
|
|
|
// We must have an app id set or a deployment can't be recorded |
23
|
|
|
$this->checkAppId(); |
24
|
|
|
|
25
|
|
|
// Check parameters |
26
|
|
|
$this->checkString('revision', $revision, 127); |
27
|
|
|
$this->checkString('changelog', $changelog, 65535); |
28
|
|
|
$this->checkString('description', $description, 65535); |
29
|
|
|
$this->checkString('user', $user, 31); |
30
|
|
|
|
31
|
|
|
$this->addData('deployment', array( |
32
|
|
|
'revision' => $revision, |
33
|
|
|
'changelog' => $changelog, |
34
|
|
|
'description' => $description, |
35
|
|
|
'user' => $user, |
36
|
|
|
)); |
37
|
|
|
|
38
|
|
|
$this->addLog('debug', "Setting revision to '" . $revision . "'"); |
39
|
|
|
$this->addLog('debug', "Setting changelog to '" . $changelog . "'"); |
40
|
|
|
$this->addLog('debug', "Setting description to '" . $description . "'"); |
41
|
|
|
$this->addLog('debug', "Setting user to '" . $user . "'"); |
42
|
|
|
|
43
|
|
|
return $this->request('applications/' . $this->appId . '/deployments.json', 'POST'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Get a list of deployments made for an application |
48
|
|
|
* |
49
|
|
|
* @throws GuzzleHttp\Exception\ClientException Exception thrown by Guzzle |
50
|
|
|
* @return GuzzleHttp\Psr7\Stream The guzzle response body |
51
|
|
|
*/ |
52
|
|
|
public function get() |
53
|
|
|
{ |
54
|
|
|
// We must have an app id set or a deployment can't be recorded |
55
|
|
|
$this->checkAppId(); |
56
|
|
|
|
57
|
|
|
return $this->request('applications/' . $this->appId . '/deployments.json'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Get a list of deployments made for an application |
62
|
|
|
* |
63
|
|
|
* @throws GuzzleHttp\Exception\ClientException Exception thrown by Guzzle |
64
|
|
|
* @return GuzzleHttp\Psr7\Stream The guzzle response body |
65
|
|
|
*/ |
66
|
|
|
public function delete($deploymentId) |
67
|
|
|
{ |
68
|
|
|
// We must have an app id set or a deployment can't be recorded |
69
|
|
|
$this->checkAppId(); |
70
|
|
|
|
71
|
|
|
// Deployment id must be a positive integer |
72
|
|
|
$this->checkInteger('deployment id', $deploymentId, true); |
73
|
|
|
|
74
|
|
|
return $this->request('applications/' . $this->appId . '/deployments/' . $deploymentId . '.json', 'DELETE'); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|