Search in sources :

Example 1 with FirmwareDTO

use of org.eclipse.smarthome.core.thing.firmware.dto.FirmwareDTO in project smarthome by eclipse.

the class ThingTypeResource method getFirmwares.

@GET
@Path("/{thingTypeUID}/firmwares")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get all available firmwares for provided thingType", response = StrippedThingTypeDTO.class, responseContainer = "Set")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 204, message = "No firmwares found.") })
public Response getFirmwares(@PathParam("thingTypeUID") @ApiParam(value = "thingTypeUID") String thingTypeUID, @HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = HttpHeaders.ACCEPT_LANGUAGE) String language) {
    ThingTypeUID athingTypeUID = new ThingTypeUID(thingTypeUID);
    Collection<Firmware> firmwares = firmwareRegistry.getFirmwares(athingTypeUID, LocaleUtil.getLocale(language));
    if (firmwares.isEmpty()) {
        return Response.status(Status.NO_CONTENT).build();
    }
    Stream<FirmwareDTO> firmwareStream = firmwares.stream().map(this::convertToFirmwareDTO);
    return Response.ok(null, MediaType.TEXT_PLAIN).entity(new Stream2JSONInputStream(firmwareStream)).build();
}
Also used : FirmwareDTO(org.eclipse.smarthome.core.thing.firmware.dto.FirmwareDTO) ThingTypeUID(org.eclipse.smarthome.core.thing.ThingTypeUID) Firmware(org.eclipse.smarthome.core.thing.binding.firmware.Firmware) Stream2JSONInputStream(org.eclipse.smarthome.io.rest.Stream2JSONInputStream) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 ThingTypeUID (org.eclipse.smarthome.core.thing.ThingTypeUID)1 Firmware (org.eclipse.smarthome.core.thing.binding.firmware.Firmware)1 FirmwareDTO (org.eclipse.smarthome.core.thing.firmware.dto.FirmwareDTO)1 Stream2JSONInputStream (org.eclipse.smarthome.io.rest.Stream2JSONInputStream)1