diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementOperations.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementOperations.java index 006efe5738c..3bd0048866c 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementOperations.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementOperations.java @@ -41,6 +41,7 @@ import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationListResult; import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationQuery; import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationRegistryService; +import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationStatus; import org.eclipse.kapua.service.device.registry.Device; @Path("{scopeId}/devices/{deviceId}/operations") @@ -69,6 +70,7 @@ public DeviceManagementOperationListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @QueryParam("resource") String resource, + @QueryParam("status") DeviceManagementOperationStatus operationStatus, @QueryParam("askTotalCount") boolean askTotalCount, @QueryParam("sortParam") String sortParam, @QueryParam("sortDir") @DefaultValue("ASCENDING") SortOrder sortDir, @@ -83,6 +85,9 @@ public DeviceManagementOperationListResult simpleQuery( if (!Strings.isNullOrEmpty(resource)) { andPredicate.and(query.attributePredicate(DeviceManagementOperationAttributes.RESOURCE, resource)); } + if (operationStatus != null) { + andPredicate.and(query.attributePredicate(DeviceManagementOperationAttributes.STATUS, operationStatus)); + } if (!Strings.isNullOrEmpty(sortParam)) { query.setSortCriteria(query.fieldSortCriteria(sortParam, sortDir)); @@ -115,12 +120,15 @@ public DeviceManagementOperationListResult query( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, DeviceManagementOperationQuery query) throws KapuaException { - query.setScopeId(scopeId); - - AndPredicate andPredicate = query.andPredicate(); - andPredicate.and(query.attributePredicate(DeviceManagementOperationAttributes.DEVICE_ID, deviceId)); - query.setPredicate(andPredicate); - + if (query.getPredicate() != null) { + final AndPredicate andPredicate = query.andPredicate( + query.attributePredicate(DeviceManagementOperationAttributes.DEVICE_ID, deviceId), + query.getPredicate() + ); + query.setPredicate(andPredicate); + } else { + query.setPredicate(query.attributePredicate(DeviceManagementOperationAttributes.DEVICE_ID, deviceId)); + } return deviceManagementOperationRegistryService.query(query); } diff --git a/rest-api/resources/src/main/resources/openapi/deviceOperation/deviceOperation-scopeId-deviceId.yaml b/rest-api/resources/src/main/resources/openapi/deviceOperation/deviceOperation-scopeId-deviceId.yaml index 5636690ac3b..f7f00be2fa5 100644 --- a/rest-api/resources/src/main/resources/openapi/deviceOperation/deviceOperation-scopeId-deviceId.yaml +++ b/rest-api/resources/src/main/resources/openapi/deviceOperation/deviceOperation-scopeId-deviceId.yaml @@ -26,6 +26,7 @@ paths: description: The resource of the DeviceManagementOperation in which to search results schema: type: string + - $ref: '../deviceOperation/deviceOperation.yaml#/components/parameters/status' - $ref: '../openapi.yaml#/components/parameters/askTotalCount' - $ref: '../openapi.yaml#/components/parameters/sortParam' - name: sortDir diff --git a/rest-api/resources/src/main/resources/openapi/deviceOperation/deviceOperation.yaml b/rest-api/resources/src/main/resources/openapi/deviceOperation/deviceOperation.yaml index f17963d860a..430694fd51a 100644 --- a/rest-api/resources/src/main/resources/openapi/deviceOperation/deviceOperation.yaml +++ b/rest-api/resources/src/main/resources/openapi/deviceOperation/deviceOperation.yaml @@ -22,6 +22,12 @@ components: schema: $ref: '../openapi.yaml#/components/schemas/kapuaId' required: true + status: + name: status + in: query + description: The status of the Registry Operation on which to perform the operation + schema: + $ref: './deviceOperation.yaml#/components/schemas/operationStatus' schemas: deviceOperation: allOf: