use of org.openhab.core.thing.dto.StrippedThingTypeDTO in project openhab-core by openhab.
the class ThingTypeResource method getAll.
@GET
@RolesAllowed({ Role.USER, Role.ADMIN })
@Produces(MediaType.APPLICATION_JSON)
@Operation(operationId = "getThingTypes", summary = "Gets all available thing types without config description, channels and properties.", responses = { @ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = StrippedThingTypeDTO.class), uniqueItems = true))) })
public Response getAll(@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @Parameter(description = "language") @Nullable String language, @QueryParam("bindingId") @Parameter(description = "filter by binding Id") @Nullable String bindingId) {
Locale locale = localeService.getLocale(language);
Stream<StrippedThingTypeDTO> typeStream = thingTypeRegistry.getThingTypes(locale).stream().map(thingType -> StrippedThingTypeDTOMapper.map(thingType, locale));
if (bindingId != null) {
typeStream = typeStream.filter(type -> type.UID.startsWith(bindingId + ':'));
}
return Response.ok(new Stream2JSONInputStream(typeStream)).build();
}
Aggregations