use of org.eclipse.smarthome.io.rest.Stream2JSONInputStream in project smarthome by eclipse.
the class ConfigDescriptionResource method getAll.
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Gets all available config descriptions.", response = ConfigDescriptionDTO.class, responseContainer = "List")
@ApiResponses(value = @ApiResponse(code = 200, message = "OK", response = ConfigDescriptionDTO.class, responseContainer = "List"))
public Response getAll(@HeaderParam("Accept-Language") @ApiParam(value = "Accept-Language") String language) {
Locale locale = LocaleUtil.getLocale(language);
Collection<ConfigDescription> configDescriptions = configDescriptionRegistry.getConfigDescriptions(locale);
return Response.ok(new Stream2JSONInputStream(configDescriptions.stream().map(ConfigDescriptionDTOMapper::map))).build();
}
use of org.eclipse.smarthome.io.rest.Stream2JSONInputStream in project smarthome by eclipse.
the class ExtensionResource method getExtensions.
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get all extensions.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = String.class) })
public Response getExtensions(@HeaderParam("Accept-Language") @ApiParam(value = "language") String language) {
logger.debug("Received HTTP GET request at '{}'", uriInfo.getPath());
Locale locale = LocaleUtil.getLocale(language);
return Response.ok(new Stream2JSONInputStream(getAllExtensions(locale))).build();
}
use of org.eclipse.smarthome.io.rest.Stream2JSONInputStream in project smarthome by eclipse.
the class ItemResource method getItems.
@GET
@RolesAllowed({ Role.USER, Role.ADMIN })
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get all available items.", response = EnrichedItemDTO.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = EnrichedItemDTO.class, responseContainer = "List") })
public Response getItems(@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = "language") @Nullable String language, @QueryParam("type") @ApiParam(value = "item type filter", required = false) @Nullable String type, @QueryParam("tags") @ApiParam(value = "item tag filter", required = false) @Nullable String tags, @DefaultValue("false") @QueryParam("recursive") @ApiParam(value = "get member items recursivly", required = false) boolean recursive, @QueryParam("fields") @ApiParam(value = "limit output to the given fields (comma separated)", required = false) @Nullable String fields) {
final Locale locale = LocaleUtil.getLocale(language);
logger.debug("Received HTTP GET request at '{}'", uriInfo.getPath());
Stream<EnrichedItemDTO> itemStream = getItems(type, tags).stream().map(item -> EnrichedItemDTOMapper.map(item, recursive, null, uriInfo.getBaseUri(), locale));
itemStream = dtoMapper.limitToFields(itemStream, fields);
return Response.ok(new Stream2JSONInputStream(itemStream)).build();
}
use of org.eclipse.smarthome.io.rest.Stream2JSONInputStream in project smarthome by eclipse.
the class ThingResource method getAll.
@GET
@RolesAllowed({ Role.USER, Role.ADMIN })
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get all available things.", response = EnrichedThingDTO.class, responseContainer = "Set")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = EnrichedThingDTO.class, responseContainer = "Set") })
public Response getAll(@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = "language") String language) {
final Locale locale = LocaleUtil.getLocale(language);
Stream<EnrichedThingDTO> thingStream = thingRegistry.stream().map(t -> convertToEnrichedThingDTO(t, locale)).distinct();
return Response.ok(new Stream2JSONInputStream(thingStream)).build();
}
use of org.eclipse.smarthome.io.rest.Stream2JSONInputStream 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();
}
Aggregations