|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
|
4
|
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Connector\ClientInterface; |
|
6
|
|
|
use AcquiaCloudApi\Response\CronsResponse; |
|
7
|
|
|
use AcquiaCloudApi\Response\CronResponse; |
|
8
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class Crons |
|
12
|
|
|
* @package AcquiaCloudApi\CloudApi |
|
13
|
|
|
*/ |
|
14
|
|
|
class Crons extends CloudApiBase implements CloudApiInterface |
|
15
|
|
|
{ |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Show all cron tasks for an environment. |
|
19
|
|
|
* |
|
20
|
|
|
* @param string $environmentUuid The environment ID |
|
21
|
|
|
* @return CronsResponse |
|
22
|
|
|
*/ |
|
23
|
|
|
public function getAll($environmentUuid) |
|
24
|
|
|
{ |
|
25
|
|
|
return new CronsResponse( |
|
26
|
|
|
$this->client->request( |
|
|
|
|
|
|
27
|
|
|
'get', |
|
28
|
|
|
"/environments/${environmentUuid}/crons" |
|
29
|
|
|
) |
|
30
|
|
|
); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Get information about a cron task. |
|
35
|
|
|
* |
|
36
|
|
|
* @param string $environmentUuid The environment ID |
|
37
|
|
|
* @param int $cronId |
|
38
|
|
|
* @return CronResponse |
|
39
|
|
|
*/ |
|
40
|
|
|
public function get($environmentUuid, $cronId) |
|
41
|
|
|
{ |
|
42
|
|
|
return new CronResponse( |
|
43
|
|
|
$this->client->request( |
|
|
|
|
|
|
44
|
|
|
'get', |
|
45
|
|
|
"/environments/${environmentUuid}/crons/${cronId}" |
|
46
|
|
|
) |
|
47
|
|
|
); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Add a cron task. |
|
52
|
|
|
* |
|
53
|
|
|
* @param string $environmentUuid |
|
54
|
|
|
* @param string $command |
|
55
|
|
|
* @param string $frequency |
|
56
|
|
|
* @param string $label |
|
57
|
|
|
* @return OperationResponse |
|
58
|
|
|
*/ |
|
59
|
|
|
public function create($environmentUuid, $command, $frequency, $label, $serverId = null) |
|
60
|
|
|
{ |
|
61
|
|
|
|
|
62
|
|
|
$options = [ |
|
63
|
|
|
'form_params' => [ |
|
64
|
|
|
'command' => $command, |
|
65
|
|
|
'frequency' => $frequency, |
|
66
|
|
|
'label' => $label, |
|
67
|
|
|
'server_id' => $serverId |
|
68
|
|
|
], |
|
69
|
|
|
]; |
|
70
|
|
|
|
|
71
|
|
|
return new OperationResponse( |
|
72
|
|
|
$this->client->request('post', "/environments/${environmentUuid}/crons", $options) |
|
|
|
|
|
|
73
|
|
|
); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Update a cron task. |
|
78
|
|
|
* |
|
79
|
|
|
* @param string $environmentUuid |
|
80
|
|
|
* @param string $command |
|
81
|
|
|
* @param string $frequency |
|
82
|
|
|
* @param string $label |
|
83
|
|
|
* @return OperationResponse |
|
84
|
|
|
*/ |
|
85
|
|
|
public function update($environmentUuid, $cronId, $command, $frequency, $label, $serverId = null) |
|
86
|
|
|
{ |
|
87
|
|
|
|
|
88
|
|
|
$options = [ |
|
89
|
|
|
'form_params' => [ |
|
90
|
|
|
'command' => $command, |
|
91
|
|
|
'frequency' => $frequency, |
|
92
|
|
|
'label' => $label, |
|
93
|
|
|
'server_id' => $serverId |
|
94
|
|
|
], |
|
95
|
|
|
]; |
|
96
|
|
|
|
|
97
|
|
|
return new OperationResponse( |
|
98
|
|
|
$this->client->request('post', "/environments/${environmentUuid}/crons/${cronId}", $options) |
|
|
|
|
|
|
99
|
|
|
); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Delete a cron task. |
|
104
|
|
|
* |
|
105
|
|
|
* @param string $environmentUuid |
|
106
|
|
|
* @param int $cronId |
|
107
|
|
|
* @return OperationResponse |
|
108
|
|
|
*/ |
|
109
|
|
|
public function delete($environmentUuid, $cronId) |
|
110
|
|
|
{ |
|
111
|
|
|
return new OperationResponse( |
|
112
|
|
|
$this->client->request('delete', "/environments/${environmentUuid}/crons/${cronId}") |
|
|
|
|
|
|
113
|
|
|
); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Disable a cron task. |
|
118
|
|
|
* |
|
119
|
|
|
* @param string $environmentUuid |
|
120
|
|
|
* @param int $cronId |
|
121
|
|
|
* @return OperationResponse |
|
122
|
|
|
*/ |
|
123
|
|
|
public function disable($environmentUuid, $cronId) |
|
124
|
|
|
{ |
|
125
|
|
|
return new OperationResponse( |
|
126
|
|
|
$this->client->request( |
|
|
|
|
|
|
127
|
|
|
'post', |
|
128
|
|
|
"/environments/${environmentUuid}/crons/${cronId}/actions/disable" |
|
129
|
|
|
) |
|
130
|
|
|
); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* Enable a cron task. |
|
135
|
|
|
* |
|
136
|
|
|
* @param string $environmentUuid |
|
137
|
|
|
* @param int $cronId |
|
138
|
|
|
* @return OperationResponse |
|
139
|
|
|
*/ |
|
140
|
|
|
public function enable($environmentUuid, $cronId) |
|
141
|
|
|
{ |
|
142
|
|
|
return new OperationResponse( |
|
143
|
|
|
$this->client->request( |
|
|
|
|
|
|
144
|
|
|
'post', |
|
145
|
|
|
"/environments/${environmentUuid}/crons/${cronId}/actions/enable" |
|
146
|
|
|
) |
|
147
|
|
|
); |
|
148
|
|
|
} |
|
149
|
|
|
} |
|
150
|
|
|
|