Skip to content

Commit

Permalink
Add askTotalCount to DeviceEvents REST API
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Mezzasalma <claudio.mezzasalma@eurotech.com>
  • Loading branch information
Claudio Mezzasalma committed Aug 4, 2021
1 parent c090030 commit 0d2b304
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Expand Up @@ -60,13 +60,14 @@ public class DeviceEvents extends AbstractKapuaResource {
/**
* Gets the {@link DeviceEvent} list in the scope.
*
* @param scopeId The {@link ScopeId} in which to search results.
* @param deviceId The id of the {@link Device} in which to search results
* @param resource The resource of the {@link DeviceEvent} in which to search results
* @param sortParam The name of the parameter that will be used as a sorting key
* @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive.
* @param offset The result set offset.
* @param limit The result set limit.
* @param scopeId The {@link ScopeId} in which to search results.
* @param deviceId The id of the {@link Device} in which to search results
* @param resource The resource of the {@link DeviceEvent} in which to search results
* @param sortParam The name of the parameter that will be used as a sorting key
* @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive.
* @param askTotalCount Ask for the total count of the matched entities in the result
* @param offset The result set offset.
* @param limit The result set limit.
* @return The {@link DeviceEventListResult} of all the deviceEvents associated to the current selected scope.
* @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions.
* @since 1.0.0
Expand All @@ -81,6 +82,7 @@ public DeviceEventListResult simpleQuery(
@QueryParam("endDate") DateParam endDateParam,
@QueryParam("sortParam") String sortParam,
@QueryParam("sortDir") @DefaultValue("ASCENDING") SortOrder sortDir,
@QueryParam("askTotalCount") boolean askTotalCount,
@QueryParam("offset") @DefaultValue("0") int offset,
@QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException {
DeviceEventQuery query = deviceEventFactory.newQuery(scopeId);
Expand All @@ -107,6 +109,7 @@ public DeviceEventListResult simpleQuery(
if (!Strings.isNullOrEmpty(sortParam)) {
query.setSortCriteria(query.fieldSortCriteria(sortParam, sortDir));
}
query.setAskTotalCount(askTotalCount);
query.setOffset(offset);
query.setLimit(limit);

Expand Down
Expand Up @@ -40,6 +40,7 @@ paths:
format: 'date-time'
- $ref: '../openapi.yaml#/components/parameters/sortParam'
- $ref: '../openapi.yaml#/components/parameters/sortDir'
- $ref: '../openapi.yaml#/components/parameters/askTotalCount'
- $ref: '../openapi.yaml#/components/parameters/limit'
- $ref: '../openapi.yaml#/components/parameters/offset'
responses:
Expand Down

0 comments on commit 0d2b304

Please sign in to comment.