public function getScalingMetric($metricName, $restrictToCurrentScope = false)
{
$criteria = $this->getDefaultCriteria();
$criteria[] = ['name' => $metricName];
/* @var $event Entity\ScalingMetric */
$metric = Entity\scalingMetric::findOne($criteria);
if (empty($metric)) {
throw new ApiErrorException(404, ErrorMessage::ERR_OBJECT_NOT_FOUND, sprintf("The Scaling Metric either does not exist or isn't in scope for the current %s.", $this->getScope()));
}
if ($restrictToCurrentScope && $metric->getScope() !== $this->getScope()) {
throw new ApiErrorException(403, ErrorMessage::ERR_SCOPE_VIOLATION, "The Scaling Metric is not either from the {$this->getScope()} scope or owned by your {$this->getScope()}.");
}
return $metric;
}