Search in sources :

Example 1 with CsarResponse

use of org.opentosca.toscana.api.model.CsarResponse in project TOSCAna by StuPro-TOSCAna.

the class CsarController method listCSARs.

/**
 *     Responds with a list of csars stored on the transformer.
 *     <p>
 *     This always responds with HTTP-Code 200 (application/hal+json)
 */
@ApiOperation(value = "List all CSARs stored on the server", notes = "Returns a Hypermedia Resource containing all CSARs" + " that have been uploaded to the server and did not get removed", response = CsarResources.class, produces = "application/hal+json")
@RequestMapping(path = "", method = RequestMethod.GET, produces = "application/hal+json")
public ResponseEntity<Resources<CsarResponse>> listCSARs() {
    Link selfLink = linkTo(methodOn(CsarController.class).listCSARs()).withSelfRel();
    List<CsarResponse> responses = new ArrayList<>();
    for (Csar csar : csarService.getCsars()) {
        responses.add(new CsarResponse(csar.getIdentifier(), csar.getLifecyclePhases()));
    }
    Resources<CsarResponse> csarResources = new HiddenResources<>(responses, selfLink);
    return ResponseEntity.ok().body(csarResources);
}
Also used : Csar(org.opentosca.toscana.core.csar.Csar) HiddenResources(org.opentosca.toscana.api.docs.HiddenResources) ArrayList(java.util.ArrayList) CsarResponse(org.opentosca.toscana.api.model.CsarResponse) Link(org.springframework.hateoas.Link) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)1 ArrayList (java.util.ArrayList)1 HiddenResources (org.opentosca.toscana.api.docs.HiddenResources)1 CsarResponse (org.opentosca.toscana.api.model.CsarResponse)1 Csar (org.opentosca.toscana.core.csar.Csar)1 Link (org.springframework.hateoas.Link)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1