Scalr\Api\Service\Account\V1beta0\Controller\Environments::getCloudCredentials PHP Метод

getCloudCredentials() публичный Метод

Gets CloudCredentials entity
public getCloudCredentials ( string $cloudCredentialsId ) : CloudCredentials
$cloudCredentialsId string Unique identifier of the CloudCredentials
Результат Scalr\Model\Entity\CloudCredentials
    public function getCloudCredentials($cloudCredentialsId)
    {
        /* @var $cloudCredentials Entity\CloudCredentials */
        $cloudCredentials = Entity\CloudCredentials::findPk($cloudCredentialsId);
        if (empty($cloudCredentials)) {
            throw new ApiErrorException(404, ErrorMessage::ERR_OBJECT_NOT_FOUND, "Requested Cloud Credentials either does not exist or is not owned by you.");
        }
        switch ($cloudCredentials->getScope()) {
            case ScopeInterface::SCOPE_SCALR:
                break;
            case ScopeInterface::SCOPE_ACCOUNT:
                if ($cloudCredentials->accountId != $this->getUser()->getAccountId()) {
                    throw new ApiErrorException(404, ErrorMessage::ERR_OBJECT_NOT_FOUND, "Requested Cloud Credentials either does not exist or is not owned by you.");
                }
                break;
            case ScopeInterface::SCOPE_ENVIRONMENT:
                if (!($this->getUser()->canManageAcl() || $this->getUser()->hasAccessToEnvironment($cloudCredentials->envId))) {
                    throw new ApiErrorException(403, ErrorMessage::ERR_PERMISSION_VIOLATION, "Insufficient permissions");
                }
        }
        return $cloudCredentials;
    }