下面列出了怎么用io.swagger.annotations.ResponseHeader的API类实例代码及写法,或者点击链接到github查看源代码。
@POST
@Path("upgrade")
@ApiOperation("Triggers a migration of Cassandra schema to a specific version")
@ApiImplicitParams({
@ApiImplicitParam(
required = true,
paramType = "body",
dataType = "Integer",
example = "3",
value = "The schema version to upgrade to.")
})
@ApiResponses({
@ApiResponse(code = HttpStatus.CREATED_201, message = "The taskId of the given scheduled task", response = TaskIdDto.class,
responseHeaders = {
@ResponseHeader(name = "Location", description = "URL of the resource associated with the scheduled task")
}),
@ApiResponse(code = HttpStatus.CONFLICT_409, message = "Migration can not be done")
})
public Task upgradeToVersion(Request request) {
LOGGER.debug("Cassandra upgrade launched");
CassandraVersionRequest cassandraVersionRequest = CassandraVersionRequest.parse(request.body());
return cassandraMigrationService.upgradeToVersion(cassandraVersionRequest.getValue());
}
private static Map<String, Property> parseResponseHeaders(ReaderContext context,
ResponseHeader[] headers) {
Map<String, Property> responseHeaders = null;
for (ResponseHeader header : headers) {
final String name = header.name();
if (StringUtils.isNotEmpty(name)) {
if (responseHeaders == null) {
responseHeaders = new HashMap<String, Property>();
}
final Class<?> cls = header.response();
if (!ReflectionUtils.isVoid(cls)) {
final Property property = ModelConverters.getInstance().readAsProperty(cls);
if (property != null) {
final Property responseProperty = ContainerWrapper.wrapContainer(
header.responseContainer(), property, ContainerWrapper.ARRAY,
ContainerWrapper.LIST, ContainerWrapper.SET);
responseProperty.setDescription(header.description());
responseHeaders.put(name, responseProperty);
appendModels(context.getSwagger(), cls);
}
}
}
}
return responseHeaders;
}
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Returns a list of all license groups",
response = LicenseGroup.class,
responseContainer = "List",
responseHeaders = @ResponseHeader(name = TOTAL_COUNT_HEADER, response = Long.class, description = "The total number of license groups")
)
@ApiResponses(value = {
@ApiResponse(code = 401, message = "Unauthorized")
})
@PermissionRequired(Permissions.Constants.POLICY_MANAGEMENT)
public Response getLicenseGroups() {
try (QueryManager qm = new QueryManager(getAlpineRequest())) {
final PaginatedResult result = qm.getLicenseGroups();
return Response.ok(result.getObjects()).header(TOTAL_COUNT_HEADER, result.getTotal()).build();
}
}
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Returns a list of all repositories",
response = Repository.class,
responseContainer = "List",
responseHeaders = @ResponseHeader(name = TOTAL_COUNT_HEADER, response = Long.class, description = "The total number of repositories")
)
@ApiResponses(value = {
@ApiResponse(code = 401, message = "Unauthorized")
})
@PermissionRequired(Permissions.Constants.SYSTEM_CONFIGURATION)
public Response getRepositories() {
try (QueryManager qm = new QueryManager(getAlpineRequest())) {
final PaginatedResult result = qm.getRepositories();
return Response.ok(result.getObjects()).header(TOTAL_COUNT_HEADER, result.getTotal()).build();
}
}
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Returns a list of all policies",
response = Policy.class,
responseContainer = "List",
responseHeaders = @ResponseHeader(name = TOTAL_COUNT_HEADER, response = Long.class, description = "The total number of policies")
)
@ApiResponses(value = {
@ApiResponse(code = 401, message = "Unauthorized")
})
@PermissionRequired(Permissions.Constants.POLICY_MANAGEMENT)
public Response getPolicies() {
try (QueryManager qm = new QueryManager(getAlpineRequest())) {
final PaginatedResult result = qm.getPolicies();
return Response.ok(result.getObjects()).header(TOTAL_COUNT_HEADER, result.getTotal()).build();
}
}
@POST
@Path("upgrade/latest")
@ApiOperation("Triggers a migration of Cassandra schema to the latest available")
@ApiResponses({
@ApiResponse(code = HttpStatus.CREATED_201, message = "The taskId of the given scheduled task", response = TaskIdDto.class,
responseHeaders = {
@ResponseHeader(name = "Location", description = "URL of the resource associated with the scheduled task")
}),
@ApiResponse(code = HttpStatus.CONFLICT_409, message = "Migration can not be done")
})
public Task upgradeToLatest() {
try {
return cassandraMigrationService.upgradeToLastVersion();
} catch (IllegalStateException e) {
LOGGER.info(MIGRATION_REQUEST_CAN_NOT_BE_DONE, e);
throw ErrorResponder.builder()
.statusCode(HttpStatus.CONFLICT_409)
.type(ErrorType.WRONG_STATE)
.message(MIGRATION_REQUEST_CAN_NOT_BE_DONE)
.cause(e)
.haltError();
}
}
@ApiOperation(
value = "Download a file",
notes = "Downloads the content of the file",
responseHeaders = {@ResponseHeader(name = "Content-Disposition")}
)
@GET
@Path("/{filePath}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public javax.ws.rs.core.Response downloadFile(@PathParam("filePath") @ApiParam("A path to a file") String filePath) throws Exception {
File file = new File(filePath + "/" + URLDecoder.decode(filePath, "UTF8"));
if (!file.exists()) {
return javax.ws.rs.core.Response.status(404).build();
} else {
ContentDisposition contentDisposition = ContentDisposition.type("attachment").fileName(file.getName()).creationDate(new Date()).build();
return javax.ws.rs.core.Response.ok( ( StreamingOutput ) output -> {
try {
InputStream input = new FileInputStream( file );
IOUtils.copy(input, output);
output.flush();
} catch ( Exception e ) { e.printStackTrace(); }
} ).header( "Content-Disposition", contentDisposition ).build();
}
}
@POST
@Path("/{id}/entries")
@ApiOperation(value = "Creates a new entry for a shopping list.")
@ApiResponses(value = {
@ApiResponse(code = HTTP_CREATED, message = HTTP_CREATED_MESSAGE, response = ShoppingList.class,
responseHeaders = @ResponseHeader(name = "Location", description = "Location of the newly created entry.", response = String.class)),
@ApiResponse(code = HTTP_BAD_REQUEST, message = HTTP_BAD_REQUEST_MESSAGE, response = ErrorResponse.class),
@ApiResponse(code = HTTP_UNAUTHORIZED, message = HTTP_UNAUTHORIZED_MESSAGE, response = ErrorResponse.class),
@ApiResponse(code = HTTP_NOT_FOUND, message = HTTP_NOT_FOUND_MESSAGE, response = ErrorResponse.class)
})
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
ShoppingListEntry postShoppingListEntry(
@ApiParam(value = "The id of the shopping list.", required = true)
@PathParam("id")
String id,
@ApiParam(value = "The quantity for the new entry.", required = true)
@FormParam("quantity")
@Min(value = 0)
int quantity,
@ApiParam(value = "The product variant id to be added to the entry. If the product variant exists in the shopping list, its quantity is increased with the provided quantity.", required = true)
@FormParam("productVariantId")
String productVariantId,
@ApiParam(value = ACCEPT_LANGUAGE_DESC)
@HeaderParam(ACCEPT_LANGUAGE) String acceptLanguage
);
private Map<String, Property> parseResponseHeaders(ResponseHeader[] headers, JsonView jsonView) {
Map<String, Property> responseHeaders = null;
if (headers != null) {
for (ResponseHeader header : headers) {
String name = header.name();
if (!"".equals(name)) {
if (responseHeaders == null) {
responseHeaders = new LinkedHashMap<String, Property>();
}
String description = header.description();
Class<?> cls = header.response();
if (!isVoid(cls)) {
final Property property = ModelConverters.getInstance().readAsProperty(cls, jsonView);
if (property != null) {
Property responseProperty = ContainerWrapper.wrapContainer(header.responseContainer(),
property, ContainerWrapper.ARRAY, ContainerWrapper.LIST, ContainerWrapper.SET);
responseProperty.setDescription(description);
responseHeaders.put(name, responseProperty);
appendModels(cls);
}
}
}
}
}
return responseHeaders;
}
@ApiResponse(code = 200, response = User.class, message = "")
@ResponseHeaders({@ResponseHeader(name = "h1", response = String.class),
@ResponseHeader(name = "h2", response = String.class)})
@GetMapping(path = "/cseResponse")
@Override
public Response cseResponse(InvocationContext c1) {
return super.cseResponse(c1);
}
@ResponseHeaders({@ResponseHeader(name = "h1", response = String.class),
@ResponseHeader(name = "h2", response = String.class)})
@RequestMapping(path = "/responseEntity", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
@Override
public ResponseEntity<Date> responseEntity(InvocationContext c1, @RequestAttribute("date") Date date) {
return super.responseEntity(c1, date);
}
@ApiResponse(code = 200, response = User.class, message = "")
@ResponseHeaders({@ResponseHeader(name = "h1", response = String.class),
@ResponseHeader(name = "h2", response = String.class)})
@RequestMapping(path = "/cseResponse", method = RequestMethod.GET)
@Override
public Response cseResponse(InvocationContext c1) {
return super.cseResponse(c1);
}
@Override
public void process(SwaggerGenerator swaggerGenerator, OperationGenerator operationGenerator,
ResponseHeaders responseHeaders) {
MethodAnnotationProcessor<ResponseHeader> processor = findMethodAnnotationProcessor(ResponseHeader.class);
for (ResponseHeader responseHeader : responseHeaders.value()) {
processor.process(swaggerGenerator, operationGenerator, responseHeader);
}
}
public void setResponseHeaders(ResponseHeader[] responseHeaders) {
this.responseHeaders = new ArrayList<>();
for (ResponseHeader header : responseHeaders) {
ResponseHeaderConfig config = AnnotationUtils.convert(header);
if (config != null) {
this.responseHeaders.add(config);
}
}
if (this.responseHeaders.isEmpty()) {
this.responseHeaders = null;
}
}
@Override
public void process(SwaggerGenerator swaggerGenerator, OperationGenerator operationGenerator,
ResponseHeader responseHeader) {
ResponseHeaderConfig config = AnnotationUtils.convert(responseHeader);
if (config != null) {
Property property =
AnnotationUtils.generateResponseHeaderProperty(swaggerGenerator.getSwagger(), config);
operationGenerator.addMethodResponseHeader(config.getName(), property);
}
}
@ApiOperation(
value = "summary",
notes = "notes",
tags = {"tag1", "tag2"},
httpMethod = "GET",
nickname = "test",
produces = "application/json",
consumes = "application/json",
protocols = "http,https",
code = 202,
responseHeaders = {@ResponseHeader(name = "h1", response = int.class)},
extensions = {@Extension(
name = "x-tagA",
properties = {@ExtensionProperty(name = "x-tagAExt", value = "value of tagAExt")})})
void testBase();
@POST
@Path("files")
@Produces ( "application/json" )
@ApiOperation(
code = 201,
value = "Save new content while creating its discussion board",
notes = "Both operations (new content and forum) must succeed within a given time interval, otherwise both will be canceled or rolled back. "
+ "The newly created resource(s) can be referenced by the URI(s) returned in the entity of the response, with the URI for the "
+ "distributed transaction given by the Location header field",
response = String.class,
responseContainer = "List",
responseHeaders = {
@ResponseHeader(name = "Location", description = "The distributed transaction URI", response = String.class)
}
)
@ApiResponses(value = {
@ApiResponse(code=500, message="Error processing request", response = ErrorDetails.class)
})
public Response save(@Context UriInfo uriInfo,
@ApiParam(value = "Data to pass to server", required = true) CompositeData data
) throws CompositeTransactionException {
Entry<String, List<String>> txEntities = service.saveAllEntities(data);
URI location = uriInfo.getAbsolutePathBuilder().path("{id}")
.resolveTemplate("id", txEntities.getKey()).build();
return Response.created(location).entity(txEntities.getValue()).build();
}
@POST
@Path("{botId}")
@ApiResponse(code = 200, responseHeaders = {
@ResponseHeader(name = "location", response = URI.class)
}, message = "returns location of the exported ZIP file to be downloaded")
Response exportBot(@PathParam("botId") String botId,
@ApiParam(name = "botVersion", required = true, format = "integer", example = "1")
@QueryParam("botVersion") @DefaultValue("1") Integer botVersion);
@GET
@Path("/checkUser")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting the User existence status",
notes = "Check if the user exists in the user store.",
tags = "User Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:users:is-exist")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched user exist status.",
response = BasicUserInfoList.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body")
}),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported",
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the " +
"total user exist status.",
response = ErrorResponse.class)
})
Response isUserExists(@ApiParam(
name = "username",
value = "The username of the user.",
required = true)
@QueryParam("username") String userName);
private Map<String, Property> parseResponseHeaders(ResponseHeader[] headers) {
Map<String, Property> responseHeaders = null;
if (headers != null && headers.length > 0) {
for (ResponseHeader header : headers) {
String name = header.name();
if (!"".equals(name)) {
if (responseHeaders == null) {
responseHeaders = new HashMap<>();
}
String description = header.description();
Class<?> cls = header.response();
if (!isVoid(cls)) {
final Property property = ModelConverters.getInstance().readAsProperty(cls);
if (property != null) {
Property responseProperty = ContainerWrapper
.wrapContainer(header.responseContainer(), property, ContainerWrapper.ARRAY,
ContainerWrapper.LIST, ContainerWrapper.SET);
responseProperty.setDescription(description);
responseHeaders.put(name, responseProperty);
appendModels(cls);
}
}
}
}
}
return responseHeaders;
}
@Path("/id/{groupId}/devices/remove")
@POST
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = HTTPConstants.HEADER_DELETE,
value = "Removing Devices from a Group",
notes = "Remove a device from a group using this API.",
tags = "Device Group Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:devices-remove")
})
}
)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK. \n Successfully removed devices from the group.",
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 = "No groups found.",
response = ErrorResponse.class),
@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 removing devices from the group.",
response = ErrorResponse.class)
})
Response removeDevicesFromGroup(@ApiParam(
name = "groupId",
value = "ID of the group.",
required = true)
@PathParam("groupId") int groupId,
@ApiParam(
name = "deviceIdentifiers",
value = "The device identifiers of the devices that needed to be removed."+
" You can define many device IDs as comma separated values.",
required = true)
@Valid List<DeviceIdentifier> deviceIdentifiers);
@PUT
@Path("/{username}")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "PUT",
value = "Updating 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.",
tags = "User Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:users:update")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully updated the details of the specified user.",
responseHeaders = {
@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 was last modified.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
response = ErrorResponse.class),
@ApiResponse(
code = 404,
message = "Not Found. \n The specified resource does not exist.",
response = ErrorResponse.class),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The format of the requested entity was not supported.",
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while updating the user.",
response = ErrorResponse.class)
})
Response updateUser(
@ApiParam(
name = "username",
value = "The username of the user.",
required = true,
defaultValue = "admin")
@PathParam("username") String username,
@ApiParam(
name = "domain",
value = "The domain name of the user store.",
required = false)
@QueryParam("domain") String domain,
@ApiParam(
name = "userData",
value = "Update the user details.\n" +
"NOTE: Do not change the admin username, password and roles when trying out this API.",
required = true) UserInfo userData);
@GET
@Path("/{id}")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting the Details of a Specific Activity",
notes = "Retrieve the details of a specific activity/operation, such as the meta information of an " +
"operation, and the responses from the devices.",
tags = "Activity Info Provider",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:get-activity")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the activity details.",
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 was last modified.\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.",
response = ErrorResponse.class),
@ApiResponse(
code = 401,
message = "Unauthorized. \n Unauthorized request."),
@ApiResponse(
code = 404,
message = "Not Found. \n No activity found with the given ID.",
response = ErrorResponse.class),
@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 activity data.",
response = ErrorResponse.class)
})
Response getActivity(
@ApiParam(
name = "id",
value = "Activity ID of the operation/activity.",
required = true,
defaultValue = "ACTIVITY_1")
@PathParam("id")
@Size(max = 45)
String id,
@ApiParam(
name = "If-Modified-Since",
value = "Checks if the requested variant was modified, since the specified date-time\n." +
"Provide the value in the Java Date Format: EEE, d MMM yyyy HH:mm:ss Z\n." +
"Example: Mon, 05 Jan 2014 15:10:00 +0200",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince);
@PUT
@Path("/operations/{type}/{id}")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
consumes = MediaType.APPLICATION_JSON,
httpMethod = "PUT",
value = "Update Operation",
notes = "Update the Operations.",
tags = "Device Agent Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device:operations")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully updated the operations.",
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. 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.",
response = ErrorResponse.class),
@ApiResponse(
code = 404,
message = "Not Found. \n No device is found under the provided type and id.",
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while retrieving information requested device.",
response = ErrorResponse.class)
})
Response updateOperation(@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 id.", required = true)
@PathParam("id") String deviceId,
@ApiParam(name = "operation", value = "Operation object with data.", required = true)
@Valid Operation operation);
@POST
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Add a Device Type",
notes = "Add the details of a device type.",
tags = "Device Type Management Administrative Service",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:admin:device-type")
})
}
)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK. \n Successfully added the device type.",
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body")
}),
@ApiResponse(
code = 304,
message = "Not Modified. Empty body because the client already has the latest version of the " +
"requested resource.\n"),
@ApiResponse(
code = 401,
message = "Unauthorized.\n The unauthorized access to the requested resource.",
response = ErrorResponse.class),
@ApiResponse(
code = 404,
message = "Not Found.\n The specified device does not exist",
response = ErrorResponse.class),
@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 = ErrorResponse.class)
})
Response addDeviceType(@ApiParam(
name = "type",
value = "The device type such as ios, android, windows or fire-alarm.",
required = true)DeviceType deviceType);
@GET
@Path("/{type}/{id}/location")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting Location Details of a Device",
notes = "Get the location details of a device by specifying the device type and device identifier.",
tags = "Device Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:details")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the location details of the device.",
response = Device.class, //TODO, This should be DeviceLocation.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 was last modified.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. Empty body because the client already has the latest version" +
" of the requested resource.\n"),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
response = ErrorResponse.class),
@ApiResponse(
code = 404,
message = "Not Found. \n Location data for the specified device was not found.",
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while retrieving the device details.",
response = ErrorResponse.class)
})
Response getDeviceLocation(
@ApiParam(
name = "type",
value = "The device type name, such as ios, android, windows or fire-alarm.",
required = true)
@PathParam("type")
@Size(max = 45)
String type,
@ApiParam(
name = "id",
value = "The device identifier of the device you want ot get details.",
required = true)
@PathParam("id")
@Size(max = 45)
String id,
@ApiParam(
name = "If-Modified-Since",
value = "Checks if the requested variant was modified, since the specified date-time. \n" +
"Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z. \n" +
"Example: Mon, 05 Jan 2014 15:10:00 +0200",
required = false)
@HeaderParam("If-Modified-Since")
String ifModifiedSince);
/**
* Remove geo alerts for geo clusters
*/
@DELETE
@Path("alerts/{alertType}")
@ApiOperation(
consumes = "application/json",
produces = "application/json",
httpMethod = "DELETE",
value = "Deletes Geo alerts for geo clusters",
notes = "Deleting any type of a geo alert that was defined for geo clusters",
response = Response.class,
tags = "Geo Service Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK.",
response = Response.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body")
}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid Device Identifiers found.",
response = Response.class),
@ApiResponse(
code = 401,
message = "Unauthorized. \n Unauthorized request."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Error on retrieving stats",
response = Response.class)
})
Response removeGeoAlertsForGeoClusters(
@ApiParam(
name = "alertType",
value = "The alert type, such as Within, Speed, Stationary",
required = true)
@PathParam("alertType") String alertType,
@ApiParam(
name = "queryName",
value = "The query name.",
required = true)
@QueryParam("queryName") String queryName);
@GET
@Path("/type/{operationCode}")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting Activity Details",
notes = "Get the details of the operations/activities executed by the server on the devices registered" +
" with WSO2 EMM, during a defined time period.",
tags = "Activity Info Provider",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:get-activity")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the activity details.",
response = ActivityList.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 was last modified.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 401,
message = "Unauthorized. \n Unauthorized request."),
@ApiResponse(
code = 404,
message = "Not Found. \n No activities found.",
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the activity data.",
response = ErrorResponse.class)
})
Response getActivities(
@ApiParam(
name = "operationCode",
value = "Operation Code of the Activity",
required = true)
@PathParam("operationCode") String operationCode,
@ApiParam(
name = "offset",
value = "The starting pagination index for the complete list of qualified items.",
required = true,
defaultValue = "0")
@QueryParam("offset") int offset,
@ApiParam(
name = "limit",
value = "Provide how many activity details you require from the starting pagination index/offset.",
required = true,
defaultValue = "5")
@QueryParam("limit") int limit);
@POST
@Path("/search-devices")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Advanced Search for Devices",
notes = "Search for devices by filtering the search result through the specified search terms.",
tags = "Device Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:search")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully retrieved the device information.",
response = DeviceList.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 was last modified. \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.\n"),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
response = ErrorResponse.class),
@ApiResponse(
code = 404,
message = "Not Acceptable.\n The existing device did not match the values specified in the device search.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The format of the requested entity was not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while getting the device details.",
response = ErrorResponse.class)
})
Response searchDevices(
@ApiParam(
name = "offset",
value = "The starting pagination index for the complete list of qualified items.",
required = false,
defaultValue = "0")
@QueryParam("offset")
int offset,
@ApiParam(
name = "limit",
value = "Provide how many activity details you require from the starting pagination index/offset.",
required = false,
defaultValue = "5")
@QueryParam("limit")
int limit,
@ApiParam(
name = "searchContext",
value = "The properties to advanced search devices.",
required = true)
SearchContext searchContext);
@GET
@Path("/{type}/features")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get Feature Details of a Device Type",
notes = "The features in WSO2 EMM enables 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.",
tags = "Device Type Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:features")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the list of supported features.",
response = DeviceTypeList.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 was last modified.\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.\n"),
@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 " +
"list of supported device types.",
response = ErrorResponse.class)
}
)
Response getFeatures(
@ApiParam(
name = "type",
value = "The device type name, such as ios, android, windows or fire-alarm.",
required = true)
@PathParam("type")
@Size(max = 45)
String type,
@ApiParam(
name = "If-Modified-Since",
value = "Checks if the requested variant was modified, since the specified date-time.\n" +
"Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
"Example: Mon, 05 Jan 2014 15:10:00 +0200",
required = false)
@HeaderParam("If-Modified-Since")
String ifModifiedSince);