forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConduitAPI_daemon_setstatus_Method.php
50 lines (39 loc) · 1.09 KB
/
ConduitAPI_daemon_setstatus_Method.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
42
43
44
45
46
47
48
49
50
<?php
/**
* @group conduit
*/
final class ConduitAPI_daemon_setstatus_Method extends ConduitAPIMethod {
public function shouldRequireAuthentication() {
// TODO: Lock this down once we build phantoms.
return false;
}
public function shouldAllowUnguardedWrites() {
return true;
}
public function getMethodDescription() {
return "Used by daemons to update their status.";
}
public function defineParamTypes() {
return array(
'daemonLogID' => 'required string',
'status' => 'required enum<unknown, run, timeout, dead, exit>',
);
}
public function defineReturnType() {
return 'void';
}
public function defineErrorTypes() {
return array(
'ERR-INVALID-ID' => 'An invalid daemonLogID was provided.',
);
}
protected function execute(ConduitAPIRequest $request) {
$daemon_log = id(new PhabricatorDaemonLog())
->load($request->getValue('daemonLogID'));
if (!$daemon_log) {
throw new ConduitException('ERR-INVALID-ID');
}
$daemon_log->setStatus($request->getValue('status'));
$daemon_log->save();
}
}