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);
}
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;
}
Aggregations