@ -19,6 +19,7 @@
package org.wso2.carbon.device.mgt.jaxrs.api ;
package org.wso2.carbon.device.mgt.jaxrs.api ;
import io.swagger.annotations.* ;
import io.swagger.annotations.* ;
import org.wso2.carbon.apimgt.annotations.api.* ;
import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException ;
import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException ;
import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper ;
import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper ;
import org.wso2.carbon.device.mgt.jaxrs.beans.PriorityUpdatedPolicyWrapper ;
import org.wso2.carbon.device.mgt.jaxrs.beans.PriorityUpdatedPolicyWrapper ;
@ -28,6 +29,9 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response ;
import javax.ws.rs.core.Response ;
import java.util.List ;
import java.util.List ;
@API ( name = "Policy" , version = "1.0.0" , context = "/policies" , tags = { "devicemgt_admin" } )
// Below Api is for swagger annotations
@Path ( "/policies" )
@Path ( "/policies" )
@Api ( value = "Policy" , description = "Policy management related operations can be found here." )
@Api ( value = "Policy" , description = "Policy management related operations can be found here." )
public interface Policy {
public interface Policy {
@ -45,6 +49,7 @@ public interface Policy {
@ApiResponses ( value = { @ApiResponse ( code = 201 , message = "Created the policy." ) ,
@ApiResponses ( value = { @ApiResponse ( code = 201 , message = "Created the policy." ) ,
@ApiResponse ( code = 500 , message = "Policy Management related error occurred when " +
@ApiResponse ( code = 500 , message = "Policy Management related error occurred when " +
"adding the policy" ) } )
"adding the policy" ) } )
@Permission ( scope = "policy-modify" , permissions = { "/permission/admin/device-mgt/admin/policies/add" } )
Response addPolicy ( @ApiParam ( name = "policyWrapper" , value = "Policy details related to the operation." ,
Response addPolicy ( @ApiParam ( name = "policyWrapper" , value = "Policy details related to the operation." ,
required = true ) PolicyWrapper policyWrapper ) ;
required = true ) PolicyWrapper policyWrapper ) ;
@ -62,6 +67,7 @@ public interface Policy {
@ApiResponses ( value = { @ApiResponse ( code = 201 , message = "Created the policy." ) ,
@ApiResponses ( value = { @ApiResponse ( code = 201 , message = "Created the policy." ) ,
@ApiResponse ( code = 500 , message = "Policy Management related error occurred when " +
@ApiResponse ( code = 500 , message = "Policy Management related error occurred when " +
"adding the policy" ) } )
"adding the policy" ) } )
@Permission ( scope = "policy-modify" , permissions = { "/permission/admin/device-mgt/admin/policies/add" } )
Response addActivePolicy ( @ApiParam ( name = "policyWrapper" , value = "Policy details related to the operation." ,
Response addActivePolicy ( @ApiParam ( name = "policyWrapper" , value = "Policy details related to the operation." ,
required = true ) PolicyWrapper policyWrapper ) ;
required = true ) PolicyWrapper policyWrapper ) ;
@ -79,6 +85,7 @@ public interface Policy {
response = org . wso2 . carbon . policy . mgt . common . Policy . class , responseContainer = "List" ) ,
response = org . wso2 . carbon . policy . mgt . common . Policy . class , responseContainer = "List" ) ,
@ApiResponse ( code = 500 , message = "Policy Management related error occurred when " +
@ApiResponse ( code = 500 , message = "Policy Management related error occurred when " +
"fetching the policies." ) } )
"fetching the policies." ) } )
@Permission ( scope = "policy-view" , permissions = { "/permission/admin/device-mgt/admin/policies/list" } )
Response getAllPolicies ( ) ;
Response getAllPolicies ( ) ;
@GET
@GET
@ -94,6 +101,7 @@ public interface Policy {
@ApiResponses ( value = { @ApiResponse ( code = 200 , message = "Fetched policy details." ) ,
@ApiResponses ( value = { @ApiResponse ( code = 200 , message = "Fetched policy details." ) ,
@ApiResponse ( code = 500 , message = "Policy Management related error occurred when " +
@ApiResponse ( code = 500 , message = "Policy Management related error occurred when " +
"fetching the policies." ) } )
"fetching the policies." ) } )
@Permission ( scope = "policy-view" , permissions = { "/permission/admin/device-mgt/admin/policies/list" } )
Response getPolicy ( @ApiParam ( name = "id" , value = "Policy ID value to identify a policy uniquely." ,
Response getPolicy ( @ApiParam ( name = "id" , value = "Policy ID value to identify a policy uniquely." ,
required = true ) @PathParam ( "id" ) int policyId ) ;
required = true ) @PathParam ( "id" ) int policyId ) ;
@ -108,6 +116,7 @@ public interface Policy {
response = int . class )
response = int . class )
@ApiResponses ( value = { @ApiResponse ( code = 200 , message = "Fetched the policy count." ) ,
@ApiResponses ( value = { @ApiResponse ( code = 200 , message = "Fetched the policy count." ) ,
@ApiResponse ( code = 500 , message = "Error while Fetching the policy count." ) } )
@ApiResponse ( code = 500 , message = "Error while Fetching the policy count." ) } )
@Permission ( scope = "policy-view" , permissions = { "/permission/admin/device-mgt/admin/policies/list" } )
Response getPolicyCount ( ) ;
Response getPolicyCount ( ) ;
@PUT
@PUT
@ -122,6 +131,7 @@ public interface Policy {
@ApiResponses ( value = { @ApiResponse ( code = 201 , message = "Policy has been updated successfully." ) ,
@ApiResponses ( value = { @ApiResponse ( code = 201 , message = "Policy has been updated successfully." ) ,
@ApiResponse ( code = 500 , message = "Policy Management related exception in policy " +
@ApiResponse ( code = 500 , message = "Policy Management related exception in policy " +
"update" ) } )
"update" ) } )
@Permission ( scope = "policy-modify" , permissions = { "/permission/admin/device-mgt/admin/policies/update" } )
Response updatePolicy ( @ApiParam ( name = "policyWrapper" , value = "Policy details related to the operation." ,
Response updatePolicy ( @ApiParam ( name = "policyWrapper" , value = "Policy details related to the operation." ,
required = true ) PolicyWrapper policyWrapper ,
required = true ) PolicyWrapper policyWrapper ,
@ApiParam ( name = "id" , value = "Policy ID value to identify a policy uniquely." ,
@ApiParam ( name = "id" , value = "Policy ID value to identify a policy uniquely." ,
@ -141,6 +151,7 @@ public interface Policy {
@ApiResponses ( value = { @ApiResponse ( code = 200 , message = "Policy Priorities successfully updated." ) ,
@ApiResponses ( value = { @ApiResponse ( code = 200 , message = "Policy Priorities successfully updated." ) ,
@ApiResponse ( code = 400 , message = "Policy priorities did not update." ) ,
@ApiResponse ( code = 400 , message = "Policy priorities did not update." ) ,
@ApiResponse ( code = 500 , message = "Error in updating policy priorities." ) } )
@ApiResponse ( code = 500 , message = "Error in updating policy priorities." ) } )
@Permission ( scope = "policy-modify" , permissions = { "/permission/admin/device-mgt/admin/policies/update" } )
Response updatePolicyPriorities ( @ApiParam ( name = "priorityUpdatedPolicies" ,
Response updatePolicyPriorities ( @ApiParam ( name = "priorityUpdatedPolicies" ,
value = "List of policy update details.." ,
value = "List of policy update details.." ,
required = true ) List < PriorityUpdatedPolicyWrapper > priorityUpdatedPolicies ) ;
required = true ) List < PriorityUpdatedPolicyWrapper > priorityUpdatedPolicies ) ;
@ -158,6 +169,7 @@ public interface Policy {
@ApiResponses ( value = { @ApiResponse ( code = 200 , message = "Policies have been successfully deleted." ) ,
@ApiResponses ( value = { @ApiResponse ( code = 200 , message = "Policies have been successfully deleted." ) ,
@ApiResponse ( code = 400 , message = "Policy does not exist." ) ,
@ApiResponse ( code = 400 , message = "Policy does not exist." ) ,
@ApiResponse ( code = 500 , message = "Error in deleting policies." ) } )
@ApiResponse ( code = 500 , message = "Error in deleting policies." ) } )
@Permission ( scope = "policy-modify" , permissions = { "/permission/admin/device-mgt/admin/policies/remove" } )
Response bulkRemovePolicy ( @ApiParam ( name = "policyIds" , value = "Policy ID list to be deleted." ,
Response bulkRemovePolicy ( @ApiParam ( name = "policyIds" , value = "Policy ID list to be deleted." ,
required = true ) List < Integer > policyIds ) ;
required = true ) List < Integer > policyIds ) ;
@ -173,6 +185,9 @@ public interface Policy {
"in the inactive state to the active state." )
"in the inactive state to the active state." )
@ApiResponses ( value = { @ApiResponse ( code = 200 , message = "Policies have been successfully activated." ) ,
@ApiResponses ( value = { @ApiResponse ( code = 200 , message = "Policies have been successfully activated." ) ,
@ApiResponse ( code = 500 , message = "Error in activating policies." ) } )
@ApiResponse ( code = 500 , message = "Error in activating policies." ) } )
@Permission ( scope = "policy-modify" , permissions = {
"/permission/admin/device-mgt/admin/policies/update" ,
"/permission/admin/device-mgt/admin/policies/add" } )
Response activatePolicy ( @ApiParam ( name = "policyIds" , value = "Policy ID list to be activated." ,
Response activatePolicy ( @ApiParam ( name = "policyIds" , value = "Policy ID list to be activated." ,
required = true ) List < Integer > policyIds ) ;
required = true ) List < Integer > policyIds ) ;
@ -188,6 +203,9 @@ public interface Policy {
"is in the active state to the inactive state." )
"is in the active state to the inactive state." )
@ApiResponses ( value = { @ApiResponse ( code = 200 , message = "Policies have been successfully deactivated." ) ,
@ApiResponses ( value = { @ApiResponse ( code = 200 , message = "Policies have been successfully deactivated." ) ,
@ApiResponse ( code = 500 , message = "Error in deactivating policies." ) } )
@ApiResponse ( code = 500 , message = "Error in deactivating policies." ) } )
@Permission ( scope = "policy-modify" , permissions = {
"/permission/admin/device-mgt/admin/policies/update" ,
"/permission/admin/device-mgt/admin/policies/add" } )
Response inactivatePolicy ( @ApiParam ( name = "policyIds" , value = "Policy ID list to be deactivated." ,
Response inactivatePolicy ( @ApiParam ( name = "policyIds" , value = "Policy ID list to be deactivated." ,
required = true ) List < Integer > policyIds ) throws MDMAPIException ;
required = true ) List < Integer > policyIds ) throws MDMAPIException ;
@ -206,6 +224,7 @@ public interface Policy {
" you need to apply the changes to push the policy changes to the existing devices." )
" you need to apply the changes to push the policy changes to the existing devices." )
@ApiResponses ( value = { @ApiResponse ( code = 200 , message = "Changes have been successfully updated." ) ,
@ApiResponses ( value = { @ApiResponse ( code = 200 , message = "Changes have been successfully updated." ) ,
@ApiResponse ( code = 500 , message = "Error in updating policies." ) } )
@ApiResponse ( code = 500 , message = "Error in updating policies." ) } )
@Permission ( scope = "policy-modify" , permissions = { "/permission/admin/device-mgt/admin/policies/update" } )
Response applyChanges ( ) ;
Response applyChanges ( ) ;
@GET
@GET
@ -223,23 +242,28 @@ public interface Policy {
@ApiResponses ( value = { @ApiResponse ( code = 200 , message = "Policy monitoring service started successfully." ) ,
@ApiResponses ( value = { @ApiResponse ( code = 200 , message = "Policy monitoring service started successfully." ) ,
@ApiResponse ( code = 500 , message = "Policy Management related exception when starting " +
@ApiResponse ( code = 500 , message = "Policy Management related exception when starting " +
"monitoring service." ) } )
"monitoring service." ) } )
@Permission ( scope = "policy-modify" , permissions = { "/permission/admin/device-mgt/admin/policies/add" } )
Response startTaskService ( @ApiParam ( name = "milliseconds" , value = "Policy monitoring frequency in milliseconds." ,
Response startTaskService ( @ApiParam ( name = "milliseconds" , value = "Policy monitoring frequency in milliseconds." ,
required = true ) @PathParam ( "milliseconds" ) int monitoringFrequency ) ;
required = true ) @PathParam ( "milliseconds" ) int monitoringFrequency ) ;
@GET
@GET
@Path ( "update-task/{milliseconds}" )
@Path ( "update-task/{milliseconds}" )
@Permission ( scope = "policy-modify" , permissions = { "/permission/admin/device-mgt/admin/policies/add" } )
Response updateTaskService ( @PathParam ( "milliseconds" ) int monitoringFrequency ) ;
Response updateTaskService ( @PathParam ( "milliseconds" ) int monitoringFrequency ) ;
@GET
@GET
@Path ( "stop-task" )
@Path ( "stop-task" )
@Permission ( scope = "policy-modify" , permissions = { "/permission/admin/device-mgt/admin/policies/add" } )
Response stopTaskService ( ) ;
Response stopTaskService ( ) ;
@GET
@GET
@Path ( "{type}/{id}" )
@Path ( "{type}/{id}" )
@Permission ( scope = "policy-view" , permissions = { "/permission/admin/device-mgt/admin/policies/list" } )
Response getComplianceDataOfDevice ( @PathParam ( "type" ) String type , @PathParam ( "id" ) String id ) ;
Response getComplianceDataOfDevice ( @PathParam ( "type" ) String type , @PathParam ( "id" ) String id ) ;
@GET
@GET
@Path ( "{type}/{id}/active-policy" )
@Path ( "{type}/{id}/active-policy" )
@Permission ( scope = "policy-view" , permissions = { "/permission/admin/device-mgt/admin/policies/list" } )
@ApiOperation (
@ApiOperation (
consumes = MediaType . APPLICATION_JSON ,
consumes = MediaType . APPLICATION_JSON ,
produces = MediaType . APPLICATION_JSON ,
produces = MediaType . APPLICATION_JSON ,