Search in sources :

Example 1 with StrippedThingTypeDTO

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

the class ThingTypeResource method getAll.

@GET
@RolesAllowed({ Role.USER })
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Gets all available thing types without config description, channels and properties.", response = StrippedThingTypeDTO.class, responseContainer = "Set")
@ApiResponses(value = @ApiResponse(code = 200, message = "OK", response = StrippedThingTypeDTO.class, responseContainer = "Set"))
public Response getAll(@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = HttpHeaders.ACCEPT_LANGUAGE) String language) {
    Locale locale = LocaleUtil.getLocale(language);
    Stream<StrippedThingTypeDTO> typeStream = thingTypeRegistry.getThingTypes(locale).stream().map(t -> convertToStrippedThingTypeDTO(t, locale));
    return Response.ok(new Stream2JSONInputStream(typeStream)).build();
}
Also used : Locale(java.util.Locale) Stream2JSONInputStream(org.eclipse.smarthome.io.rest.Stream2JSONInputStream) StrippedThingTypeDTO(org.eclipse.smarthome.core.thing.dto.StrippedThingTypeDTO) RolesAllowed(javax.annotation.security.RolesAllowed) 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 Locale (java.util.Locale)1 RolesAllowed (javax.annotation.security.RolesAllowed)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 StrippedThingTypeDTO (org.eclipse.smarthome.core.thing.dto.StrippedThingTypeDTO)1 Stream2JSONInputStream (org.eclipse.smarthome.io.rest.Stream2JSONInputStream)1