@ -24,8 +24,6 @@ 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.Extension ;
import io.swagger.annotations.ExtensionProperty ;
import io.swagger.annotations.ExtensionProperty ;
import io.swagger.annotations.Info ;
import io.swagger.annotations.Info ;
@ -33,12 +31,15 @@ import io.swagger.annotations.ResponseHeader;
import io.swagger.annotations.SwaggerDefinition ;
import io.swagger.annotations.SwaggerDefinition ;
import io.swagger.annotations.Tag ;
import io.swagger.annotations.Tag ;
import org.apache.axis2.transport.http.HTTPConstants ;
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.DeviceIdentifier ;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup ;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup ;
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceGroupList ;
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceGroupList ;
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList ;
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList ;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse ;
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.beans.RoleList ;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants ;
import javax.validation.Valid ;
import javax.validation.Valid ;
import javax.ws.rs.Consumes ;
import javax.ws.rs.Consumes ;
@ -74,6 +75,82 @@ import java.util.List;
"details." )
"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" )
@Path ( "/groups" )
@Api ( value = "Device Group Management" , description = "This API carries all device group management related " +
@Api ( value = "Device Group Management" , description = "This API carries all device group management related " +
"operations such as get all the available groups, etc." )
"operations such as get all the available groups, etc." )
@ -88,12 +165,10 @@ public interface GroupManagementService {
value = "Get the list of groups belongs to current user." ,
value = "Get the list of groups belongs to current user." ,
notes = "Returns all permitted groups enrolled with the system." ,
notes = "Returns all permitted groups enrolled with the system." ,
tags = "Device Group Management" ,
tags = "Device Group Management" ,
authorizations = {
extensions = {
@Authorization (
@Extension ( properties = {
value = "permission" ,
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:groups" )
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/view" ,
} )
description = "View Groups" ) }
)
}
}
)
)
@ApiResponses ( value = {
@ApiResponses ( value = {
@ -153,13 +228,12 @@ public interface GroupManagementService {
value = "Get the count of groups belongs to current user." ,
value = "Get the count of groups belongs to current user." ,
notes = "Returns count of all permitted groups enrolled with the system." ,
notes = "Returns count of all permitted groups enrolled with the system." ,
tags = "Device Group Management" ,
tags = "Device Group Management" ,
authorizations = {
extensions = {
@Authorization (
@Extension ( properties = {
value = "permission" ,
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:count" )
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/view" ,
} )
description = "View Groups" ) }
)
}
}
)
)
@ApiResponses ( value = {
@ApiResponses ( value = {
@ApiResponse ( code = 200 , message = "OK. \n Successfully fetched the device group count." ,
@ApiResponse ( code = 200 , message = "OK. \n Successfully fetched the device group count." ,
@ -202,12 +276,10 @@ public interface GroupManagementService {
value = "Add new device group to the system." ,
value = "Add new device group to the system." ,
notes = "Add device group with current user as the owner." ,
notes = "Add device group with current user as the owner." ,
tags = "Device Group Management" ,
tags = "Device Group Management" ,
authorizations = {
extensions = {
@Authorization (
@Extension ( properties = {
value = "permission" ,
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:add" )
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/add" ,
} )
description = "Add Group" ) }
)
}
}
)
)
@ApiResponses (
@ApiResponses (
@ -270,12 +342,10 @@ public interface GroupManagementService {
value = "View group specified." ,
value = "View group specified." ,
notes = "Returns details of group enrolled with the system." ,
notes = "Returns details of group enrolled with the system." ,
tags = "Device Group Management" ,
tags = "Device Group Management" ,
authorizations = {
extensions = {
@Authorization (
@Extension ( properties = {
value = "permission" ,
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:groups-view" )
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/view" ,
} )
description = "View Groups" ) }
)
}
}
)
)
@ApiResponses ( value = {
@ApiResponses ( value = {
@ -325,12 +395,10 @@ public interface GroupManagementService {
notes = "If you wish to make changes to an existing group, that can be done by updating the group using " +
notes = "If you wish to make changes to an existing group, that can be done by updating the group using " +
"this resource." ,
"this resource." ,
tags = "Device Group Management" ,
tags = "Device Group Management" ,
authorizations = {
extensions = {
@Authorization (
@Extension ( properties = {
value = "permission" ,
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:update" )
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/update" ,
} )
description = "Update Group" ) }
)
}
}
)
)
@ApiResponses ( value = {
@ApiResponses ( value = {
@ -384,12 +452,10 @@ public interface GroupManagementService {
notes = "If you wish to remove an existing group, that can be done by updating the group using " +
notes = "If you wish to remove an existing group, that can be done by updating the group using " +
"this resource." ,
"this resource." ,
tags = "Device Group Management" ,
tags = "Device Group Management" ,
authorizations = {
extensions = {
@Authorization (
@Extension ( properties = {
value = "permission" ,
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:remove" )
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/remove" ,
} )
description = "Remove Group" ) }
)
}
}
)
)
@ApiResponses ( value = {
@ApiResponses ( value = {
@ -438,12 +504,10 @@ public interface GroupManagementService {
notes = "If you wish to share /un share an existing group with a user under defined sharing roles, " +
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." ,
"that can be done using this resource." ,
tags = "Device Group Management" ,
tags = "Device Group Management" ,
authorizations = {
extensions = {
@Authorization (
@Extension ( properties = {
value = "permission" ,
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:share" )
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/share" ,
} )
description = "Share Group" ) }
)
}
}
)
)
@ApiResponses ( value = {
@ApiResponses ( value = {
@ -496,12 +560,10 @@ public interface GroupManagementService {
value = "View list of roles of a device group." ,
value = "View list of roles of a device group." ,
notes = "Returns details of roles which particular group has been shared with." ,
notes = "Returns details of roles which particular group has been shared with." ,
tags = "Device Group Management" ,
tags = "Device Group Management" ,
authorizations = {
extensions = {
@Authorization (
@Extension ( properties = {
value = "permission" ,
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:roles" )
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/roles/view" ,
} )
description = "View roles" ) }
)
}
}
)
)
@ApiResponses ( value = {
@ApiResponses ( value = {
@ -550,12 +612,10 @@ public interface GroupManagementService {
value = "View list of devices in the device group." ,
value = "View list of devices in the device group." ,
notes = "Returns list of devices in the device group." ,
notes = "Returns list of devices in the device group." ,
tags = "Device Group Management" ,
tags = "Device Group Management" ,
authorizations = {
extensions = {
@Authorization (
@Extension ( properties = {
value = "permission" ,
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:devices" )
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/devices/view" ,
} )
description = "View devices" ) }
)
}
}
)
)
@ApiResponses ( value = {
@ApiResponses ( value = {
@ -612,12 +672,10 @@ public interface GroupManagementService {
value = "View list of device count in the device group." ,
value = "View list of device count in the device group." ,
notes = "Returns device count in the device group." ,
notes = "Returns device count in the device group." ,
tags = "Device Group Management" ,
tags = "Device Group Management" ,
authorizations = {
extensions = {
@Authorization (
@Extension ( properties = {
value = "permission" ,
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:devices-count" )
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/devices/view" ,
} )
description = "View devices" ) }
)
}
}
)
)
@ApiResponses ( value = {
@ApiResponses ( value = {
@ -666,12 +724,10 @@ public interface GroupManagementService {
value = "Add devices to group." ,
value = "Add devices to group." ,
notes = "Add existing devices to the device group." ,
notes = "Add existing devices to the device group." ,
tags = "Device Group Management" ,
tags = "Device Group Management" ,
authorizations = {
extensions = {
@Authorization (
@Extension ( properties = {
value = "permission" ,
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:devices-add" )
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/devices/add" ,
} )
description = "Add devices" ) }
)
}
}
)
)
@ApiResponses ( value = {
@ApiResponses ( value = {
@ -724,12 +780,10 @@ public interface GroupManagementService {
value = "Remove devices from group." ,
value = "Remove devices from group." ,
notes = "Remove existing devices from the device group." ,
notes = "Remove existing devices from the device group." ,
tags = "Device Group Management" ,
tags = "Device Group Management" ,
authorizations = {
extensions = {
@Authorization (
@Extension ( properties = {
value = "permission" ,
@ExtensionProperty ( name = Constants . SCOPE , value = "cdmf:groups:devices-remove" )
scopes = { @AuthorizationScope ( scope = "/device-mgt/groups/devices/remove" ,
} )
description = "Remove devices" ) }
)
}
}
)
)
@ApiResponses ( value = {
@ApiResponses ( value = {