use of alien4cloud.model.orchestrators.Orchestrator in project alien4cloud by alien4cloud.
the class OrchestratorController method update.
@ApiOperation(value = "Update the name of an existing orchestrators.", authorizations = { @Authorization("ADMIN") })
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
@Audit
public RestResponse<Void> update(@ApiParam(value = "Id of the orchestrators to update.", required = true) @PathVariable @Valid @NotEmpty String id, @ApiParam(value = "Orchestrator update request, representing the fields to updates and their new values.", required = true) @Valid @NotEmpty @RequestBody UpdateOrchestratorRequest request) {
Orchestrator orchestrator = orchestratorService.getOrFail(id);
String currentName = orchestrator.getName();
ReflectionUtil.mergeObject(request, orchestrator);
orchestratorService.ensureNameUnicityAndSave(orchestrator, currentName);
return RestResponseBuilder.<Void>builder().build();
}
use of alien4cloud.model.orchestrators.Orchestrator in project alien4cloud by alien4cloud.
the class OrchestratorController method delete.
@ApiOperation(value = "Delete an existing orchestrators.", authorizations = { @Authorization("ADMIN") })
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@PreAuthorize("hasAuthority('ADMIN')")
@Audit
public RestResponse<Void> delete(@ApiParam(value = "Id of the orchestrators to delete.", required = true) @PathVariable @Valid @NotEmpty String id) {
Orchestrator orchestrator = orchestratorService.getOrFail(id);
if (!orchestrator.getState().equals(OrchestratorState.DISABLED)) {
return RestResponseBuilder.<Void>builder().error(RestErrorBuilder.builder(RestErrorCode.ILLEGAL_STATE_OPERATION).message("An activated orchestrator can not be deleted").build()).build();
}
orchestratorService.delete(id);
return RestResponseBuilder.<Void>builder().build();
}
use of alien4cloud.model.orchestrators.Orchestrator 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();
}
Aggregations