Search in sources :

Example 11 with RestError

use of alien4cloud.rest.model.RestError in project alien4cloud by alien4cloud.

the class ApplicationDeploymentController method doUndeploy.

private RestResponse<Void> doUndeploy(String applicationId, String applicationEnvironmentId, SecretProviderConfigurationAndCredentials secretProviderConfigurationAndCredentials) {
    ApplicationEnvironment environment = applicationEnvironmentService.getEnvironmentByIdOrDefault(applicationId, applicationEnvironmentId);
    Application application = applicationService.checkAndGetApplication(applicationId);
    AuthorizationUtil.checkAuthorizationForEnvironment(application, environment);
    try {
        undeployService.undeployEnvironment(secretProviderConfigurationAndCredentials, applicationEnvironmentId);
    } catch (OrchestratorDisabledException e) {
        return RestResponseBuilder.<Void>builder().error(new RestError(RestErrorCode.CLOUD_DISABLED_ERROR.getCode(), e.getMessage())).build();
    }
    return RestResponseBuilder.<Void>builder().build();
}
Also used : OrchestratorDisabledException(alien4cloud.paas.exception.OrchestratorDisabledException) RestError(alien4cloud.rest.model.RestError) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment) Application(alien4cloud.model.application.Application)

Example 12 with RestError

use of alien4cloud.rest.model.RestError in project alien4cloud by alien4cloud.

the class OrchestratorController method disable.

@ApiOperation(value = "Disable an orchestrator. Destroys the instance of the orchestrator connector.", authorizations = { @Authorization("ADMIN") })
@RequestMapping(value = "/{id}/instance", method = RequestMethod.DELETE)
@PreAuthorize("hasAuthority('ADMIN')")
public RestResponse<List<Usage>> disable(@ApiParam(value = "Id of the orchestrator to enable", required = true) @PathVariable String id, @ApiParam(value = "This parameter is useful only when trying to disable the orchestrator, if deployments are performed using this orchestrator disable " + "operation will fail unnless the force flag is true", required = false) @RequestParam(required = false, defaultValue = "false") boolean force, @ApiParam(value = "In case an orchestrator with deployment is forced to be disabled, the user may decide to mark all deployments managed " + "by this orchestrator as ended.", required = false) @RequestParam(required = false, defaultValue = "false") boolean clearDeployments) {
    RestResponseBuilder<List<Usage>> responseBuilder = RestResponseBuilder.<List<Usage>>builder();
    Orchestrator orchestrator = orchestratorService.getOrFail(id);
    List<Usage> usages = orchestratorStateService.disable(orchestrator, force);
    if (CollectionUtils.isEmpty(usages)) {
        return responseBuilder.build();
    }
    return responseBuilder.data(usages).error(new RestError(RestErrorCode.RESOURCE_USED_ERROR.getCode(), "There are actives deployment with the orchestrator. It cannot be disabled.")).build();
}
Also used : Usage(alien4cloud.model.common.Usage) RestError(alien4cloud.rest.model.RestError) List(java.util.List) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RestError (alien4cloud.rest.model.RestError)12 ApiOperation (io.swagger.annotations.ApiOperation)10 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 Audit (alien4cloud.audit.annotation.Audit)7 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)5 OrchestratorDisabledException (alien4cloud.paas.exception.OrchestratorDisabledException)5 RestResponse (alien4cloud.rest.model.RestResponse)4 DeferredResult (org.springframework.web.context.request.async.DeferredResult)4 Application (alien4cloud.model.application.Application)3 DeploymentTopologyDTO (alien4cloud.deployment.DeploymentTopologyDTO)2 Deployment (alien4cloud.model.deployment.Deployment)2 DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)2 PaaSDeploymentException (alien4cloud.paas.exception.PaaSDeploymentException)2 TopologyValidationResult (alien4cloud.topology.TopologyValidationResult)2 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 Topology (org.alien4cloud.tosca.model.templates.Topology)2 NodeType (org.alien4cloud.tosca.model.types.NodeType)2 CSARUsedInActiveDeployment (alien4cloud.component.repository.exception.CSARUsedInActiveDeployment)1