Since: 5.11.7 (25.01.2016)
Author: Andrii Penchuk (a.penchuk@scalr.com)
Inheritance: extends Scalr\Api\Service\User\V1beta0\Adapter\ScalingRuleAdapter
Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  * @see BasicScalingRuleAdapter::validateEntity()
  */
 public function validateEntity($entity)
 {
     parent::validateEntity($entity);
     $this->validateNumericSetting($entity->settings, FarmRoleScalingMetric::PERIOD);
     if (!in_array($entity->settings[FarmRoleScalingMetric::PERIOD], static::$calculatingPeriod)) {
         throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, sprintf('Property calculatingPeriod is invalid. Allowed periods are %s', implode(', ', static::$calculatingPeriod)));
     }
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  * @see BasicScalingRuleAdapter::toEntity()
  */
 public function toEntity($data)
 {
     /* @var $entity FarmRoleScalingMetric */
     $entity = parent::toEntity($data);
     if (!isset($entity->settings[FarmRoleScalingMetric::USE_CACHED])) {
         $entity->settings[FarmRoleScalingMetric::USE_CACHED] = false;
     }
     return $entity;
 }
 /**
  * {@inheritdoc}
  * @see BasicScalingRuleAdapter::validateEntity()
  */
 public function validateEntity($entity)
 {
     parent::validateEntity($entity);
     if (empty($entity->settings[FarmRoleScalingMetric::URL])) {
         throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_STRUCTURE, 'Missed property url');
     }
     if (!filter_var($entity->settings[FarmRoleScalingMetric::URL], FILTER_VALIDATE_URL)) {
         throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, 'Property url is invalid');
     }
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  * @see BasicScalingRuleAdapter::validateEntity()
  */
 public function validateEntity($entity)
 {
     parent::validateEntity($entity);
     if (empty($entity->settings[FarmRoleScalingMetric::QUEUE_NAME])) {
         throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_STRUCTURE, 'Missed property queue');
     }
     if (!is_string($entity->settings[FarmRoleScalingMetric::QUEUE_NAME])) {
         throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, 'Unexpected queue value');
     }
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  * @see BasicScalingRuleAdapter::validateEntity()
  */
 public function validateEntity($entity)
 {
     parent::validateEntity($entity);
     $direction = $entity->settings[FarmRoleScalingMetric::TYPE];
     if (empty($direction)) {
         throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_STRUCTURE, 'Missed property direction');
     }
     if (!in_array($direction, static::$directions)) {
         throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, sprintf('Invalid value. The allowed direction values are %s', implode(' or ', static::$directions)));
     }
 }