Scalr\Api\Service\User\V1beta0\Controller\ScriptVersions::getVersion PHP Method

getVersion() public method

Gets specified Version for the Script taking into account both scope and authentication token
public getVersion ( string $scriptId, integer $versionNumber, boolean $modify = false ) : Scalr\Model\Entity\ScriptVersion
$scriptId string Numeric identifier of the Script
$versionNumber integer Script version number
$modify boolean optional Flag checking write permissions
return Scalr\Model\Entity\ScriptVersion Returns the Script Entity on success
    public function getVersion($scriptId, $versionNumber, $modify = false)
    {
        $version = ScriptVersion::findPk($scriptId, $versionNumber);
        if (!$version) {
            throw new ApiErrorException(404, ErrorMessage::ERR_OBJECT_NOT_FOUND, "Requested Version either does not exist or is not owned by your environment.");
        }
        if (!$this->hasPermissions($version, $modify)) {
            //Checks entity level write access permissions
            throw new ApiErrorException(403, ErrorMessage::ERR_PERMISSION_VIOLATION, "Insufficient permissions");
        }
        return $version;
    }