@ -24,8 +24,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam ;
import io.swagger.annotations.ApiResponse ;
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 ;
@ -33,6 +31,8 @@ import io.swagger.annotations.ResponseHeader;
import io.swagger.annotations.SwaggerDefinition ;
import io.swagger.annotations.Tag ;
import org.apache.axis2.transport.http.HTTPConstants ;
import org.wso2.carbon.apimgt.annotations.api.Scope ;
import org.wso2.carbon.apimgt.annotations.api.Scopes ;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier ;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup ;
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceGroupList ;
@ -40,6 +40,7 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList;
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceToGroupsAssignment ;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse ;
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList ;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants ;
import javax.validation.Valid ;
import javax.ws.rs.Consumes ;
@ -75,6 +76,82 @@ import java.util.List;
"details." )
}
)
@Scopes (
scopes = {
@Scope (
name = "Get the list of groups belongs to current user." ,
description = "Get the list of groups belongs to current user." ,
key = "cdmf:groups:groups" ,
permissions = { "/device-mgt/groups/groups" }
) ,
@Scope (
name = "Get the count of groups belongs to current user." ,
description = "Get the count of groups belongs to current user." ,
key = "cdmf:groups:count" ,
permissions = { "/device-mgt/groups/count" }
) ,
@Scope (
name = "Add new device group to the system." ,
description = "Add new device group to the system." ,
key = "cdmf:groups:add" ,
permissions = { "/device-mgt/groups/add" }
) ,
@Scope (
name = "View group specified" ,
description = "View group specified" ,
key = "cdmf:groups:groups-view" ,
permissions = { "/device-mgt/groups/groups-view" }
) ,
@Scope (
name = "Update a group" ,
description = "Update a group" ,
key = "cdmf:groups:update" ,
permissions = { "/device-mgt/groups/update" }
) ,
@Scope (
name = "Delete a group" ,
description = "Delete a group" ,
key = "cdmf:groups:remove" ,
permissions = { "/device-mgt/groups/remove" }
) ,
@Scope (
name = "Manage group sharing with a user" ,
description = "Manage group sharing with a user" ,
key = "cdmf:groups:share" ,
permissions = { "/device-mgt/groups/share" }
) ,
@Scope (
name = "View list of roles of a device group" ,
description = "View list of roles of a device group" ,
key = "cdmf:groups:roles" ,
permissions = { "/device-mgt/groups/roles" }
) ,
@Scope (
name = "View list of devices in the device group" ,
description = "View list of devices in the device group" ,
key = "cdmf:groups:devices" ,
permissions = { "/device-mgt/groups/devices" }
) ,
@Scope (
name = "View list of device count in the device group" ,
description = "View list of device count in the device group" ,
key = "cdmf:groups:devices-count" ,
permissions = { "/device-mgt/groups/devices/devices-count" }
) ,
@Scope (
name = "Add devices to group" ,
description = "Add devices to group" ,
key = "cdmf:groups:devices-add" ,
permissions = { "/device-mgt/groups/devices/devices-add" }
) ,
@Scope (
name = "Remove devices from group" ,
description = "Remove devices from group" ,
key = "cdmf:groups:devices-remove" ,
permissions = { "/device-mgt/groups/devices/devices-remove" }
)
}
)
@Path ( "/groups" )
@Api ( value = "Device Group Management" , description = "This API carries all device group management related " +
"operations such as get all the available groups, etc." )
@ -89,12 +166,10 @@ public interface GroupManagementService {
value = "Get the list of groups belongs to current user." ,
notes = "Returns all permitted groups enrolled with the system." ,
tags = "Device Group Management" ,
authorizations = {
@Authorization (
value = "permission" ,
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/view" ,
description = "View Groups" ) }
)
extensions = {
@Extension ( properties = {
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:groups" )
} )
}
)
@ApiResponses ( value = {
@ -154,13 +229,12 @@ public interface GroupManagementService {
value = "Get the count of groups belongs to current user." ,
notes = "Returns count of all permitted groups enrolled with the system." ,
tags = "Device Group Management" ,
authorizations = {
@Authorization (
value = "permission" ,
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/view" ,
description = "View Groups" ) }
)
extensions = {
@Extension ( properties = {
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:count" )
} )
}
)
@ApiResponses ( value = {
@ApiResponse ( code = 200 , message = "OK. \n Successfully fetched the device group count." ,
@ -203,12 +277,10 @@ public interface GroupManagementService {
value = "Add new device group to the system." ,
notes = "Add device group with current user as the owner." ,
tags = "Device Group Management" ,
authorizations = {
@Authorization (
value = "permission" ,
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/add" ,
description = "Add Group" ) }
)
extensions = {
@Extension ( properties = {
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:add" )
} )
}
)
@ApiResponses (
@ -271,12 +343,10 @@ public interface GroupManagementService {
value = "View group specified." ,
notes = "Returns details of group enrolled with the system." ,
tags = "Device Group Management" ,
authorizations = {
@Authorization (
value = "permission" ,
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/view" ,
description = "View Groups" ) }
)
extensions = {
@Extension ( properties = {
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:groups-view" )
} )
}
)
@ApiResponses ( value = {
@ -326,12 +396,10 @@ public interface GroupManagementService {
notes = "If you wish to make changes to an existing group, that can be done by updating the group using " +
"this resource." ,
tags = "Device Group Management" ,
authorizations = {
@Authorization (
value = "permission" ,
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/update" ,
description = "Update Group" ) }
)
extensions = {
@Extension ( properties = {
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:update" )
} )
}
)
@ApiResponses ( value = {
@ -385,12 +453,10 @@ public interface GroupManagementService {
notes = "If you wish to remove an existing group, that can be done by updating the group using " +
"this resource." ,
tags = "Device Group Management" ,
authorizations = {
@Authorization (
value = "permission" ,
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/remove" ,
description = "Remove Group" ) }
)
extensions = {
@Extension ( properties = {
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:remove" )
} )
}
)
@ApiResponses ( value = {
@ -439,12 +505,10 @@ public interface GroupManagementService {
notes = "If you wish to share /un share an existing group with a user under defined sharing roles, " +
"that can be done using this resource." ,
tags = "Device Group Management" ,
authorizations = {
@Authorization (
value = "permission" ,
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/share" ,
description = "Share Group" ) }
)
extensions = {
@Extension ( properties = {
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:share" )
} )
}
)
@ApiResponses ( value = {
@ -497,12 +561,10 @@ public interface GroupManagementService {
value = "View list of roles of a device group." ,
notes = "Returns details of roles which particular group has been shared with." ,
tags = "Device Group Management" ,
authorizations = {
@Authorization (
value = "permission" ,
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/roles/view" ,
description = "View roles" ) }
)
extensions = {
@Extension ( properties = {
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:roles" )
} )
}
)
@ApiResponses ( value = {
@ -551,12 +613,10 @@ public interface GroupManagementService {
value = "View list of devices in the device group." ,
notes = "Returns list of devices in the device group." ,
tags = "Device Group Management" ,
authorizations = {
@Authorization (
value = "permission" ,
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/devices/view" ,
description = "View devices" ) }
)
extensions = {
@Extension ( properties = {
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:devices" )
} )
}
)
@ApiResponses ( value = {
@ -613,12 +673,10 @@ public interface GroupManagementService {
value = "View list of device count in the device group." ,
notes = "Returns device count in the device group." ,
tags = "Device Group Management" ,
authorizations = {
@Authorization (
value = "permission" ,
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/devices/view" ,
description = "View devices" ) }
)
extensions = {
@Extension ( properties = {
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:devices-count" )
} )
}
)
@ApiResponses ( value = {
@ -667,12 +725,10 @@ public interface GroupManagementService {
value = "Add devices to group." ,
notes = "Add existing devices to the device group." ,
tags = "Device Group Management" ,
authorizations = {
@Authorization (
value = "permission" ,
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/devices/add" ,
description = "Add devices" ) }
)
extensions = {
@Extension ( properties = {
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:devices-add" )
} )
}
)
@ApiResponses ( value = {
@ -725,12 +781,10 @@ public interface GroupManagementService {
value = "Remove devices from group." ,
notes = "Remove existing devices from the device group." ,
tags = "Device Group Management" ,
authorizations = {
@Authorization (
value = "permission" ,
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/devices/remove" ,
description = "Remove devices" ) }
)
extensions = {
@Extension ( properties = {
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:devices-remove" )
} )
}
)
@ApiResponses ( value = {