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

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

Detach configured cloud configuration from specified environment
public detachCredentialsAction ( integer $envId, string $cloud ) : Scalr\Api\DataType\ResultEnvelope
$envId integer Environment ID
$cloud string Cloud platform name
Результат Scalr\Api\DataType\ResultEnvelope
    public function detachCredentialsAction($envId, $cloud)
    {
        if (!$this->getUser()->canManageAcl()) {
            $this->checkPermissions(Acl::RESOURCE_ENV_CLOUDS_ENVIRONMENT);
        }
        $env = $this->getEnv($envId);
        $cloudCredentials = $env->keychain($cloud);
        if (empty($cloudCredentials->id)) {
            throw new ApiErrorException(404, ErrorMessage::ERR_OBJECT_NOT_FOUND, "Cloud '{$cloud}' not configured for this environment");
        }
        if (in_array($cloudCredentials->cloud, [SERVER_PLATFORMS::EC2, SERVER_PLATFORMS::GCE]) && (count(Entity\Server::find([['envId' => $envId], ['platform' => $cloudCredentials->cloud]])) || count(Entity\Image::find([['envId' => $envId], ['platform' => $cloudCredentials->cloud]])))) {
            throw new ApiErrorException(409, ErrorMessage::ERR_OBJECT_IN_USE, "Cloud Credentials are used");
        }
        $cloudCredentials->environments[$envId]->delete();
        return $this->result(null);
    }