Search in sources :

Example 1 with PlatformResponse

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

the class PlatformController method getPlatforms.

/**
 *     Lists all Supported Platforms (HTTP Response Method).
 *     <p>
 *     It handles the <code>/platforms</code> Request
 *     <p>
 *     Always responds with HTTP-Code 200 (application/hal+json)
 */
@ApiOperation(value = "List all supported Platforms", notes = "Returns a HAL resource (_embedded) containing all " + "Platforms supported by this transformer", code = 200, response = PlatformResources.class)
@RequestMapping(path = "", method = RequestMethod.GET, produces = "application/hal+json")
public ResponseEntity<Resources<PlatformResponse>> getPlatforms() {
    Link selfLink = linkTo(methodOn(PlatformController.class).getPlatforms()).withSelfRel();
    ArrayList<PlatformResponse> responses = new ArrayList<>();
    for (Platform platform : platformService.getSupportedPlatforms()) {
        logger.info("Adding Platform {} to response ", platform.id);
        PlatformResponse res = getPlatformResource(platform);
        responses.add(res);
    }
    Resources<PlatformResponse> resources = new HiddenResources<>(responses, selfLink);
    return ResponseEntity.ok(resources);
}
Also used : HiddenResources(org.opentosca.toscana.api.docs.HiddenResources) Platform(org.opentosca.toscana.core.transformation.platform.Platform) ArrayList(java.util.ArrayList) PlatformResponse(org.opentosca.toscana.api.model.PlatformResponse) Link(org.springframework.hateoas.Link) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with PlatformResponse

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

the class PlatformController method getPlatformResource.

/**
 *     Generates a Platform Response and adds a self link to it.
 */
private PlatformResponse getPlatformResource(Platform platform) {
    PlatformResponse res = new PlatformResponse(platform);
    res.add(linkTo(methodOn(PlatformController.class).getPlatform(res.getIdentifier())).withSelfRel());
    return res;
}
Also used : PlatformResponse(org.opentosca.toscana.api.model.PlatformResponse)

Aggregations

PlatformResponse (org.opentosca.toscana.api.model.PlatformResponse)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ArrayList (java.util.ArrayList)1 HiddenResources (org.opentosca.toscana.api.docs.HiddenResources)1 Platform (org.opentosca.toscana.core.transformation.platform.Platform)1 Link (org.springframework.hateoas.Link)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1