3 final class DrydockManagementReleaseResourceWorkflow
4 extends DrydockManagementWorkflow
{
6 protected function didConstruct() {
8 ->setName('release-resource')
9 ->setSynopsis(pht('Release a resource.'))
16 'help' => pht('Resource ID to release.'),
21 public function execute(PhutilArgumentParser
$args) {
22 $ids = $args->getArg('id');
24 throw new PhutilArgumentUsageException(
26 'Specify one or more resource IDs to release with "%s".',
30 $viewer = $this->getViewer();
31 $drydock_phid = id(new PhabricatorDrydockApplication())->getPHID();
33 $resources = id(new DrydockResourceQuery())
38 PhabricatorWorker
::setRunAllTasksInProcess(true);
39 foreach ($ids as $id) {
40 $resource = idx($resources, $id);
45 pht('Resource "%s" does not exist.', $id));
49 if (!$resource->canRelease()) {
52 pht('Resource "%s" is not releasable.', $id));
56 $command = DrydockCommand
::initializeNewCommand($viewer)
57 ->setTargetPHID($resource->getPHID())
58 ->setAuthorPHID($drydock_phid)
59 ->setCommand(DrydockCommand
::COMMAND_RELEASE
)
62 $resource->scheduleUpdate();
66 pht('Scheduled release of resource "%s".', $id));