Author: N.V.
Inheritance: extends Scalr\Api\DataType\ApiEntityAdapter
Example #1
0
 /**
  * Terminates specified farm
  *
  * @param   int     $farmId Unique farm identifier
  *
  * @return ResultEnvelope
  * @throws ApiErrorException
  */
 public function terminateAction($farmId)
 {
     $farm = $this->getFarm($farmId, Acl::PERM_FARMS_LAUNCH_TERMINATE);
     $object = $this->request->getJsonBody();
     $force = isset($object->force) ? FarmAdapter::convertInputValue('boolean', $object->force) : false;
     try {
         $farm->checkLocked();
         \Scalr::FireEvent($farm->id, new FarmTerminatedEvent(false, false, false, false, $force, $this->getUser()->id));
     } catch (LockedException $e) {
         throw new ApiErrorException(409, ErrorMessage::ERR_LOCKED, $e->getMessage() . ", please unlock it first", $e->getCode(), $e);
     }
     $farmAdapter = $this->adapter('farm');
     return $this->result($farmAdapter->toData($farm));
 }