use of org.opentosca.toscana.api.model.GetOutputsResponse in project TOSCAna by StuPro-TOSCAna.
the class TransformationController method getOutputs.
/**
* Returns the outputs of a Transformation.
* <p>
* <table summary="">
* <tr>
* <td>HTTP-Code</td>
* <td>Mime-Type</td>
* <td>Description (Returned if)</td>
* </tr>
* <tr>
* <td>200</td>
* <td>application/hal+json</td>
* <td>Returns a List of the outputs. (Empty if no deployment has been executed)</td>
* </tr>
* <tr>
* <td>400</td>
* <td>application/json</td>
* <td>Returned if the transformation is not in a valid state (has to be in DONE or ERROR) to set inputs</td>
* </tr>
* <tr>
* <td>404</td>
* <td>application/json</td>
* <td>Returns a error message if the csar is not found or if the csar does not have a transformation for the given
* name (see returned error message for details)</td>
* </tr>
* </table>
*/
@ApiOperation(value = "Retrieve the outputs and their values", tags = { "transformations" }, notes = "This operation returns the outputs of a deployment. Retrieval of the outputs is not possible " + "if the transformation (including deployment) is not done yet")
@ApiResponses({ @ApiResponse(code = 200, message = "The operation was executed successfully", response = GetOutputsResponse.class), @ApiResponse(code = 404, message = "There is no CSAR for the given identifier or the CSAR does not have " + "a transformation for the specified platform", response = RestErrorResponse.class), @ApiResponse(code = 400, message = "The state of the transformation is invalid (not ERROR or DONE)", response = RestErrorResponse.class) })
@RequestMapping(path = "/{platform}/outputs", method = { RequestMethod.GET }, produces = "application/hal+json")
public ResponseEntity<GetOutputsResponse> getOutputs(@ApiParam(value = "The unique identifier for the CSAR", required = true, example = "test") @PathVariable(name = "csarId") String csarId, @ApiParam(value = "The identifier for the platform", required = true, example = "kubernetes") @PathVariable(name = "platform") String platformId) {
Csar csar = findByCsarId(csarId);
Transformation transformation = findTransformationByPlatform(csar, platformId);
if (transformation.getState() != TransformationState.DONE && transformation.getState() != TransformationState.ERROR) {
throw new IllegalTransformationStateException("The Transformation has not finished yet!");
}
List<OutputProperty> outputs = transformation.getOutputs();
List<OutputWrap> wrappedOutputs = outputs.stream().map(OutputWrap::new).collect(Collectors.toList());
return ResponseEntity.ok(new GetOutputsResponse(csarId, platformId, wrappedOutputs));
}
Aggregations