Merge pull request #503 from charithag/release-2.0.x

Fixed https://wso2.org/jira/browse/IOTS-335
4.x.x
Rasika Perera 8 years ago committed by GitHub
commit 7d0a51c8a1

@ -5,25 +5,50 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.Extension;
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Info;
import io.swagger.annotations.ResponseHeader; import io.swagger.annotations.ResponseHeader;
import org.wso2.carbon.apimgt.annotations.api.Permission; import io.swagger.annotations.SwaggerDefinition;
import io.swagger.annotations.Tag;
import org.wso2.carbon.device.mgt.analytics.dashboard.bean.DeviceCountByGroup; import org.wso2.carbon.device.mgt.analytics.dashboard.bean.DeviceCountByGroup;
import org.wso2.carbon.device.mgt.jaxrs.beans.DashboardGadgetDataWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.DashboardGadgetDataWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.DashboardPaginationGadgetDataWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.DashboardPaginationGadgetDataWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import javax.ws.rs.*; import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
/** /**
* Device Analytics Dashboard related REST-APIs. This can be used to obtain device related analytics. * Device Analytics Dashboard related REST-APIs. This can be used to obtain device related analytics.
*/ */
@SwaggerDefinition(
info = @Info(
version = "1.0.0",
title = "",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = "name", value = "DeviceAnalyticsDashboard"),
@ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/dashboard"),
})
}
),
tags = {
@Tag(name = "device_management", description = "Device Analytics Dashboard related APIs.")
}
)
@Path("/dashboard") @Path("/dashboard")
@Api(value = "Device Analytics Dashboard", @Api(value = "Device Analytics Dashboard",
description = "Device Analytics Dashboard related information APIs are described here.") description = "Device Analytics Dashboard related information APIs are described here.")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@SuppressWarnings("NonJaxWsWebServices") @Consumes(MediaType.APPLICATION_JSON)
public interface Dashboard { public interface Dashboard {
String CONNECTIVITY_STATUS = "connectivity-status"; String CONNECTIVITY_STATUS = "connectivity-status";
@ -41,10 +66,17 @@ public interface Dashboard {
@ApiOperation( @ApiOperation(
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", httpMethod = "GET",
value = "Get the details of registered devices in WSO2 EMM.", value = "Get the details of registered devices in WSO2 IoT.",
notes = "Get the details of active, inactive, removed and total number of registered devices in" notes = "Get the details of active, inactive, removed and total number of registered devices in"
+ " WSO2 EMM.", + " WSO2 IoT.",
tags = "Dashboard") tags = "Dashboard",
authorizations = {
@Authorization(
value = "permission",
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
description = "View Dashboard")}
)
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -86,7 +118,6 @@ public interface Dashboard {
message = "Internal Server Error. \n ErrorResponse in retrieving requested data.", message = "Internal Server Error. \n ErrorResponse in retrieving requested data.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
Response getOverviewDeviceCounts(); Response getOverviewDeviceCounts();
@GET @GET
@ -94,8 +125,15 @@ public interface Dashboard {
@ApiOperation( @ApiOperation(
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", httpMethod = "GET",
value = "Get the number of unmonitored and non-compliant devices in WSO2 EMM.", value = "Get the number of unmonitored and non-compliant devices in WSO2 IoT.",
tags = "Dashboard") tags = "Dashboard",
authorizations = {
@Authorization(
value = "permission",
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
description = "View Dashboard")}
)
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -137,7 +175,6 @@ public interface Dashboard {
message = "Internal Server Error. \n Server error occurred while fetching activity data.", message = "Internal Server Error. \n Server error occurred while fetching activity data.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
Response getDeviceCountsByPotentialVulnerabilities(); Response getDeviceCountsByPotentialVulnerabilities();
@GET @GET
@ -147,7 +184,14 @@ public interface Dashboard {
httpMethod = "GET", httpMethod = "GET",
value = "Get the number of devices that have not complied to a policy that was enforced on a " value = "Get the number of devices that have not complied to a policy that was enforced on a "
+ "device.", + "device.",
tags = "Dashboard") tags = "Dashboard",
authorizations = {
@Authorization(
value = "permission",
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
description = "View Dashboard")}
)
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -189,7 +233,6 @@ public interface Dashboard {
message = "Internal Server Error. \n ErrorResponse in retrieving requested data.", message = "Internal Server Error. \n ErrorResponse in retrieving requested data.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
Response getNonCompliantDeviceCountsByFeatures( Response getNonCompliantDeviceCountsByFeatures(
@ApiParam( @ApiParam(
name = "start", name = "start",
@ -212,7 +255,14 @@ public interface Dashboard {
httpMethod = "GET", httpMethod = "GET",
value = "Get the number of devices for a given device type, such as connectivity status, " value = "Get the number of devices for a given device type, such as connectivity status, "
+ "potential vulnerability, platform, and ownership.\n", + "potential vulnerability, platform, and ownership.\n",
tags = "Dashboard") tags = "Dashboard",
authorizations = {
@Authorization(
value = "permission",
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
description = "View Dashboard")}
)
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -254,16 +304,15 @@ public interface Dashboard {
message = "Internal Server Error. \n ErrorResponse in retrieving requested data.", message = "Internal Server Error. \n ErrorResponse in retrieving requested data.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
Response getDeviceCountsByGroups( Response getDeviceCountsByGroups(
@ApiParam( @ApiParam(
name = "connectivity-status", name = "connectivity-status",
value = "Provide the connectivity status of the device. The following values can be assigned:\n" value = "Provide the connectivity status of the device. The following values can be assigned:\n"
+ "active: The devices that are registered with WSO2 EMM and are actively " + "active: The devices that are registered with WSO2 IoT and are actively "
+ "communicating with the server.\n" + "communicating with the server.\n"
+ "inactive: The devices that are registered with WSO2 EMM but unable to " + "inactive: The devices that are registered with WSO2 IoT but unable to "
+ "actively communicate with the server.\n" + "actively communicate with the server.\n"
+ "removed: The devices that have unregistered from WSO2 EMM", + "removed: The devices that have unregistered from WSO2 IoT",
required = true) required = true)
@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus, @QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
@ApiParam( @ApiParam(
@ -271,7 +320,7 @@ public interface Dashboard {
value = "Provide details of the potential vulnerabilities of the device. The following " value = "Provide details of the potential vulnerabilities of the device. The following "
+ "values can be assigned:\n" + "values can be assigned:\n"
+ "non-compliant: Devices that have not complied to the policies enforced on the " + "non-compliant: Devices that have not complied to the policies enforced on the "
+ "device by WSO2 EMM.\n" + "device by WSO2 IoT.\n"
+ "unmonitored: Devices that have no policy assigned to them.", + "unmonitored: Devices that have no policy assigned to them.",
required = true) required = true)
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability, @QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
@ -296,7 +345,14 @@ public interface Dashboard {
httpMethod = "GET", httpMethod = "GET",
value = "Get the number of devices that have not complied to a given policy based on a particular" value = "Get the number of devices that have not complied to a given policy based on a particular"
+ " device type.", + " device type.",
tags = "Dashboard") tags = "Dashboard",
authorizations = {
@Authorization(
value = "permission",
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
description = "View Dashboard")}
)
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -338,7 +394,6 @@ public interface Dashboard {
message = "Internal Server Error. \n ErrorResponse in retrieving requested data.", message = "Internal Server Error. \n ErrorResponse in retrieving requested data.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
Response getFeatureNonCompliantDeviceCountsByGroups( Response getFeatureNonCompliantDeviceCountsByGroups(
@ApiParam( @ApiParam(
name = "non-compliant-feature-code", name = "non-compliant-feature-code",
@ -365,12 +420,19 @@ public interface Dashboard {
@ApiOperation( @ApiOperation(
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", httpMethod = "GET",
value = "Get the number of devices that are registered with WSO2 EMM filtered by one of the " value = "Get the number of devices that are registered with WSO2 IoT filtered by one of the "
+ "following attributes:\n" + "following attributes:\n"
+ "Connectivity status of the device, such as active, inactive or removed.\n" + "Connectivity status of the device, such as active, inactive or removed.\n"
+ "The device ownership type, such as BYOD or COPE.\n" + "The device platform.\n" + "The device ownership type, such as BYOD or COPE.\n" + "The device platform.\n"
+ "The potential vulnerabilities faced by the devices.", + "The potential vulnerabilities faced by the devices.",
tags = "Dashboard") tags = "Dashboard",
authorizations = {
@Authorization(
value = "permission",
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
description = "View Dashboard")}
)
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -412,18 +474,17 @@ public interface Dashboard {
message = "Internal Server Error. \n ErrorResponse in retrieving requested data.", message = "Internal Server Error. \n ErrorResponse in retrieving requested data.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
Response getFilteredDeviceCountOverTotal( Response getFilteredDeviceCountOverTotal(
@ApiParam( @ApiParam(
name = "connectivity-status", name = "connectivity-status",
value = "Provide the connectivity status of the device. You can assign any of the values " value = "Provide the connectivity status of the device. You can assign any of the values "
+ "given below:\n" + "given below:\n"
+ "Total: All the devices that have registered with WSO2 EMM.\n" + "Total: All the devices that have registered with WSO2 IoT.\n"
+ "active: The devices that are registered with WSO2 EMM and are actively " + "active: The devices that are registered with WSO2 IoT and are actively "
+ "communicating with the server.\n" + "communicating with the server.\n"
+ "inactive: The devices that are registered with WSO2 EMM but unable to actively" + "inactive: The devices that are registered with WSO2 IoT but unable to actively"
+ " communicate with the server.\n" + " communicate with the server.\n"
+ "removed: The devices that have unregistered from WSO2 EMM.", + "removed: The devices that have unregistered from WSO2 IoT.",
required = true) required = true)
@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus, @QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
@ApiParam( @ApiParam(
@ -431,7 +492,7 @@ public interface Dashboard {
value = "Provide details of the potential vulnerabilities of the device. You can assign" value = "Provide details of the potential vulnerabilities of the device. You can assign"
+ " any of the values given below:\n" + " any of the values given below:\n"
+ "non-compliant: Devices that have not complied to the policies enforced on the " + "non-compliant: Devices that have not complied to the policies enforced on the "
+ "device by WSO2 EMM.\n" + "device by WSO2 IoT.\n"
+ "unmonitored: Devices that have no policy assigned to them.", + "unmonitored: Devices that have no policy assigned to them.",
required = true) required = true)
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability, @QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
@ -456,8 +517,15 @@ public interface Dashboard {
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", httpMethod = "GET",
value = "Get the number of devices that have not complied to a given policy over the total" value = "Get the number of devices that have not complied to a given policy over the total"
+ " number of devices registered with WSO2 EMM.\n", + " number of devices registered with WSO2 IoT.\n",
tags = "Dashboard") tags = "Dashboard",
authorizations = {
@Authorization(
value = "permission",
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
description = "View Dashboard")}
)
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -499,7 +567,6 @@ public interface Dashboard {
message = "Internal Server Error. \n ErrorResponse in retrieving requested data.", message = "Internal Server Error. \n ErrorResponse in retrieving requested data.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
Response getFeatureNonCompliantDeviceCountOverTotal( Response getFeatureNonCompliantDeviceCountOverTotal(
@ApiParam( @ApiParam(
name = "non-compliant-feature-code", name = "non-compliant-feature-code",
@ -527,7 +594,14 @@ public interface Dashboard {
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", httpMethod = "GET",
value = "Get device details of devices based on a particular device type.", value = "Get device details of devices based on a particular device type.",
tags = "Dashboard") tags = "Dashboard",
authorizations = {
@Authorization(
value = "permission",
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
description = "View Dashboard")}
)
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -569,24 +643,23 @@ public interface Dashboard {
message = "Internal Server Error. \n ErrorResponse in retrieving requested data.", message = "Internal Server Error. \n ErrorResponse in retrieving requested data.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
Response getDevicesWithDetails( Response getDevicesWithDetails(
@ApiParam( @ApiParam(
name = "connectivity-status", name = "connectivity-status",
value = "Provide the connectivity status of the device. This can be one of the following:\n" value = "Provide the connectivity status of the device. This can be one of the following:\n"
+ "Total: All the devices that have registered with WSO2 EMM.\n" + "Total: All the devices that have registered with WSO2 IoT.\n"
+ "active: The devices that are registered with WSO2 EMM and are actively " + "active: The devices that are registered with WSO2 IoT and are actively "
+ "communicating with the server.\n" + "communicating with the server.\n"
+ "inactive: The devices that are registered with WSO2 EMM but unable to actively" + "inactive: The devices that are registered with WSO2 IoT but unable to actively"
+ " communicate with the server.\n" + " communicate with the server.\n"
+ "removed: The devices that have unregistered from WSO2 EMM.", + "removed: The devices that have unregistered from WSO2 IoT.",
required = true) required = true)
@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus, @QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
@ApiParam( @ApiParam(
name = "potential-vulnerability", name = "potential-vulnerability",
value = "Provide details of the potential vulnerabilities of the device. This can be:\n" value = "Provide details of the potential vulnerabilities of the device. This can be:\n"
+ "non-compliant: Devices that have not complied to the policies enforced on " + "non-compliant: Devices that have not complied to the policies enforced on "
+ "the device by WSO2 EMM.\n" + "the device by WSO2 IoT.\n"
+ "unmonitored: Devices that have no policy assigned to them. ", + "unmonitored: Devices that have no policy assigned to them. ",
required = true) required = true)
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability, @QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
@ -624,7 +697,14 @@ public interface Dashboard {
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", httpMethod = "GET",
value = "Get device details of non-compliant devices which do not comply to a given policy.", value = "Get device details of non-compliant devices which do not comply to a given policy.",
tags = "Dashboard") tags = "Dashboard",
authorizations = {
@Authorization(
value = "permission",
scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
description = "View Dashboard")}
)
})
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
@ -666,7 +746,6 @@ public interface Dashboard {
message = "Internal Server Error. \n ErrorResponse in retrieving requested data.", message = "Internal Server Error. \n ErrorResponse in retrieving requested data.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view")
Response getFeatureNonCompliantDevicesWithDetails( Response getFeatureNonCompliantDevicesWithDetails(
@ApiParam( @ApiParam(
name = "non-compliant-feature-code", name = "non-compliant-feature-code",

Loading…
Cancel
Save