Committing improved swagger annotated cdm-f APIs

revert-70aa11f8
prabathabey 9 years ago
parent 0b9c64594c
commit 37aa05f79c

@ -21,6 +21,8 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.apimgt.annotations.api.Permission;
import org.wso2.carbon.device.mgt.common.notification.mgt.Notification;
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
@ -43,16 +45,50 @@ public interface ActivityInfoProviderService {
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Retrieving the operation details.",
notes = "This will return the operation details including the responses from the devices.")
response = Activity.class,
value = "Retrieve details of a particular activity.",
notes = "This will return information of a particular activity i.e. meta information of an operation, " +
"etc; including the responses from the devices.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Activity details provided successfully."),
@ApiResponse(code = 500, message = "Error occurred while fetching the activity for the supplied id.")
@ApiResponse(
code = 200,
message = "OK. \n Activity details is successfully fetched",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of " +
"the requested resource."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching activity data.")
})
@Permission(scope = "operation-view", permissions = {"/permission/admin/device-mgt/admin/devices/view"})
Response getActivity(
@ApiParam(name = "id", value = "Activity id of the operation/activity to be retrieved.",
@ApiParam(
name = "id",
value = "Activity id of the operation/activity to be retrieved.",
required = true)
@PathParam("id") String id);
@PathParam("id") String id,
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince);
}

@ -22,7 +22,6 @@ import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.apimgt.annotations.api.Permission;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
@ -40,54 +39,97 @@ import javax.ws.rs.core.Response;
@Consumes(MediaType.APPLICATION_JSON)
public interface ConfigurationManagementService {
@POST
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Configuring general platform settings",
notes = "Configure the general platform settings using this REST API.")
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Tenant configuration saved successfully"),
@ApiResponse(code = 500, message = "Error occurred while saving the tenant configuration")
})
@Permission(scope = "configuration-modify",
permissions = {"/permission/admin/device-mgt/admin/platform-configs/modify"})
Response saveConfiguration(@ApiParam(name = "configuration", value = "The required properties to "
+ "update the platform configurations.",
required = true) PlatformConfiguration configuration);
@GET
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting General Platform Configurations.",
notes = "Get the general platform level configuration details using this REST API.",
value = "Get the general platform configurations.",
notes = "Get the general platform level configuration details.",
response = PlatformConfiguration.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Tenant configuration saved successfully."),
@ApiResponse(code = 500, message = "Error occurred while retrieving the tenant configuration.")
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched general platform configuration.",
response = PlatformConfiguration.class,
responseContainer = "List",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the general platform configuration.")
})
@Permission(scope = "configuration-view",
permissions = {"/permission/admin/device-mgt/admin/platform-configs/view"})
Response getConfiguration();
Response getConfiguration(
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince);
@PUT
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "PUT",
value = "Updating General Platform Configurations.",
notes = "Update the notification frequency using this REST API.")
value = "Update General Platform Configurations.",
notes = "This resource is used to update the general platform configuration.")
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Tenant configuration updated successfully."),
@ApiResponse(code = 500, message = "Error occurred while updating the tenant configuration.")
@ApiResponse(
code = 200,
message = "OK. \n Notification status has been updated successfully",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The URL of the updated device."),
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while modifying status of the notification.")
})
@Permission(scope = "configuration-modify",
permissions = {"/permission/admin/device-mgt/admin/platform-configs/modify"})
Response updateConfiguration(@ApiParam(name = "configuration", value = "The required properties to "
+ "update the platform configurations.",
required = true) PlatformConfiguration configuration);
Response updateConfiguration(
@ApiParam(
name = "configuration",
value = "The required properties to be updated in the platform configuration.",
required = true) PlatformConfiguration configuration);
}

@ -21,13 +21,16 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.apimgt.annotations.api.Permission;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
import org.wso2.carbon.device.mgt.common.device.details.DeviceWrapper;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.search.SearchContext;
import org.wso2.carbon.policy.mgt.common.Policy;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
@ -38,62 +41,90 @@ import java.util.List;
/**
* Device related REST-API. This can be used to manipulated device related details.
*/
@API(name = "Device", version = "1.0.0", context = "/devicemgt_admin/devices", tags = {"devicemgt_admin"})
@API(name = "Device", version = "1.0.0", context = "/api/device-mgt/admin/devices", tags = {"devicemgt_admin"})
@Path("/devices")
@Api(value = "Device", description = "Device related operations such as get all the available devices, etc.")
@Api(value = "Device Management API", description = "This API carries all device management related operations " +
"such as get all the available devices, etc.")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public interface DeviceManagementService {
@GET
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get the device list.",
value = "Get the list of devices enrolled with the system.",
notes = "Returns all devices enrolled with the system.",
response = org.wso2.carbon.device.mgt.common.Device.class,
response = Device.class,
responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched the list of devices.", response = org.wso2.carbon
.device.mgt.common.Device.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "No device has currently been under the provided type."),
@ApiResponse(code = 500, message = "Error occurred while fetching the device list.")
@ApiResponse(code = 200, message = "OK. \n Successfully fetched the list of devices.",
response = Device.class,
responseContainer = "List",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the device list.")
})
@Permission(scope = "device-list", permissions = {"/permission/admin/device-mgt/admin/devices/list"})
Response getDevices(
@ApiParam(name = "offset", value = "Starting pagination index.",required = true)
@QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "How many device details are required from the starting pagination " +
"index.", required = true)
@QueryParam("limit") int limit);
Response getDevices(@HeaderParam("If-Modified-Since") Date timestamp, @QueryParam("offset") int offset,
@QueryParam("limit") int limit);
@GET
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get the device list corresponding to a device type.",
notes = "Returns all devices enrolled with the system under the provided type.",
response = org.wso2.carbon.device.mgt.common.Device.class,
responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched the list of devices.", response = org.wso2.carbon
.device.mgt.common.Device.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "No device has currently been under the provided type."),
@ApiResponse(code = 500, message = "Error occurred while fetching the device list.")
})
@Permission(scope = "device-list", permissions = {"/permission/admin/device-mgt/admin/devices/list"})
Response getDevices(
@ApiParam(name = "type", value = "The device type, such as ios, android or windows.", required = true)
@QueryParam ("type") String type,
@ApiParam(name = "offset", value = "Starting pagination index.",required = true)
@ApiParam(
name = "type",
value = "The device type, such as ios, android or windows.",
required = false)
@QueryParam("type") String type,
@ApiParam(
name = "user", value = "Username of owner of the devices.",
required = true)
@QueryParam("user") String user,
@ApiParam(
name = "roleName",
value = "Role name of the devices to be fetched.",
required = false)
@QueryParam("roleName") String roleName,
@ApiParam(
name = "ownership",
allowableValues = "BYOD, COPE",
value = "Ownership of the devices to be fetched registered under.",
required = false)
@QueryParam("ownership") String ownership,
@ApiParam(
name = "status",
value = "Enrollment status of devices to be fetched.",
required = false)
@QueryParam("status") String status,
@ApiParam(
name = "If-Modified-Since",
value = "Timestamp of the last modified date",
required = false)
@HeaderParam("If-Modified-Since") Date timestamp,
@ApiParam(
name = "offset",
value = "Starting point within the complete list of items qualified.",
required = false)
@QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "How many device details are required from the starting pagination " +
"index.", required = true)
@ApiParam(
name = "limit",
value = "Maximum size of resource array to return.",
required = false)
@QueryParam("limit") int limit);
@POST
@ -101,128 +132,123 @@ public interface DeviceManagementService {
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Get devices information from the supplied device identifies.",
value = "Retrieve devices information from the supplied device identifies.",
notes = "This will return device information such as CPU usage, memory usage etc for supplied device " +
"identifiers.",
response = DeviceInfo.class,
responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched device information.", response = DeviceInfo.class,
responseContainer = "List"),
@ApiResponse(code = 404, message = "No device information is available for the device list submitted."),
@ApiResponse(code = 500, message = "Error occurred while getting the device information.")
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Information of the submitted list of devices is returned",
response = DeviceInfo.class,
responseContainer = "List",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The Source URL of the document.")}),
@ApiResponse(
code = 304,
message = "Not Modified. \n " +
"Empty body because the client already has the latest version of the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 406,
message = "Not Acceptable. \n The requested media type is not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while retrieving information of the list of the devices submitted.")
})
@Permission(scope = "device-info", permissions = {"/permission/admin/device-mgt/admin/devices/list"})
Response getDevicesInfo(
@ApiParam(name = "deviceIds", value = "List of device identifiers",
required = true) List<DeviceIdentifier> deviceIds);
@GET
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get the device list of a user.",
notes = "Returns the set of devices that matches a given username.",
response = org.wso2.carbon.device.mgt.common.Device.class,
responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched the list of devices.", response = org.wso2.carbon
.device.mgt.common.Device.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "No device has currently been enrolled by the user."),
@ApiResponse(code = 500, message = "Error occurred while fetching the device list.")
})
@Permission(scope = "device-list", permissions = {"/permission/admin/device-mgt/admin/devices/list"})
Response getDeviceByUsername(
@ApiParam(name = "user", value = "Username of owner of the devices.", required = true)
@QueryParam("user") String user,
@ApiParam(name = "offset", value = "Starting pagination index.",required = true)
@QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "How many device details are required from the starting pagination " +
"index.", required = true)
@QueryParam("limit") int limit);
@GET
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Returns device list in a role.",
notes = "Returns the set of devices that matches a given role.",
response = org.wso2.carbon.device.mgt.common.Device.class,
responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched the list of devices.", response = org.wso2.carbon
.device.mgt.common.Device.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "No device has currently been enrolled under the role."),
@ApiResponse(code = 500, message = "Error occurred while fetching the device list.")
})
@Permission(scope = "device-list", permissions = {"/permission/admin/device-mgt/admin/devices/list"})
Response getDevicesByRole(
@ApiParam(name = "roleName", value = "Role name of the devices to be fetched.", required = true)
@QueryParam("roleName") String roleName,
@ApiParam(name = "offset", value = "Starting pagination index.",required = true)
@QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "How many device details are required from the starting pagination " +
"index.", required = true)
@QueryParam("limit") int limit);
@ApiParam(
name = "deviceIds",
value = "List of device identifiers",
required = true) List<DeviceIdentifier> deviceIds,
@ApiParam(
name = "If-Modified-Since",
value = "Timestamp of the last modified date",
required = false)
@HeaderParam("If-Modified-Since") Date timestamp);
@GET
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Returns device list of an ownership scheme.",
notes = "Returns the set of devices that matches a given ownership scheme.",
response = org.wso2.carbon.device.mgt.common.Device.class,
responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched the list of devices.", response = org.wso2.carbon
.device.mgt.common.Device.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "No device has currently been enrolled under the given ownership " +
"scheme."),
@ApiResponse(code = 500, message = "Error occurred while fetching the device list.")
})
@Permission(scope = "device-list", permissions = {"/permission/admin/device-mgt/admin/devices/list"})
Response getDevicesByOwnership(
@ApiParam(name = "ownership", value = "Ownership of the devices to be fetched registered under.",
required = true) EnrolmentInfo.OwnerShip ownership,
@ApiParam(name = "offset", value = "Starting pagination index.",required = true)
@QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "How many device details are required from the starting pagination " +
"index.", required = true)
@QueryParam("limit") int limit);
@GET
@Path("/{type}/{id}")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Returns device list",
notes = "Returns the set of devices that matches a given enrollment status",
response = org.wso2.carbon.device.mgt.common.Device.class,
responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched the list of devices.",
response = org.wso2.carbon.device.mgt.common.Device.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "No device is currently in the given enrollment status."),
@ApiResponse(code = 500, message = "Error occurred while fetching the device list.")
})
@Permission(scope = "device-list", permissions = {"/permission/admin/device-mgt/admin/devices/list"})
Response getDevicesByEnrollmentStatus(
@ApiParam(name = "status", value = "Enrollment status of devices to be fetched.", required = true)
EnrolmentInfo.Status status,
@ApiParam(name = "offset", value = "Starting pagination index.",required = true)
@QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "How many device details are required from the starting pagination " +
"index.", required = true)
@QueryParam("limit") int limit);
@GET
value = "Get information of the requested device.",
notes = "Returns information of the requested device.",
response = Device.class)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched information of the device.",
response = Device.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n " +
"Empty body because the client already has the latest version of the requested resource."),
@ApiResponse(
code = 404,
message = "Not Found. \n No device is found under the provided type and id."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while retrieving information requested device.")
})
@Permission(scope = "device-view", permissions = {
"/permission/admin/device-mgt/admin/devices/view",
"/permission/admin/device-mgt/user/devices/view"})
Response getDevice(@QueryParam("type") String type, @QueryParam("id") String id);
Response getDevice(
@ApiParam(
name = "type",
value = "The device type, such as ios, android or windows.",
required = true)
@PathParam("type") String type,
@ApiParam(
name = "id",
value = "The device identifier of the device.",
required = true)
@PathParam("id") String id,
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince);
@GET
@Path("/{type}/{id}/location")
@ -234,18 +260,40 @@ public interface DeviceManagementService {
notes = "This will return the device location including latitude and longitude as well the "
+ "physical address.",
response = DeviceLocation.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched the device location.",
response = DeviceLocation.class),
@ApiResponse(code = 404, message = "Location details are not available for the given device."),
@ApiResponse(code = 500, message = "Error occurred while getting the device location.")
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "Successfully fetched the device location.",
response = DeviceLocation.class),
@ApiResponse(
code = 304,
message = "Not Modified. \n " +
"Empty body because the client already has the latest version of the requested resource."),
@ApiResponse(
code = 404,
message = "Location details are not available for the given device."),
@ApiResponse(
code = 500,
message = "Error occurred while getting the device location.")
})
@Permission(scope = "device-info", permissions = {"/permission/admin/device-mgt/admin/devices/list"})
Response getDeviceLocation(
@ApiParam(name = "type", value = "The device type, such as ios, android or windows.", required = true)
@ApiParam(
name = "type",
value = "The device type, such as ios, android or windows.",
required = true)
@PathParam("type") String type,
@ApiParam(name = "id", value = "The device identifier of the device.", required = true)
@PathParam("id") String id);
@ApiParam(
name = "id",
value = "The device identifier of the device.",
required = true)
@PathParam("id") String id,
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince);
@GET
@Path("/{type}/{id}/features")
@ -257,20 +305,71 @@ public interface DeviceManagementService {
notes = "WSO2 EMM features enable you to carry out many operations on a given device platform. " +
"Using this REST API you can get the features that can be carried out on a preferred device type," +
" such as iOS, Android or Windows.",
response = org.wso2.carbon.device.mgt.common.Feature.class,
response = Feature.class,
responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched the features.",
response = org.wso2.carbon.device.mgt.common.Feature.class, responseContainer = "List"),
@ApiResponse(code = 500, message = "Error occurred while retrieving the list of features.")
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n List of features of the device is returned",
response = Feature.class,
responseContainer = "List",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
message = "See Other. \n " +
"Source can be retrieved from the URL specified at the Location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The Source URL of the document.")}),
@ApiResponse(
code = 304,
message = "Not Modified. \n " +
"Empty body because the client already has the latest version of the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Device of which the feature list is requested, is not found."),
@ApiResponse(
code = 406,
message = "Not Acceptable. \n The requested media type is not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while retrieving feature list of the device.")
})
@Permission(scope = "device-search", permissions = {"/permission/admin/device-mgt/admin/devices/view",
"/permission/admin/device-mgt/user/devices/view"})
Response getFeaturesOfDevice(
@ApiParam(name = "type", value = "The device type, such as ios, android or windows.", required = true)
@ApiParam(
name = "type",
value = "The device type, such as ios, android or windows.",
required = true)
@PathParam("type") String type,
@ApiParam(name = "id", value = "The device identifier of the device.", required = true)
@PathParam("id") String id);
@ApiParam(
name = "id",
value = "The device identifier of the device.",
required = true)
@PathParam("id") String id,
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince);
@POST
@Path("/search-devices")
@ -282,74 +381,300 @@ public interface DeviceManagementService {
notes = "Carry out an advanced search of devices.",
response = DeviceWrapper.class,
responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched matching devices.", response = DeviceWrapper.class,
responseContainer = "List"),
@ApiResponse(code = 500, message = "Error occurred while searching the device information.")
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Device has successfully been enrolled. Location header " +
"contains URL of newly enrolled device",
response = DeviceWrapper.class,
responseContainer = "List",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 304,
message = "Not Modified. \n " +
"Empty body because the client already has the latest version of the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while enrolling the device.")
})
@Permission(scope = "device-search", permissions = {"/permission/admin/device-mgt/admin/devices/list"})
Response searchDevices(
@ApiParam(name = "searchContext", value = "List of search conditions.",
required = true) SearchContext searchContext);
@ApiParam(
name = "searchContext",
value = "List of search conditions.",
required = true) SearchContext searchContext,
@ApiParam(
name = "offset",
value = "Starting point within the complete list of items qualified.",
required = false)
@QueryParam("offset") int offset,
@ApiParam(
name = "limit",
value = "Maximum size of resource array to return.",
required = false)
@QueryParam("limit") int limit);
@GET
@Path("/{type}/{id}/applications")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting installed application details of a device.",
responseContainer = "List",
notes = "Get the list of applications that a device has subscribed.",
response = Application.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "List of installed application details of a device.",
response = Application.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "No installed applications found on the device searched."),
@ApiResponse(code = 500, message = "Error occurred while fetching the apps of the device.")
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n List of applications installed into the device is returned",
response = Application.class,
responseContainer = "List",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
message = "See Other. \n " +
"Source can be retrieved from the URL specified at the Location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The Source URL of the document.")}),
@ApiResponse(
code = 304,
message = "Not Modified. \n " +
"Empty body because the client already has the latest version of the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Device of which the application list is requested, is not found."),
@ApiResponse(
code = 406,
message = "Not Acceptable. \n The requested media type is not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while retrieving installed application list of the device.")
})
@Permission(scope = "operation-view", permissions = {
"/permission/admin/device-mgt/admin/devices/view",
"/permission/admin/device-mgt/user/devices/view"
})
Response getInstalledApplications(
@ApiParam(name = "type", value = "The device type, such as ios, android or windows.", required = true)
@ApiParam(
name = "type",
value = "The device type, such as ios, android or windows.", required = true)
@PathParam("type") String type,
@ApiParam(name = "id", value = "The device identifier of the device.", required = true)
@PathParam("id") String id);
@ApiParam(
name = "id",
value = "The device identifier of the device.",
required = true)
@PathParam("id") String id,
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince,
@ApiParam(
name = "offset",
value = "Starting point within the complete list of items qualified.",
required = false)
@QueryParam("offset") int offset,
@ApiParam(
name = "limit",
value = "Maximum size of resource array to return.",
required = false)
@QueryParam("limit") int limit);
@GET
@Path("/{type}/{id}/operations")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting paginated details for operations on a device.",
notes = "You will carry out many operations on a device. In a situation where you wish to view the all" +
" the operations carried out on a device it is not feasible to show all the details on one page" +
" therefore the details are paginated.",
response = org.wso2.carbon.device.mgt.common.operation.mgt.Operation.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "List of Operations on a device.",
response = org.wso2.carbon.device.mgt.common.operation.mgt.Operation.class,
responseContainer = "List"),
@ApiResponse(code = 500, message = "Error occurred while fetching the operations for the " +
"device.")
})
response = Operation.class)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n List of operations scheduled for the device is returned",
response = Operation.class,
responseContainer = "List",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
message = "See Other. \n " +
"Source can be retrieved from the URL specified at the Location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The Source URL of the document.")}),
@ApiResponse(
code = 304,
message = "Not Modified. \n " +
"Empty body because the client already has the latest version of the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Device of which the operation list is requested, is not found."),
@ApiResponse(
code = 406,
message = "Not Acceptable. \n The requested media type is not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while retrieving operation list scheduled for the device.")
})
@Permission(scope = "operation-view", permissions = {
"/permission/admin/device-mgt/admin/devices/view",
"/permission/admin/device-mgt/user/devices/view"
})
Response getDeviceOperations(
@ApiParam(name = "offset", value = "Starting pagination index.",required = true)
@QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "How many device details are required from the starting pagination " +
"index.", required = true)
@QueryParam("limit") int limit,
@ApiParam(name = "type", value = "The device type, such as ios, android or windows.", required = true)
@ApiParam(
name = "type",
value = "The device type, such as ios, android or windows.",
required = true)
@PathParam("type") String type,
@ApiParam(name = "id", value = "The device identifier of the device.", required = true)
@PathParam("id") String id);
@ApiParam(
name = "id",
value = "The device identifier of the device.",
required = true)
@PathParam("id") String id,
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince,
@ApiParam(
name = "offset",
value = "Starting point within the complete list of items qualified.",
required = false)
@QueryParam("offset") int offset,
@ApiParam(
name = "limit",
value = "Maximum size of resource array to return.",
required = false)
@QueryParam("limit") int limit);
@GET
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get the effective policy calculated for a device.",
notes = "When a device registers with WSO2 EMM a policy is enforced on the device. Initially the EMM " +
"filters the policies based on the Platform (device type), filters based on the device ownership" +
" type , filters based on the user role or name and finally the policy is enforced on the device.",
response = Policy.class)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Effective policy calculated for the device is returned",
response = Policy.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
message = "See Other. \n " +
"Source can be retrieved from the URL specified at the Location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The Source URL of the document.")}),
@ApiResponse(
code = 304,
message = "Not Modified. \n " +
"Empty body because the client already has the latest version of the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Device of which the effective policy is requested, is not found."),
@ApiResponse(
code = 406,
message = "Not Acceptable. \n The requested media type is not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while retrieving the effective policy calculated for the device.")
})
Response getEffectivePolicyOfDevice(
@ApiParam(
name = "type",
value = "The device type, such as ios, android or windows.",
required = true)
@QueryParam("type") String type,
@ApiParam(
name = "id",
value = "Device Identifier",
required = true)
@QueryParam("id") String id,
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince);
}

@ -30,9 +30,9 @@ import javax.ws.rs.core.Response;
/**
* Notifications related REST-API.
*/
@API(name = "Device Notification", version = "1.0.0", context = "/devicemgt_admin/notifications",
@API(name = "Device Notification Management API", version = "1.0.0", context = "/devicemgt_admin/notifications",
tags = {"devicemgt_admin"})
@Api(value = "DeviceNotification", description = "Device notification related operations can be found here.")
@Api(value = "Device Notification Management API", description = "Device notification related operations can be found here.")
@Path("/notifications")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@ -40,7 +40,6 @@ public interface NotificationManagementService {
@GET
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting all device notification details.",
@ -48,52 +47,62 @@ public interface NotificationManagementService {
+ "this REST API",
response = Notification.class,
responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched the list of notifications",
response = Notification.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "No notification is available to be retrieved."),
@ApiResponse(code = 500, message = "Error occurred while retrieving the notification list.")
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the list of notifications.",
response = Notification.class,
responseContainer = "List",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the notification list.")
})
@Permission(scope = "device-notification-view", permissions = {
"/permission/admin/device-mgt/admin/notifications/view",
"/permission/admin/device-mgt/user/notifications/view"
})
Response getNotifications(
@ApiParam(name = "offset", value = "Starting pagination index.",required = true)
@ApiParam(name = "status",
value = "Status of the notification.",
allowableValues = "NEW, CHECKED",
required = true)
@QueryParam("status") String status,
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince,
@ApiParam(
name = "offset",
value = "Starting point within the complete list of items qualified.",
required = false)
@QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "How notification device details are required from the starting " +
"pagination index.", required = true)
@ApiParam(
name = "limit",
value = "Maximum size of resource array to return.",
required = false)
@QueryParam("limit") int limit);
@GET
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting the device notifications filtered by the status.",
notes = "Get the details of all the unread notifications or the details of all the read "
+ "notifications using this REST API.",
response = Notification.class,
responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched the list of notifications.",
response = Notification.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "No notification, which carries the given status " +
"is available to be retrieved."),
@ApiResponse(code = 500, message = "Error occurred while retrieving the notification list.")
})
@Permission(scope = "device-notification-view", permissions = {
"/permission/admin/device-mgt/admin/notifications/view",
"/permission/admin/device-mgt/user/notifications/view"
})
Response getNotificationsByStatus(
@ApiParam(name = "status", value = "Status of the notification.",required = true)
Notification.Status status,
@ApiParam(name = "offset", value = "Starting pagination index.",required = true)
@QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "How many notification details are required from the starting pagination " +
"index.", required = true)
@QueryParam("limit") int limit);
@PUT
@Path("/{id}/status")
@ -101,35 +110,100 @@ public interface NotificationManagementService {
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "PUT",
value = "Updating the device notification status",
value = "Update the device notification status",
notes = "When a user has read the the device notifications, the device notification status must "
+ "change from NEW to CHECKED. Update the device notification status using this REST API.")
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Notification status updated successfully."),
@ApiResponse(code = 500, message = "Error occurred while updating notification status.")
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Notification status has been updated successfully",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The URL of the updated device."),
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while modifying status of the notification.")
})
@Permission(scope = "device-notification-modify",
permissions = {"/permission/admin/device-mgt/admin/notifications/modify"})
Response updateNotificationStatus(
@ApiParam(name = "id", value = "The device identifier of the device.", required = true)
@ApiParam(
name = "id",
value = "Notification identifier.",
required = true)
@PathParam("id") int id,
@ApiParam(name = "status", value = "Status of the notification.",required = true)
Notification.Status status);
@ApiParam(
name = "status",
value = "Status of the notification.",
allowableValues = "NEW, CHECKED",
required = true) String status);
@POST
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Sending a device notification.",
notes = "Notify users on device operation failures and other information using this REST API.")
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Notification has added successfully."),
@ApiResponse(code = 500, message = "Error occurred while updating notification status.")
})
value = "Add a device notification.",
notes = "Add a device notification, which will then be sent to a device.")
@ApiResponses(
value = {
@ApiResponse(code = 201, message = "Created. \n Notification has been added successfully.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The URL of the added notification."),
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")
}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while adding the notification.")
})
@Permission(scope = "device-notification-modify",
permissions = {"/permission/admin/device-mgt/admin/notifications/modify"})
Response addNotification(@ApiParam(name = "notification", value = "Notification details to be added.",required =
true) Notification notification);
Response addNotification(
@ApiParam(
name = "notification",
value = "Notification details to be added.",
required = true) Notification notification);
}

@ -18,12 +18,10 @@
*/
package org.wso2.carbon.device.mgt.jaxrs.service.api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.Permission;
import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper;
import org.wso2.carbon.policy.mgt.common.Policy;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
@ -44,38 +42,106 @@ public interface PolicyManagementService {
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Adding a policy.",
notes = "Add a policy using this REST API command. Using the REST API command given below " +
"you are able to save a created Policy and this policy will be in the inactive state.")
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Created the policy."),
@ApiResponse(code = 401, message = "Current user is not authorized to add policies."),
@ApiResponse(code = 500, message = "Policy Management related error occurred when adding the policy.")})
value = "Add a new policy.",
notes = "This particular resource can be used to add a new policy, which will be created in in-active state.")
@ApiResponses(
value = {
@ApiResponse(
code = 201,
message = "Created. \n Policy has successfully been created",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The URL of the added policy."),
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The Source URL of the document.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while adding a new policy.")})
@Permission(scope = "policy-modify", permissions = {"/permission/admin/device-mgt/admin/policies/add"})
Response addPolicy(@ApiParam(name = "policy", value = "Policy details related to the operation.",
required = true) PolicyWrapper policy);
Response addPolicy(
@ApiParam(
name = "policy",
value = "Policy details related to the operation.",
required = true) PolicyWrapper policy);
@GET
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting details of policies.",
value = "Get details of policies.",
responseContainer = "List",
notes = "Retrieve the details of all the policies that you have created in EMM.",
response = org.wso2.carbon.policy.mgt.common.Policy.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Fetched all policies.",
response = org.wso2.carbon.policy.mgt.common.Policy.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "No policies found."),
@ApiResponse(code = 500, message = "Policy Management related error occurred when " +
"fetching the policies.")
})
notes = "Retrieve the details of all the policies that have been created in EMM.",
response = Policy.class)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched policies.",
response = Policy.class,
responseContainer = "List",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching policies.")
})
@Permission(scope = "policy-view", permissions = {"/permission/admin/device-mgt/admin/policies/list"})
Response getPolicies(
@ApiParam(name = "offset", value = "Starting pagination index.",required = true)
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince,
@ApiParam(
name = "offset",
value = "Starting point within the complete list of items qualified.",
required = false)
@QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "How many policy details are required from the starting pagination " +
"index.", required = true)
@ApiParam(
name = "limit",
value = "Maximum size of resource array to return.",
required = false)
@QueryParam("limit") int limit);
@GET
@ -83,20 +149,53 @@ public interface PolicyManagementService {
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting details of a policy.",
notes = "Retrieve the details of a given policy in EMM.",
response = org.wso2.carbon.policy.mgt.common.Policy.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Fetched policy details.",
response = org.wso2.carbon.policy.mgt.common.Policy.class),
@ApiResponse(code = 404, message = "Policy not found."),
@ApiResponse(code = 500, message = "Policy management related error occurred when " +
"fetching the policy.")
})
value = "Get details of a policy.",
notes = "Retrieve the details of a given policy that has been created in EMM.",
response = Policy.class)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the policy.",
response = Policy.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 404,
message = "Not Found. \n No policy is found with the given id."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the policy.")
})
@Permission(scope = "policy-view", permissions = {"/permission/admin/device-mgt/admin/policies/list"})
Response getPolicy(
@ApiParam(name = "id", value = "The device identifier of the device.", required = true)
@PathParam("id") int id);
@ApiParam(
name = "id",
value = "Policy identifier",
required = true)
@PathParam("id") int id,
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince);
@PUT
@Path("/{id}")
@ -104,35 +203,86 @@ public interface PolicyManagementService {
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "PUT",
value = "Updating a policy.",
notes = "If you wish to make changes to an existing policy, you can do so by updating the policy using " +
"this API.")
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Policy has been updated successfully."),
@ApiResponse(code = 500, message = "Policy management related exception in policy update.")
})
value = "Update a policy.",
notes = "If you wish to make changes to an existing policy, that can be done by updating the policy using " +
"this resource.")
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Policy has been updated successfully",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The URL of the updated device."),
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while updating the policy.")
})
@Permission(scope = "policy-modify", permissions = {"/permission/admin/device-mgt/admin/policies/update"})
Response updatePolicy(
@ApiParam(name = "id", value = "The device identifier of the device.", required = true)
@ApiParam(
name = "id",
value = "The device identifier of the device.", required = true)
@PathParam("id") int id,
@ApiParam(name = "policy", value = "Policy details related to the operation.",
required = true) PolicyWrapper policy);
@ApiParam(
name = "policy",
value = "Policy details related to the operation.",
required = true) PolicyWrapper policy);
@POST
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Removing multiple policies.",
value = "Remove multiple policies.",
notes = "In situations where you need to delete more than one policy you can do so using this API.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Policies have been successfully deleted."),
@ApiResponse(code = 404, message = "Policy does not exist."),
@ApiResponse(code = 500, message = "Error in deleting policies.")
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Policies have successfully been removed"),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while bulk removing policies.")
})
@Permission(scope = "policy-modify", permissions = {"/permission/admin/device-mgt/admin/policies/remove"})
Response removePolicies(@ApiParam(name = "policyIds", value = "Policy ID list to be deleted.",
required = true) List<Integer> policyIds);
Response removePolicies(
@ApiParam(
name = "policyIds",
value = "Policy id list to be deleted.",
required = true) List<Integer> policyIds);
@POST
@Path("/activate-policy")
@ -143,16 +293,17 @@ public interface PolicyManagementService {
value = "Activating policies.",
notes = "Using the REST API command you are able to publish a policy in order to bring a policy that is " +
"in the inactive state to the active state.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Policies have been successfully activated."),
@ApiResponse(code = 500, message = "Error in activating policies.")
})
@ApiResponses(
value = {
@ApiResponse(code = 200, message = "Policies have been successfully activated."),
@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 activatePolicies(
@ApiParam(name = "policyIds", value = "Policy ID list to be activated.",
required = true) List<Integer> policyIds);
required = true) List<Integer> policyIds);
@POST
@Path("/deactivate-policy")
@ -172,26 +323,7 @@ public interface PolicyManagementService {
"/permission/admin/device-mgt/admin/policies/add"})
Response deactivatePolicies(
@ApiParam(name = "policyIds", value = "Policy ID list to be deactivated.",
required = true) List<Integer> policyIds);
required = true) List<Integer> policyIds);
@GET
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting Policy Enforced Details of a Device.",
notes = "When a device registers with WSO2 EMM a policy is enforced on the device. Initially the EMM " +
"filters the policies based on the Platform (device type), filters based on the device ownership" +
" type , filters based on the user role or name and finally the policy is enforced on the device.",
response = org.wso2.carbon.policy.mgt.common.Policy.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Fetched current policy."),
@ApiResponse(code = 404, message = "No policy found."),
@ApiResponse(code = 500, message = "Error occurred while getting the current policy.")
})
Response getEffectivePolicyOfDevice(
@ApiParam(name = "device-type", value = "The device type, such as ios, android or windows.", required = true)
@QueryParam("device-type") String type,
@ApiParam(name = "device-id", value = "The device identifier of the device.", required = true)
@QueryParam("device-id") String deviceId);
}

@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.apimgt.annotations.api.Permission;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleWrapper;
import org.wso2.carbon.user.mgt.common.UIPermissionNode;
@ -38,93 +39,78 @@ public interface RoleManagementService {
@GET
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting the list of roles.",
value = "Get the list of roles.",
responseContainer = "List",
notes = "If you wish to get the details of all the roles in EMM, you can do so using this REST API. All " +
"internal roles, roles created for Service-providers and application related roles are omitted.",
response = String.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched the list of available roles",
response = String.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "No roles found."),
@ApiResponse(code = 500, message = "Error occurred while fetching the role list.")
})
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the requested list of roles.",
response = String.class,
responseContainer = "List",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching requested list of roles.")
})
@Permission(scope = "roles-view", permissions = {
"/permission/admin/device-mgt/admin/roles/list",
"/permission/admin/device-mgt/admin/users/view",
"/permission/admin/device-mgt/admin/policies/add",
"/permission/admin/device-mgt/admin/policies/update"})
Response getRoles(
@ApiParam(name = "offset", value = "Starting pagination index.",required = true)
@QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "How many role details are required from the starting pagination " +
"index.", required = true)
@QueryParam("limit") int limit);
@GET
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting the list of roles in a user store.",
responseContainer = "List",
notes = "If you wish to get the details of all the roles in EMM, you can do so using this REST API.",
response = String.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched the list of available roles",
response = String.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "No roles found."),
@ApiResponse(code = 500, message = "Error occurred while fetching the role list.")
})
@Permission(scope = "roles-view", permissions = {
"/permission/admin/device-mgt/admin/users/add",
"/permission/admin/device-mgt/admin/roles/list"})
Response getRoles(
@ApiParam(name = "user-store", value = "From which user store the roles must be fetched.",required = true)
@QueryParam("user-store") String userStoreName,
@ApiParam(name = "offset", value = "Starting pagination index.",required = true)
@QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "How many role details are required from the starting pagination " +
"index.", required = true)
@QueryParam("limit") int limit);
@GET
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Searching for roles via the role name.",
responseContainer = "List",
notes = "You will have many roles created within EMM. As the admin you will need to confirm if a " +
"given role exists in the EMM. In such situation you can search for the role by giving a " +
"character or a few characters of the role name. The search will give you a list of roles that" +
" have the name in the exact order of the characters you provided.",
response = String.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched the list of matching roles.",
response = String.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "No roles found."),
@ApiResponse(code = 500, message = "Error occurred while fetching the matching role list.")
})
@Permission(scope = "roles-view", permissions = {
"/permission/admin/device-mgt/admin/users/add",
"/permission/admin/device-mgt/admin/roles/list"})
Response searchRoles(
@ApiParam(name = "filter", value = "Role name or a part of it to search.",required = true)
@ApiParam(
name = "filter",
value = "Role name or a part of it to search.",
required = false)
@QueryParam("filter") String filter,
@ApiParam(name = "offset", value = "Starting pagination index.",required = true)
@ApiParam(
name = "user-store",
value = "From which user store the roles must be fetched.",
required = false)
@QueryParam("user-store") String userStoreName,
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince,
@ApiParam(
name = "offset",
value = "Starting point within the complete list of items qualified.",
required = false)
@QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "How many role details are required from the starting pagination " +
"index.", required = true)
@ApiParam(
name = "limit",
value = "Maximum size of resource array to return.",
required = false)
@QueryParam("limit") int limit);
@GET
@Path("/{roleName}/permissions")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting permission details of a role.",
@ -132,51 +118,158 @@ public interface RoleManagementService {
"role. In EMM you are able to configure permissions based on the responsibilities carried " +
"out by a role. Therefore if you wish to retrieve the permission details of a role, you can do " +
"so using this REST API.",
response = UIPermissionNode.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Permission details of a role", response = UIPermissionNode.class),
@ApiResponse(code = 404, message = "No permissions found for the role."),
@ApiResponse(code = 500, message = "Error occurred while fetching the permission details of a role.")
})
response = UIPermissionNode.class,
responseContainer = "List"
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the permission list of the given role.",
response = UIPermissionNode.class,
responseContainer = "List",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the permission list of the requested role.")
})
@Permission(scope = "roles-view", permissions = {"/permission/admin/device-mgt/admin/roles/list"})
Response getPermissionsOfRole(
@ApiParam(name = "roleName", value = "Name of the role.",required = true)
@PathParam("roleName") String roleName);
@ApiParam(
name = "roleName",
value = "Name of the role.",
required = true)
@PathParam("roleName") String roleName,
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince);
@GET
@Path("/{roleName}")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting details of a role.",
value = "Get details of a role.",
notes = "If you wish to get the details of a role in EMM, you can do so using this REST API.",
response = RoleWrapper.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched the role details.", response = RoleWrapper.class),
@ApiResponse(code = 404, message = "No role details found for the provided role name."),
@ApiResponse(code = 500, message = "Error occurred while retrieving the role details.")
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the requested role.",
response = RoleWrapper.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the requested role.")
})
@Permission(scope = "roles-view", permissions = {"/permission/admin/device-mgt/admin/roles/list"})
Response getRole(
@ApiParam(name = "roleName", value = "Name of the role.",required = true)
@PathParam("roleName") String roleName);
@ApiParam(
name = "roleName",
value = "Name of the role.",
required = true)
@PathParam("roleName") String roleName,
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince);
@POST
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Adding a role.",
value = "Add a role.",
notes = "You are able to add a new role to EMM using the REST API.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Added the role."),
@ApiResponse(code = 500, message = "Error occurred while adding the user role.")
@ApiResponse(
code = 201,
message = "Created. \n Role has successfully been created",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The URL of the role added."),
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The Source URL of the document.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while adding a new role.")
})
@Permission(scope = "roles-modify", permissions = {"/permission/admin/device-mgt/admin/roles/add"})
Response addRole(
@ApiParam(name = "role", value = "Details about the role to be added.",required = true)
RoleWrapper role);
@ApiParam(
name = "role",
value = "Details about the role to be added.",
required = true) RoleWrapper role);
@PUT
@Path("/{roleName}")
@ -184,60 +277,138 @@ public interface RoleManagementService {
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "PUT",
value = "Updating a role.",
value = "Update a role.",
notes = "There will be situations where you will need to update the role details, such as the permissions" +
" or the role name. In such situation you can update the role details.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Updated the role."),
@ApiResponse(code = 500, message = "Error occurred while updating the user role details.")
@ApiResponse(
code = 200,
message = "OK. \n Role has been updated successfully",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "URL of the updated role."),
@ResponseHeader(
name = "Content-Type",
description = "Content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while updating the role.")
})
@Permission(scope = "roles-modify", permissions = {"/permission/admin/device-mgt/admin/roles/update"})
Response updateRole(
@ApiParam(name = "roleName", value = "Name of the role.",required = true)
@ApiParam(
name = "roleName",
value = "Name of the role.",
required = true)
@PathParam("roleName") String roleName,
@ApiParam(name = "role", value = "Details about the role to be added.",required = true)
RoleWrapper role);
@ApiParam(
name = "role",
value = "Details about the role to be added.",
required = true) RoleWrapper role);
@DELETE
@Path("/{roleName}")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "DELETE",
value = "Deleting a role.",
value = "Delete a role.",
notes = "In a situation when your Organization identifies that a specific role is no longer required you " +
"will need to remove the role details from EMM.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Deleted the role."),
@ApiResponse(code = 500, message = "Error occurred while deleting the user role details.")
@ApiResponse(
code = 200,
message = "OK. \n Role has successfully been removed"),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while removing the role.")
})
@Permission(scope = "roles-modify", permissions = {"/permission/admin/device-mgt/admin/roles/remove"})
Response deleteRole(
@ApiParam(name = "roleName", value = "Name of the role to de deleted.",required = true)
@ApiParam(
name = "roleName",
value = "Name of the role to de deleted.",
required = true)
@PathParam("roleName") String roleName);
@POST
@PUT
@Path("/{roleName}/users")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "PUT",
value = "Adding users to a role.",
value = "Add users to a role.",
notes = "Defining the users to a role at the point of creating a new role is optional, " +
"therefore you are able to update the users that belong to a given role after you have created " +
"a role using this REST API." +
"Example: Your Organization hires 30 new engineers. Updating the role details for each user can " +
"be cumbersome, therefore you can define all the new employees that belong to the engineering " +
"role using this API.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Added Users to a Role."),
@ApiResponse(code = 500, message = "Error occurred while saving the users of the role.")
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n User list of the role has been updated successfully",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "URL of the updated user list."),
@ResponseHeader(
name = "Content-Type",
description = "Content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while updating the user list of the role.")
})
@Permission(scope = "roles-modify", permissions = {"/permission/admin/device-mgt/admin/roles/update"})
Response updateUsersOfRole(
@ApiParam(name = "roleName", value = "Name of the role.",required = true)
@ApiParam(
name = "roleName",
value = "Name of the role.",
required = true)
@PathParam("roleName") String roleName,
@ApiParam(name = "users", value = "List of usernames to be added.",required = true)
List<String> users);
@ApiParam(
name = "users",
value = "List of usernames to be added.",
required = true) List<String> users);
}

@ -27,11 +27,12 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.UserWrapper;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Date;
@API(name = "UserManagement", version = "1.0.0", context = "/devicemgt_admin/users", tags = {"devicemgt_admin"})
@API(name = "User Management API", version = "1.0.0", context = "/devicemgt_admin/users", tags = {"devicemgt_admin"})
@Path("/users")
@Api(value = "UserManagement", description = "User management related operations can be found here.")
@Api(value = "User Management API", description = "User management related operations can be found here.")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public interface UserManagementService {
@ -41,15 +42,52 @@ public interface UserManagementService {
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Adding a user.",
notes = "Adds a new user to EMM using this REST API.")
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Added the user successfully."),
@ApiResponse(code = 500, message = "Exception in trying to add the user.")
})
value = "Add a user.",
notes = "A new user can be added to the user management system via this resource")
@ApiResponses(
value = {
@ApiResponse(
code = 201,
message = "Created. \n User has successfully been created",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The URL of the role added."),
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The Source URL of the document.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while adding a new user.")
})
@Permission(scope = "user-modify", permissions = {"/permission/admin/device-mgt/admin/user/add"})
Response addUser(
@ApiParam(name = "user", value = "User related details.",required = true) UserWrapper user);
@ApiParam(
name = "user",
value = "User related details.",
required = true) UserWrapper user);
@GET
@Path("/{username}")
@ -62,15 +100,48 @@ public interface UserManagementService {
+ " you can do so using the REST API.",
response = UserWrapper.class)
@ApiResponses(value = {
@ApiResponse(code = 201, message = "User information was retrieved successfully.",
response = UserWrapper.class),
@ApiResponse(code = 404, message = "User by the provided username does not exist."),
@ApiResponse(code = 500, message = "Exception in trying to retrieve user by username.")
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the requested role.",
response = UserWrapper.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the requested user.")
})
@Permission(scope = "user-view", permissions = {"/permission/admin/device-mgt/admin/user/view"})
Response getUser(
@ApiParam(name = "username", value = "Username of the user to be fetched.",required = true)
@PathParam("username") String username);
@ApiParam(
name = "username",
value = "Username of the user to be fetched.",
required = true)
@PathParam("username") String username,
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince);
@PUT
@Path("/{username}")
@ -78,95 +149,192 @@ public interface UserManagementService {
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "PUT",
value = "Updating details of a user",
value = "Update details of a user",
notes = "There will be situations where you will want to update the user details. In such "
+ "situation you can update the user details using this REST API.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "User was successfully updated"),
@ApiResponse(code = 409, message = "User by the provided username doesn't exists. Therefore, "
+ "request made to update user was refused."),
@ApiResponse(code = 500, message = "Exception in trying to update user by username: 'username'")
@ApiResponse(
code = 200,
message = "OK. \n User has been updated successfully",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "URL of the updated user."),
@ResponseHeader(
name = "Content-Type",
description = "Content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while updating the user.")
})
@Permission(scope = "user-modify", permissions = {"/permission/admin/device-mgt/admin/user/update"})
Response updateUser(
@ApiParam(name = "username", value = "Username of the user to be updated.",required = true)
@ApiParam(
name = "username",
value = "Username of the user to be updated.",
required = true)
@PathParam("username") String username,
@ApiParam(name = "user", value = "User related details.",required = true)
UserWrapper user);
@ApiParam(
name = "userData",
value = "User related details.",
required = true) UserWrapper userData);
@DELETE
@Path("/{username}")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "DELETE",
value = "Deleting a user.",
notes = "In a situation where an employee leaves the organization you will need to remove the"
+ " user details from EMM. In such situations you can use this REST API to remove a user.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "User was successfully removed."),
@ApiResponse(code = 404, message = "User does not exist for removal."),
@ApiResponse(code = 500, message = "Exception in trying to remove user.")
@ApiResponse(
code = 200,
message = "OK. \n User has successfully been removed"),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while removing the user.")
})
@Permission(scope = "user-modify", permissions = {"/permission/admin/device-mgt/admin/user/remove"})
Response removeUser(
@ApiParam(name = "username", value = "Username of the user to be deleted.",required = true)
@ApiParam(name = "username", value = "Username of the user to be deleted.", required = true)
@PathParam("username") String username);
@POST
@GET
@Path("/{username}/roles")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting the role details of a user.",
value = "Get the role list of a user.",
notes = "A user can be assigned to one or more role in EMM. Using this REST API you are "
+ "able to get the role/roles a user is assigned to.",
response = String.class,
responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "User roles obtained for the provided user.", response = String.class,
responseContainer = "List"),
@ApiResponse(code = 404, message = "User does not exist for role retrieval."),
@ApiResponse(code = 500, message = "Exception in trying to retrieve roles for the provided user.")
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the role list assigned to the user.",
response = String.class,
responseContainer = "List",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the role list assigned to the user.")
})
@Permission(scope = "user-view", permissions = {"/permission/admin/device-mgt/admin/user/view"})
Response getRolesOfUser(
@ApiParam(name = "username", value = "Username of the user.",required = true)
@ApiParam(name = "username", value = "Username of the user.", required = true)
@PathParam("username") String username);
@GET
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting details of users",
notes = "If you wish to get the details of all the user registered with EMM, you can do so "
value = "Get user list",
notes = "If you wish to get the details of all the users registered with EMM, you can do so "
+ "using the REST API",
response = UserWrapper.class,
responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "All users were successfully retrieved.", response = UserWrapper.class,
responseContainer = "List"),
@ApiResponse(code = 404, message = "No users found."),
@ApiResponse(code = 500, message = "Error occurred while retrieving the list of users.")
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the requested role.",
response = UserWrapper.class,
responseContainer = "List",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the user list.")
})
@Permission(scope = "user-view", permissions = {"/permission/admin/device-mgt/admin/user/list"})
Response getUsers(
@ApiParam(name = "filter", value = "Username of the user details to be fetched.",required = true)
@ApiParam(
name = "filter",
value = "Username of the user details to be fetched.",
required = true)
@QueryParam("filter") String filter,
@ApiParam(name = "offset", value = "Starting pagination index.",required = true)
@ApiParam(
name = "If-Modified-Since",
value = "Timestamp of the last modified date",
required = false)
@HeaderParam("If-Modified-Since") Date timestamp,
@ApiParam(
name = "offset",
value = "Starting point within the complete list of items qualified.",
required = false)
@QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "How many user details are required from the starting pagination " +
"index.", required = true)
@ApiParam(
name = "limit",
value = "Maximum size of resource array to return.",
required = false)
@QueryParam("limit") int limit);
@GET
@Path("/usernames")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Searching for a username.",
value = "Search for a username.",
notes = "If you are unsure of the "
+ "user name of a user and need to retrieve the details of a specific user, you can "
+ "search for that user by giving a character or a few characters in the username. "
@ -175,19 +343,55 @@ public interface UserManagementService {
response = String.class,
responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "All users by username were successfully retrieved.",
response = String.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "No users found."),
@ApiResponse(code = 500, message = "Error occurred while retrieving the list of users.")
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the username list that matches the given filter.",
response = String.class,
responseContainer = "List",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the username list that matches the given filter.")
})
@Permission(scope = "user-view", permissions = {"/permission/admin/device-mgt/admin/user/list"})
Response getUserNames(
@ApiParam(name = "filter", value = "Username/part of the user name to search.",required = true)
@ApiParam(
name = "filter",
value = "Username/part of the user name to search.",
required = true)
@QueryParam("filter") String filter,
@ApiParam(name = "offset", value = "Starting pagination index.",required = true)
@ApiParam(
name = "If-Modified-Since",
value = "Timestamp of the last modified date",
required = false)
@HeaderParam("If-Modified-Since") Date timestamp,
@ApiParam(
name = "offset",
value = "Starting point within the complete list of items qualified.",
required = false)
@QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "How many user details are required from the starting pagination " +
"index.", required = true)
@ApiParam(
name = "limit",
value = "Maximum size of resource array to return.",
required = false)
@QueryParam("limit") int limit);
@PUT
@ -199,16 +403,33 @@ public interface UserManagementService {
value = "Changing the user password.",
notes = "A user is able to change the password to secure their EMM profile via this REST API.")
@ApiResponses(value = {
@ApiResponse(code = 201, message = "User password was successfully changed."),
@ApiResponse(code = 400, message = "Old password does not match."),
@ApiResponse(code = 500, message = "Could not change the password of the user. The Character encoding is" +
" not supported.")
@ApiResponse(
code = 200,
message = "OK. \n Credentials of the user have been updated successfully"),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while updating credentials of the user.")
})
@Permission(scope = "user-modify", permissions = {"/permission/admin/login"})
Response resetPassword(
@ApiParam(name = "username", value = "Username of the user.",required = true)
@ApiParam(
name = "username",
value = "Username of the user.",
required = true)
@PathParam("username") String username,
@ApiParam(name = "credentials", value = "Credential.",required = true)
UserCredentialWrapper credentials);
@ApiParam(
name = "credentials",
value = "Credential.",
required = true) UserCredentialWrapper credentials);
}

@ -46,11 +46,28 @@ public interface ApplicationManagementAdminService {
value = "Application installation API.(Internal API)",
notes = "This is an internal API used for application installation on a device.")
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Application wil be installed on the device."),
@ApiResponse(code = 500, message = "Error while adding the application install operation.")
@ApiResponse(
code = 200,
message = "OK. \n Install application operations have been successfully scheduled upon given devices"),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be processed does not exist."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while bulk issuing application installation operations upon " +
"a given set of devices.")
})
Response installApplication(
@ApiParam(name = "applicationWrapper", value = "Application details of the application to be installed.",
@ApiParam(
name = "applicationWrapper",
value = "Application details of the application to be installed.",
required = true) ApplicationWrapper applicationWrapper);
@POST
@ -59,14 +76,31 @@ public interface ApplicationManagementAdminService {
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Application uninstallation API.(Internal API)",
value = "Application un-installation API.(Internal API)",
notes = "This is an internal API used for application uninstallation on a device.")
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Application wil be uninstalled on the device."),
@ApiResponse(code = 500, message = "Error while adding the application uninstall operation.")
@ApiResponse(
code = 200,
message = "OK. \n Uninstall application operations have been successfully scheduled upon given devices"),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be processed does not exist."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while bulk issuing application un-installation operations upon " +
"a given set of devices.")
})
Response uninstallApplication(
@ApiParam(name = "applicationWrapper", value = "Application details of the application to be uninstalled.",
@ApiParam(
name = "applicationWrapper",
value = "Application details of the application to be uninstalled.",
required = true) ApplicationWrapper applicationWrapper);
}

@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api.admin;
import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.device.mgt.common.Device;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
@ -36,23 +37,69 @@ public interface DeviceManagementAdminService {
@GET
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get devices by the name.",
notes = "Get devices the name of device and tenant.",
response = org.wso2.carbon.device.mgt.common.Device.class,
value = "Get devices by name.",
notes = "Get devices by name of the device and tenant that they belong to.",
response = Device.class,
responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched device details.",
response = org.wso2.carbon.device.mgt.common.Device.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "No matching device found in the provided tenant."),
@ApiResponse(code = 500, message = "Error while fetching device information.")
@ApiResponse(code = 200, message = "OK. \n Successfully fetched the list of devices.",
response = Device.class,
responseContainer = "List",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the device list.")
})
Response getDevicesByName(
@ApiParam(name = "name", value = "Name of the device.",required = true)
@ApiParam(
name = "name",
value = "Name of the device.",
required = true)
@QueryParam("name") String name,
@ApiParam(name = "tenant-domain", value = "Name of the tenant.",required = true)
@QueryParam("tenant-domain") String tenantDomain);
@ApiParam(
name = "type",
value = "Type of the device.",
required = true)
@QueryParam("type") String type,
@ApiParam(
name = "tenant-domain",
value = "Name of the tenant.",
required = true)
@QueryParam("tenant-domain") String tenantDomain,
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince,
@ApiParam(
name = "offset",
value = "Starting point within the complete list of items qualified.",
required = false)
@QueryParam("offset") int offset,
@ApiParam(
name = "limit",
value = "Maximum size of resource array to return.",
required = false)
@QueryParam("limit") int limit);
}

@ -18,15 +18,14 @@
*/
package org.wso2.carbon.device.mgt.jaxrs.service.api.admin;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.Permission;
import org.wso2.carbon.policy.mgt.common.DeviceGroupWrapper;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Date;
@Path("/groups")
@Produces(MediaType.APPLICATION_JSON)
@ -35,27 +34,60 @@ public interface GroupManagementAdminService {
@GET
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get groups by the name.",
notes = "Get devices the name of device and tenant.",
response = org.wso2.carbon.device.mgt.common.Device.class,
response = DeviceGroupWrapper.class,
responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully fetched group details.",
response = org.wso2.carbon.device.mgt.common.Device.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "Device not found."),
@ApiResponse(code = 500, message = "Error while fetching group information.")
@ApiResponse(code = 200, message = "OK. \n Successfully fetched the list of groups.",
response = DeviceGroupWrapper.class,
responseContainer = "List",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the group list.")
})
@Permission(scope = "group-view", permissions = {"/permission/admin/device-mgt/user/groups/list"})
Response getGroupsOfUser(
@ApiParam(name = "username", value = "Username of the user.",required = true)
@ApiParam(
name = "username",
value = "Username of the user.",
required = true)
@QueryParam("username") String username,
@ApiParam(name = "offset", value = "Starting pagination index.",required = true)
@ApiParam(
name = "If-Modified-Since",
value = "Timestamp of the last modified date",
required = false)
@HeaderParam("If-Modified-Since") Date timestamp,
@ApiParam(
name = "offset",
value = "Starting point within the complete list of items qualified.",
required = false)
@QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "How many policy details are required from the starting pagination " +
"index.", required = true)
@ApiParam(
name = "limit",
value = "Maximum size of resource array to return.",
required = false)
@QueryParam("limit") int limit);

@ -34,25 +34,42 @@ import javax.ws.rs.core.Response;
@Consumes(MediaType.APPLICATION_JSON)
public interface UserManagementAdminService {
@POST
@PUT
@Path("/{username}/credentials")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Changing the user password.",
value = "Change the user password.",
notes = "A user is able to change the password to secure their EMM profile via this REST API.")
@ApiResponses(value = {
@ApiResponse(code = 201, message = "User password was successfully changed."),
@ApiResponse(code = 400, message = "Old password does not match."),
@ApiResponse(code = 500, message = "Could not change the password of the user. The Character encoding is" +
" not supported.")
@ApiResponse(
code = 200,
message = "OK. \n Credentials of the user have been updated successfully"),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while updating credentials of the user.")
})
@Permission(scope = "user-modify", permissions = {"/permission/admin/login"})
Response resetPassword(
@ApiParam(name = "username", value = "Username of the user.",required = true)
@ApiParam(
name = "username",
value = "Username of the user.",
required = true)
@PathParam("username") String username,
@ApiParam(name = "credentials", value = "Credential.",required = true)
UserCredentialWrapper credentials);
@ApiParam(
name = "credentials",
value = "Credential.",
required = true) UserCredentialWrapper credentials);
}

@ -21,12 +21,12 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.jaxrs.service.api.ActivityInfoProviderService;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
@ -37,7 +37,9 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
@Override
@Path("/{id}")
public Response getActivity(@PathParam("id") String id) {
public Response getActivity(
@PathParam("id") String id,
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
Activity operation = null;
DeviceManagementProviderService dmService;
try {

@ -28,7 +28,10 @@ import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import org.wso2.carbon.device.mgt.jaxrs.util.MDMAppConstants;
import org.wso2.carbon.policy.mgt.core.util.PolicyManagerUtil;
import javax.ws.rs.*;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.List;
@ -38,25 +41,9 @@ public class ConfigurationServiceImpl implements ConfigurationManagementService
private static final Log log = LogFactory.getLog(ConfigurationServiceImpl.class);
@POST
@Override
public Response saveConfiguration(PlatformConfiguration config) {
try {
DeviceMgtAPIUtils.getPlatformConfigurationManagementService().saveConfiguration(config,
MDMAppConstants.RegistryConstants.GENERAL_CONFIG_RESOURCE_PATH);
//Schedule the task service
DeviceMgtAPIUtils.scheduleTaskService(DeviceMgtAPIUtils.getNotifierFrequency(config));
return Response.status(Response.Status.OK).entity("Platform configuration successfully saved.").build();
} catch (ConfigurationManagementException e) {
String msg = "Error occurred while saving the platform configuration.";
log.error(msg, e);
return javax.ws.rs.core.Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
@GET
@Override
public Response getConfiguration() {
public Response getConfiguration(@HeaderParam("If-Modified-Since") String ifModifiedSince) {
String msg;
try {
PlatformConfiguration config = DeviceMgtAPIUtils.getPlatformConfigurationManagementService().

@ -37,6 +37,9 @@ import org.wso2.carbon.device.mgt.core.search.mgt.SearchMgtException;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.jaxrs.service.api.DeviceManagementService;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import org.wso2.carbon.policy.mgt.common.Policy;
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
@ -50,7 +53,15 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@GET
@Override
public Response getDevices(@QueryParam("offset") int offset, @QueryParam("limit") int limit) {
public Response getDevices(
@QueryParam("type") String type,
@QueryParam("user") String user,
@QueryParam("roleName") String roleName,
@QueryParam("ownership") String ownership,
@QueryParam("status") String status,
@HeaderParam("If-Modified-Since") Date timestamp,
@QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
try {
DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService();
PaginationRequest request = new PaginationRequest(offset, limit);
@ -68,48 +79,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
}
}
@Override
public Response getDevices(@HeaderParam("If-Modified-Since") Date timestamp,
@QueryParam("offset") int offset, @QueryParam("limit") int limit) {
SearchManagerService searchManagerService;
List<DeviceWrapper> devices;
try {
searchManagerService = DeviceMgtAPIUtils.getSearchManagerService();
devices = searchManagerService.getUpdated(timestamp.getTime());
} catch (SearchMgtException e) {
String msg = "Error occurred while retrieving the updated device information after the given time.";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
return Response.status(Response.Status.OK).entity(devices).build();
}
@GET
@Override
public Response getDevices(@QueryParam("type") String type, @QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
try {
DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService();
PaginationRequest request = new PaginationRequest(offset, limit);
request.setDeviceType(type);
PaginationResult result = dms.getAllDevices(request);
if (result == null || result.getData().size() == 0) {
return Response.status(Response.Status.NOT_FOUND).entity("No device of type '" + type +
"' is currently enrolled with the server").build();
}
return Response.status(Response.Status.OK).entity(result.getData()).build();
} catch (DeviceManagementException e) {
String msg = "Error occurred while fetching the devices of type '" + type + "'";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
@POST
@Override
public Response getDevicesInfo(List<DeviceIdentifier> deviceIds) {
public Response getDevicesInfo(
List<DeviceIdentifier> deviceIds,
@HeaderParam("If-Modified-Since") Date timestamp) {
DeviceInformationManager informationManager;
List<DeviceInfo> deviceInfo;
try {
@ -129,91 +103,10 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@GET
@Override
public Response getDeviceByUsername(@QueryParam("user") String user, @QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
PaginationResult result;
try {
PaginationRequest request = new PaginationRequest(offset, limit);
request.setOwner(user);
result = DeviceMgtAPIUtils.getDeviceManagementService().getDevicesOfUser(request);
if (result == null || result.getData().size() == 0) {
return Response.status(Response.Status.NOT_FOUND).entity("No device has currently been " +
"enrolled by the user '" + user + "'").build();
}
return Response.status(Response.Status.OK).entity(result.getData()).build();
} catch (DeviceManagementException e) {
String msg = "Error occurred while fetching the devices of user '" + user + "'";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
@GET
@Override
public Response getDevicesByRole(@QueryParam("roleName") String roleName, @QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
List<Device> devices;
try {
devices = DeviceMgtAPIUtils.getDeviceManagementService().getAllDevicesOfRole(roleName);
if (devices == null || devices.size() == 0) {
return Response.status(Response.Status.NOT_FOUND).entity("No device has currently been " +
"enrolled under the role '" + roleName + "'").build();
}
return Response.status(Response.Status.OK).entity(devices).build();
} catch (DeviceManagementException e) {
String msg = "Error occurred while fetching the devices of the role '" + roleName + "'";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
@GET
@Override
public Response getDevicesByOwnership(@QueryParam("ownership") EnrolmentInfo.OwnerShip ownership,
@QueryParam("offset") int offset, @QueryParam("limit") int limit) {
PaginationResult result;
try {
PaginationRequest request = new PaginationRequest(offset, limit);
request.setOwnership(ownership.toString());
result = DeviceMgtAPIUtils.getDeviceManagementService().getDevicesByOwnership(request);
if (result == null || result.getData().size() == 0) {
return Response.status(Response.Status.NOT_FOUND).entity("No device has currently been enrolled " +
"under the ownership scheme '" + ownership.toString() + "'").build();
}
return Response.status(Response.Status.OK).entity(result.getData()).build();
} catch (DeviceManagementException e) {
String msg = "Error occurred while fetching the devices enrolled under the ownership scheme '" +
ownership.toString() + "'";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
@GET
@Override
public Response getDevicesByEnrollmentStatus(@QueryParam("status") EnrolmentInfo.Status status,
@QueryParam("offset") int offset, @QueryParam("limit") int limit) {
PaginationResult result;
try {
PaginationRequest request = new PaginationRequest(offset, limit);
request.setStatus(status.toString());
result = DeviceMgtAPIUtils.getDeviceManagementService().getDevicesByOwnership(request);
if (result == null || result.getData().size() == 0) {
return Response.status(Response.Status.NOT_FOUND).entity("No device is currently in enrollment " +
"status '" + status.toString() + "'").build();
}
return Response.status(Response.Status.OK).entity(result.getData()).build();
} catch (DeviceManagementException e) {
String msg = "Error occurred while fetching the devices that carry the enrollment status '" +
status.toString() + "'";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
@GET
@Override
public Response getDevice(@QueryParam("type") String type, @QueryParam("id") String id) {
public Response getDevice(
@PathParam("type") String type,
@PathParam("id") String id,
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
Device device;
try {
DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService();
@ -233,7 +126,10 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@GET
@Path("/{type}/{id}/location")
@Override
public Response getDeviceLocation(@PathParam("type") String type, @PathParam("id") String id) {
public Response getDeviceLocation(
@PathParam("type") String type,
@PathParam("id") String id,
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
DeviceInformationManager informationManager;
DeviceLocation deviceLocation;
try {
@ -256,7 +152,10 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@GET
@Path("/{type}/{id}/features")
@Override
public Response getFeaturesOfDevice(@PathParam("type") String type, @PathParam("id") String id) {
public Response getFeaturesOfDevice(
@PathParam("type") String type,
@PathParam("id") String id,
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
List<Feature> features;
DeviceManagementProviderService dms;
try {
@ -278,7 +177,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@POST
@Path("/search-devices")
@Override
public Response searchDevices(SearchContext searchContext) {
public Response searchDevices(SearchContext searchContext, @QueryParam("offset") int offset, int limit) {
SearchManagerService searchManagerService;
List<DeviceWrapper> devices;
try {
@ -299,7 +198,12 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@GET
@Path("/{type}/{id}/applications")
@Override
public Response getInstalledApplications(@PathParam("type") String type, @PathParam("id") String id) {
public Response getInstalledApplications(
@PathParam("type") String type,
@PathParam("id") String id,
@HeaderParam("If-Modified-Since") String ifModifiedSince,
@QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
List<Application> applications;
ApplicationManagementProviderService amc;
try {
@ -321,8 +225,12 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@GET
@Path("/{type}/{id}/operations")
@Override
public Response getDeviceOperations(@QueryParam("offset") int offset, @QueryParam("limit") int limit,
@PathParam("type") String type, @PathParam("id") String id) {
public Response getDeviceOperations(
@PathParam("type") String type,
@PathParam("id") String id,
@HeaderParam("If-Modified-Since") String ifModifiedSince,
@QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
List<? extends Operation> operations;
DeviceManagementProviderService dms;
try {
@ -337,4 +245,24 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
return Response.status(Response.Status.OK).entity(operations).build();
}
@Override
public Response getEffectivePolicyOfDevice(@QueryParam("type") String type,
@QueryParam("id") String id,
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
try {
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
Policy policy = policyManagementService.getAppliedPolicyToDevice(new DeviceIdentifier(id, type));
if (policy == null) {
return Response.status(Response.Status.NOT_FOUND).entity("No policy has been found for the '" +
type + "' device, which carries the id '" + id + "'").build();
}
return Response.status(Response.Status.OK).entity(policy).build();
} catch (PolicyManagementException e) {
String msg = "Error occurred while retrieving the current policy associated with the '" + type +
"' device, which carries the id '" + id + "'";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
}

@ -39,7 +39,10 @@ public class NotificationManagementServiceImpl implements NotificationManagement
@GET
@Override
public Response getNotifications(@QueryParam("offset") int offset, @QueryParam("limit") int limit) {
public Response getNotifications(
@QueryParam("status") String status,
@HeaderParam("If-Modified-Since") String ifModifiedSince,
@QueryParam("offset") int offset, @QueryParam("limit") int limit) {
String msg;
try {
List<Notification> notifications =
@ -56,33 +59,13 @@ public class NotificationManagementServiceImpl implements NotificationManagement
}
}
@GET
@Override
public Response getNotificationsByStatus(@QueryParam("status") Notification.Status status,
@QueryParam("offset") int offset, @QueryParam("limit") int limit) {
String msg;
try {
List<Notification> notifications =
DeviceMgtAPIUtils.getNotificationManagementService().getNotificationsByStatus(status);
if (notifications == null || notifications.size() == 0) {
return Response.status(Response.Status.NOT_FOUND).entity("No notification, which carries " +
"the status '" + status.toString() + "' is available to be retrieved").build();
}
return Response.status(Response.Status.OK).entity(notifications).build();
} catch (NotificationManagementException e) {
msg = "Error occurred while retrieving the notification list that carries the status '" +
status.toString() + "'";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
@PUT
@Path("/{id}/status")
@Override
public Response updateNotificationStatus(@PathParam("id") int id, Notification.Status status) {
public Response updateNotificationStatus(@PathParam("id") int id, String status) {
try {
DeviceMgtAPIUtils.getNotificationManagementService().updateNotificationStatus(id, status);
DeviceMgtAPIUtils.getNotificationManagementService().updateNotificationStatus(id,
Notification.Status.valueOf(status));
return Response.status(Response.Status.OK).entity("Notification status has successfully been updated").build();
} catch (NotificationManagementException e) {
String msg = "Error occurred while updating notification status";

@ -26,9 +26,9 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper;
import org.wso2.carbon.device.mgt.jaxrs.service.api.PolicyManagementService;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtUtil;
import org.wso2.carbon.policy.mgt.common.Policy;
import org.wso2.carbon.policy.mgt.common.PolicyAdministratorPoint;
@ -96,7 +96,10 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
@GET
@Override
public Response getPolicies(@QueryParam("offset") int offset, @QueryParam("limit") int limit) {
public Response getPolicies(
@HeaderParam("If-Modified-Since") String ifModifiedSince,
@QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
List<Policy> policies;
try {
@ -116,7 +119,7 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
@GET
@Path("/{id}")
@Override
public Response getPolicy(@PathParam("id") int id) {
public Response getPolicy(@PathParam("id") int id, @HeaderParam("If-Modified-Since") String ifModifiedSince) {
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
final org.wso2.carbon.policy.mgt.common.Policy policy;
try {
@ -130,9 +133,6 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
if (policy == null) {
return Response.status(Response.Status.NOT_FOUND).entity("Policy for ID " + id + " not found").build();
}
return Response.status(Response.Status.OK).entity(policy).build();
}
@ -186,7 +186,7 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
try {
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
PolicyAdministratorPoint pap = policyManagementService.getPAP();
for(int i : policyIds) {
for (int i : policyIds) {
pap.activatePolicy(i);
}
} catch (PolicyManagementException e) {
@ -204,7 +204,7 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
try {
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
PolicyAdministratorPoint pap = policyManagementService.getPAP();
for(int i : policyIds) {
for (int i : policyIds) {
pap.inactivatePolicy(i);
}
} catch (PolicyManagementException e) {
@ -216,24 +216,4 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
"deactivated").build();
}
@GET
@Override
public Response getEffectivePolicyOfDevice(@QueryParam("device-type") String type,
@QueryParam("device-id") String deviceId) {
try {
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
Policy policy = policyManagementService.getAppliedPolicyToDevice(new DeviceIdentifier(deviceId, type));
if (policy == null) {
return Response.status(Response.Status.NOT_FOUND).entity("No policy has been found for the '" +
type + "' device, which carries the id '" + deviceId + "'").build();
}
return Response.status(Response.Status.OK).entity(policy).build();
} catch (PolicyManagementException e) {
String msg = "Error occurred while retrieving the current policy associated with the '" + type +
"' device, which carries the id '" + deviceId + "'";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
}

@ -44,7 +44,11 @@ public class RoleManagementServiceImpl implements RoleManagementService {
@GET
@Override
public Response getRoles(@QueryParam("offset") int offset, @QueryParam("limit") int limit) {
public Response getRoles(
@QueryParam("filter") String filter,
@QueryParam("user-store") String userStoreName,
@HeaderParam("If-Modified-Since") String ifModifiedSince,
@QueryParam("offset") int offset, @QueryParam("limit") int limit) {
List<String> filteredRoles;
try {
filteredRoles = getRolesFromUserStore();
@ -59,73 +63,12 @@ public class RoleManagementServiceImpl implements RoleManagementService {
return Response.status(Response.Status.OK).entity(filteredRoles).build();
}
@GET
@Override
public Response getRoles(@QueryParam("user-store") String userStoreName, @QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
String[] roles;
try {
AbstractUserStoreManager abstractUserStoreManager =
(AbstractUserStoreManager) DeviceMgtAPIUtils.getUserStoreManager();
if (log.isDebugEnabled()) {
log.debug("Getting the list of user roles");
}
roles = abstractUserStoreManager.getRoleNames(userStoreName + "/*", -1, false, true, true);
} catch (UserStoreException e) {
String msg = "Error occurred while retrieving the list of user roles from the underlying user-store '" +
userStoreName + "'";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
// removing all internal roles and roles created for Service-providers
List<String> filteredRoles = new ArrayList<>();
for (String role : roles) {
if (!(role.startsWith("Internal/") || role.startsWith("Authentication/"))) {
filteredRoles.add(role);
}
}
if (filteredRoles == null || filteredRoles.size() == 0) {
return Response.status(Response.Status.NOT_FOUND).entity("No roles found.").build();
}
return Response.status(Response.Status.OK).entity(filteredRoles).build();
}
@GET
@Override
public Response searchRoles(@QueryParam("filter") String filter, @QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
String[] roles;
try {
AbstractUserStoreManager abstractUserStoreManager =
(AbstractUserStoreManager) DeviceMgtAPIUtils.getUserStoreManager();
if (log.isDebugEnabled()) {
log.debug("Getting the list of user roles using filter : " + filter);
}
roles = abstractUserStoreManager.getRoleNames("*" + filter + "*", -1, true, true, true);
} catch (UserStoreException e) {
String msg = "Error occurred while retrieving the list of user roles using the filter '" + filter + "'";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
// removing all internal roles and roles created for Service-providers
List<String> filteredRoles = new ArrayList<>();
for (String role : roles) {
if (!(role.startsWith("Internal/") || role.startsWith("Authentication/"))) {
filteredRoles.add(role);
}
}
if (filteredRoles == null || filteredRoles.size() == 0) {
return Response.status(Response.Status.NOT_FOUND).entity("No roles found.").build();
}
return Response.status(Response.Status.OK).entity(filteredRoles).build();
}
@GET
@Path("/{roleName}/permissions")
@Override
public Response getPermissionsOfRole(@PathParam("roleName") String roleName) {
public Response getPermissionsOfRole(
@PathParam("roleName") String roleName,
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
try {
final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm();
org.wso2.carbon.user.core.UserRealm userRealmCore = null;
@ -176,7 +119,8 @@ public class RoleManagementServiceImpl implements RoleManagementService {
@GET
@Path("/{roleName}")
@Override
public Response getRole(@PathParam("roleName") String roleName) {
public Response getRole(@PathParam("roleName") String roleName,
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
RoleWrapper roleWrapper = new RoleWrapper();
try {
final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
@ -201,10 +145,6 @@ public class RoleManagementServiceImpl implements RoleManagementService {
String[] permListAr = new String[permList.size()];
roleWrapper.setPermissions(permList.toArray(permListAr));
}
if (roleWrapper == null) {
return Response.status(Response.Status.NOT_FOUND).entity("No roles found for the role name '"
+ roleName + ".").build();
}
} catch (UserStoreException | UserAdminException e) {
String msg = "Error occurred while retrieving the user role '" + roleName + "'";
log.error(msg, e);

@ -19,7 +19,6 @@
package org.wso2.carbon.device.mgt.jaxrs.service.impl;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -27,13 +26,12 @@ import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.EmailMetaInfo;
import org.wso2.carbon.device.mgt.jaxrs.service.api.UserManagementService;
import org.wso2.carbon.device.mgt.jaxrs.util.CredentialManagementResponseBuilder;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import org.wso2.carbon.device.mgt.jaxrs.util.ResponsePayload;
import org.wso2.carbon.device.mgt.jaxrs.beans.UserCredentialWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.UserWrapper;
import org.wso2.carbon.device.mgt.jaxrs.service.api.UserManagementService;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import org.wso2.carbon.device.mgt.jaxrs.util.CredentialManagementResponseBuilder;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.api.UserStoreManager;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
@ -162,7 +160,8 @@ public class UserManagementServiceImpl implements UserManagementService {
@GET
@Path("/{username}")
@Override
public Response getUser(@PathParam("username") String username) {
public Response getUser(@PathParam("username") String username,
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
try {
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
if (userStoreManager.isExistingUser(username)) {
@ -175,10 +174,6 @@ public class UserManagementServiceImpl implements UserManagementService {
if (log.isDebugEnabled()) {
log.debug("User by username: " + username + " was found.");
}
if (user == null) {
return Response.status(Response.Status.NOT_FOUND).entity("User by username '" + username + "' " +
"doesn't exist").build();
}
return Response.status(Response.Status.OK).entity(user).build();
} else {
// Outputting debug message upon trying to remove non-existing user
@ -328,7 +323,8 @@ public class UserManagementServiceImpl implements UserManagementService {
@GET
@Override
public Response getUsers(@QueryParam("filter") String filter, @QueryParam("offset") int offset,
public Response getUsers(@QueryParam("filter") String filter, @HeaderParam("If-Modified-Since") Date timestamp,
@QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
if (log.isDebugEnabled()) {
log.debug("Getting the list of users with all user-related information");
@ -359,9 +355,10 @@ public class UserManagementServiceImpl implements UserManagementService {
}
@GET
@Path("/usernames")
@Override
public Response getUserNames(@QueryParam("filter") String filter, @QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
public Response getUserNames(@QueryParam("filter") String filter, @HeaderParam("If-Modified-Since") Date timestamp,
@QueryParam("offset") int offset, @QueryParam("limit") int limit) {
if (log.isDebugEnabled()) {
log.debug("Getting the list of users with all user-related information using the filter : " + filter);
}

@ -39,7 +39,12 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
@Override
@GET
public Response getDevicesByName(@QueryParam("name") String name, @QueryParam("tenant-domain") String tenantDomain) {
public Response getDevicesByName(@QueryParam("name") String name,
@QueryParam("type") String type,
@QueryParam("tenant-domain") String tenantDomain,
@HeaderParam("If-Modified-Since") String ifModifiedSince,
@QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
List<Device> devices;
try {
devices = DeviceMgtAPIUtils.getDeviceManagementService().getDevicesByName(name);

@ -18,6 +18,7 @@
*/
package org.wso2.carbon.device.mgt.jaxrs.service.impl.admin;
import io.swagger.annotations.ApiParam;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.PaginationResult;
@ -25,12 +26,10 @@ import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException;
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.GroupManagementAdminService;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import javax.ws.rs.Consumes;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Date;
@Path("/groups")
@Produces(MediaType.APPLICATION_JSON)
@ -40,8 +39,11 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ
private static final Log log = LogFactory.getLog(GroupManagementAdminServiceImpl.class);
@Override
public Response getGroupsOfUser(@QueryParam("username") String username, @QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
public Response getGroupsOfUser(
@QueryParam("username") String username,
@HeaderParam("If-Modified-Since") Date timestamp,
@QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
try {
PaginationResult result =
DeviceMgtAPIUtils.getGroupManagementProviderService().getGroups(username, offset, limit);

@ -18,9 +18,9 @@
*/
package org.wso2.carbon.device.mgt.jaxrs.service.impl.admin;
import org.wso2.carbon.device.mgt.jaxrs.beans.UserCredentialWrapper;
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.UserManagementAdminService;
import org.wso2.carbon.device.mgt.jaxrs.util.CredentialManagementResponseBuilder;
import org.wso2.carbon.device.mgt.jaxrs.beans.UserCredentialWrapper;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

@ -29,79 +29,79 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
@ApiModel(value = "Notification", description = "This is used to communicate Operation notifications to MDM.")
public class Notification {
public enum Status{
NEW, CHECKED
}
public enum Status {
NEW, CHECKED
}
public enum Type{
ALERT,
}
public enum Type {
ALERT,
}
@ApiModelProperty(name = "notificationId", value = "Defines the notification ID.", required = true )
private int notificationId;
@ApiModelProperty(name = "notificationId", value = "Defines the notification ID.", required = true)
private int notificationId;
@ApiModelProperty(name = "deviceIdentifier", value = "Defines the device identification properties.",
required = true )
private DeviceIdentifier deviceIdentifier;
required = true)
private DeviceIdentifier deviceIdentifier;
@ApiModelProperty(name = "description", value = "Provides the message you want to send to the user.",
required = true )
private String description;
@ApiModelProperty(name = "operationId", value = "Provides the operationID.", required = true )
private int operationId;
required = true)
private String description;
@ApiModelProperty(name = "operationId", value = "Provides the operationID.", required = true)
private int operationId;
@ApiModelProperty(name = "status", value = "Provides the status of the message." +
"The following values can be assigned for the status.\n" +
"NEW: The message is in the unread state.\n" +
"CHECKED: The message is in the read state.", required = true )
private Status status;
public Status getStatus() {
return status;
}
public void setStatus(String status) {
this.status = Status.valueOf(status);
}
public int getNotificationId() {
return notificationId;
}
public void setNotificationId(int notificationId) {
this.notificationId = notificationId;
}
public DeviceIdentifier getDeviceIdentifier() {
return deviceIdentifier;
}
public void setDeviceIdentifier(DeviceIdentifier deviceIdentifier) {
this.deviceIdentifier = deviceIdentifier;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getOperationId() {
return operationId;
}
public void setOperationId(int operationId) {
this.operationId = operationId;
}
@Override
public String toString() {
return "Notification{" +
"notificationId='" + notificationId + '\'' +
", deviceId=" + deviceIdentifier.getId() +
", deviceType=" + deviceIdentifier.getType() +
", status=" + status +
", description='" + description + '\'' +
", operationId='" + operationId + '\'' +
'}';
}
"The following values can be assigned for the status.\n" +
"NEW: The message is in the unread state.\n" +
"CHECKED: The message is in the read state.", required = true)
private Status status;
public Status getStatus() {
return status;
}
public void setStatus(String status) {
this.status = Status.valueOf(status);
}
public int getNotificationId() {
return notificationId;
}
public void setNotificationId(int notificationId) {
this.notificationId = notificationId;
}
public DeviceIdentifier getDeviceIdentifier() {
return deviceIdentifier;
}
public void setDeviceIdentifier(DeviceIdentifier deviceIdentifier) {
this.deviceIdentifier = deviceIdentifier;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getOperationId() {
return operationId;
}
public void setOperationId(int operationId) {
this.operationId = operationId;
}
@Override
public String toString() {
return "Notification{" +
"notificationId='" + notificationId + '\'' +
", deviceId=" + deviceIdentifier.getId() +
", deviceType=" + deviceIdentifier.getType() +
", status=" + status +
", description='" + description + '\'' +
", operationId='" + operationId + '\'' +
'}';
}
}

Loading…
Cancel
Save