Differential D13874 Diff 33503 src/applications/harbormaster/conduit/HarbormasterStartLogConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/conduit/HarbormasterStartLogConduitAPIMethod.php
- This file was added.
| <?php | |||||
| final class HarbormasterStartLogConduitAPIMethod | |||||
| extends HarbormasterConduitAPIMethod { | |||||
| public function getAPIMethodName() { | |||||
| return 'harbormaster.startlog'; | |||||
| } | |||||
| public function getMethodDescription() { | |||||
| return pht( | |||||
| 'Creates a new log artifact against a Harbormaster build target '. | |||||
| 'and returns the log artifact PHID.'); | |||||
| } | |||||
| protected function defineParamTypes() { | |||||
| return array( | |||||
| 'buildTargetPHID' => 'required phid', | |||||
| 'logSource' => 'required string', | |||||
| 'logType' => 'required string', | |||||
| ); | |||||
| } | |||||
| protected function defineReturnType() { | |||||
| return 'array'; | |||||
| } | |||||
| protected function execute(ConduitAPIRequest $request) { | |||||
| $viewer = $request->getUser(); | |||||
| $build_target_phid = $request->getValue('buildTargetPHID'); | |||||
| $log_source = $request->getValue('logSource'); | |||||
| $log_type = $request->getValue('logType'); | |||||
| $build_target = id(new HarbormasterBuildTargetQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withPHIDs(array($build_target_phid)) | |||||
| ->executeOne(); | |||||
| if (!$build_target) { | |||||
| throw new Exception(pht('No such build target!')); | |||||
| } | |||||
| $build = $build_target->getBuild(); | |||||
| $log = $build->createLog($build_target, $log_source, $log_type); | |||||
| $start = $log->start(); | |||||
| return array( | |||||
| 'buildLogPHID' => $log->getPHID(), | |||||
| 'startTimestamp' => $start, | |||||
| ); | |||||
| } | |||||
| } | |||||