下面列出了怎么用io.swagger.annotations.ExtensionProperty的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Retrieves all the of user groups in this NiFi.
*
* @return a list of all user groups in this NiFi.
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("user-groups")
@ApiOperation(
value = "Get user groups",
notes = NON_GUARANTEED_ENDPOINT,
response = UserGroup.class,
responseContainer = "List",
extensions = {
@Extension(name = "access-policy", properties = {
@ExtensionProperty(name = "action", value = "read"),
@ExtensionProperty(name = "resource", value = "/tenants") })
}
)
@ApiResponses({
@ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400),
@ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
@ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
@ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
@ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getUserGroups() {
final List<UserGroup> userGroups = serviceFacade.getUserGroups();
return generateOkResponse(userGroups).build();
}
/**
* Retrieves all access policies
*
* @return A list of access policies
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Get all access policies",
response = AccessPolicy.class,
responseContainer = "List",
extensions = {
@Extension(name = "access-policy", properties = {
@ExtensionProperty(name = "action", value = "read"),
@ExtensionProperty(name = "resource", value = "/policies") })
}
)
@ApiResponses({
@ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
@ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
@ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getAccessPolicies() {
List<AccessPolicy> accessPolicies = serviceFacade.getAccessPolicies();
if (accessPolicies == null) {
accessPolicies = Collections.emptyList();
}
return generateOkResponse(accessPolicies).build();
}
/**
* Retrieves the specified access policy.
*
* @param identifier The id of the access policy to retrieve
* @return An accessPolicyEntity.
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
@ApiOperation(
value = "Get access policy",
response = AccessPolicy.class,
extensions = {
@Extension(name = "access-policy", properties = {
@ExtensionProperty(name = "action", value = "read"),
@ExtensionProperty(name = "resource", value = "/policies") })
}
)
@ApiResponses({
@ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
@ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
@ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
@ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getAccessPolicy(
@ApiParam(value = "The access policy id.", required = true)
@PathParam("id") final String identifier) {
final AccessPolicy accessPolicy = serviceFacade.getAccessPolicy(identifier);
return generateOkResponse(accessPolicy).build();
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Create bucket",
response = Bucket.class,
extensions = {
@Extension(name = "access-policy", properties = {
@ExtensionProperty(name = "action", value = "write"),
@ExtensionProperty(name = "resource", value = "/buckets") })
}
)
@ApiResponses({
@ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400),
@ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
@ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403) })
public Response createBucket(
@ApiParam(value = "The bucket to create", required = true)
final Bucket bucket) {
final Bucket createdBucket = serviceFacade.createBucket(bucket);
publish(EventFactory.bucketCreated(createdBucket));
return Response.status(Response.Status.OK).entity(createdBucket).build();
}
@Path("device/ordercoffee")
@POST
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Order Coffee",
notes = "",
response = Response.class,
tags = "connectedcup",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "perm:connectedcup:enroll")
})
}
)
Response orderCoffee(@QueryParam("deviceId") String deviceId);
@ApiResponse(code = 200, message = "200 is ok............", response = String.class,
responseHeaders = @ResponseHeader(name = "x-user-domain", response = String.class))
@ApiOperation(value = "value1", tags = {"tag1", "tag2"},
responseHeaders = {@ResponseHeader(name = "x-user-name", response = String.class),
@ResponseHeader(name = "x-user-id", response = String.class)},
extensions = {
@Extension(name = "x-class-name", properties = {@ExtensionProperty(value = "value", name = "key")})})
public void responseThenApiOperation() {
}
@ApiOperation(value = "value1", tags = {"tag1", "tag2"},
responseHeaders = {@ResponseHeader(name = "x-user-name", response = String.class),
@ResponseHeader(name = "x-user-id", response = String.class)},
extensions = {
@Extension(name = "x-class-name", properties = {@ExtensionProperty(value = "value", name = "key")})})
@ApiResponse(code = 200, message = "200 is ok............", response = String.class,
responseHeaders = @ResponseHeader(name = "x-user-domain", response = String.class))
public void apiOperationThenResponse() {
}
@DELETE
@Path("/enroll/{type}/{id}")
@ApiOperation(
httpMethod = "DELETE",
value = "Unregistering a Device",
notes = "Use this REST API to unregister a device.",
tags = "Device Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device:disenroll")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully disenrolled the device."),
@ApiResponse(
code = 404,
message = "Not Found. \n The specified resource does not exist."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while dis-enrolling the device.")
})
Response disEnrollDevice(
@ApiParam(name = "type", value = "Define the device type, such as android, ios, or windows.") @PathParam("type") String type,
@ApiParam(name = "id", value = "The unique device identifier.") @PathParam("id") String id);
/**
* Removes the specified user group.
*
* @param httpServletRequest request
* @param identifier The id of the user group to remove.
* @return The deleted user group.
*/
@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("user-groups/{id}")
@ApiOperation(
value = "Delete user group",
notes = NON_GUARANTEED_ENDPOINT,
response = UserGroup.class,
extensions = {
@Extension(name = "access-policy", properties = {
@ExtensionProperty(name = "action", value = "delete"),
@ExtensionProperty(name = "resource", value = "/tenants") })
}
)
@ApiResponses({
@ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400),
@ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
@ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
@ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
@ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response removeUserGroup(
@Context
final HttpServletRequest httpServletRequest,
@ApiParam(value = "The version is used to verify the client is working with the latest version of the entity.", required = true)
@QueryParam(VERSION)
final LongParameter version,
@ApiParam(value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.")
@QueryParam(CLIENT_ID)
@DefaultValue(StringUtils.EMPTY)
final ClientIdParameter clientId,
@ApiParam(value = "The user group id.", required = true)
@PathParam("id")
final String identifier) {
final RevisionInfo revisionInfo = getRevisionInfo(version, clientId);
final UserGroup userGroup = serviceFacade.deleteUserGroup(identifier, revisionInfo);
publish(EventFactory.userGroupDeleted(userGroup));
return generateOkResponse(userGroup).build();
}
@DELETE
@Path("{flowId}")
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Delete bucket flow",
notes = "Deletes a flow, including all saved versions of that flow.",
response = VersionedFlow.class,
extensions = {
@Extension(name = "access-policy", properties = {
@ExtensionProperty(name = "action", value = "delete"),
@ExtensionProperty(name = "resource", value = "/buckets/{bucketId}") })
}
)
@ApiResponses({
@ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
@ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
@ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
@ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response deleteFlow(
@ApiParam(value = "The version is used to verify the client is working with the latest version of the entity.", required = true)
@QueryParam(VERSION)
final LongParameter version,
@ApiParam(value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.")
@QueryParam(CLIENT_ID)
@DefaultValue(StringUtils.EMPTY)
final ClientIdParameter clientId,
@PathParam("bucketId")
@ApiParam("The bucket identifier")
final String bucketId,
@PathParam("flowId")
@ApiParam("The flow identifier")
final String flowId) {
final RevisionInfo revisionInfo = getRevisionInfo(version, clientId);
final VersionedFlow deletedFlow = serviceFacade.deleteFlow(bucketId, flowId, revisionInfo);
publish(EventFactory.flowDeleted(deletedFlow));
return Response.status(Response.Status.OK).entity(deletedFlow).build();
}
@DELETE
@Path("/enroll/{type}/{id}")
@ApiOperation(
httpMethod = "DELETE",
value = "Unregistering a Device",
notes = "Use this REST API to unregister a device.",
tags = "Device Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device:disenroll")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully disenrolled the device."),
@ApiResponse(
code = 404,
message = "Not Found. \n The specified resource does not exist."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while dis-enrolling the device.")
})
Response disEnrollDevice(
@ApiParam(name = "type", value = "The unique device identifier.") @PathParam("type") String type,
@ApiParam(name = "id", value = "The unique device identifier.") @PathParam("id") String id);
@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);
@GET
@Path("{bucketName}/{groupId}/{artifactId}/{version}/sha256")
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation(
value = "Get extension repo version checksum",
notes = "Gets the hex representation of the SHA-256 digest for the binary content of the bundle " +
"with the given bucket, group, artifact, and version." + NON_GUARANTEED_ENDPOINT,
response = String.class,
extensions = {
@Extension(name = "access-policy", properties = {
@ExtensionProperty(name = "action", value = "read"),
@ExtensionProperty(name = "resource", value = "/buckets/{bucketId}") })
}
)
@ApiResponses({
@ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400),
@ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
@ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
@ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
@ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getExtensionRepoVersionSha256(
@PathParam("bucketName")
@ApiParam("The bucket name")
final String bucketName,
@PathParam("groupId")
@ApiParam("The group identifier")
final String groupId,
@PathParam("artifactId")
@ApiParam("The artifact identifier")
final String artifactId,
@PathParam("version")
@ApiParam("The version")
final String version
) {
final String sha256Hex = serviceFacade.getExtensionRepoVersionSha256(bucketName, groupId, artifactId, version);
return Response.ok(sha256Hex, MediaType.TEXT_PLAIN).build();
}
/**
* Update an access policy.
*
* @param httpServletRequest request
* @param identifier The id of the access policy to update.
* @param requestAccessPolicy An access policy.
* @return the updated access policy.
*/
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
@ApiOperation(
value = "Update access policy",
response = AccessPolicy.class,
extensions = {
@Extension(name = "access-policy", properties = {
@ExtensionProperty(name = "action", value = "write"),
@ExtensionProperty(name = "resource", value = "/policies") })
}
)
@ApiResponses({
@ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400),
@ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
@ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
@ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
@ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409 + " The NiFi Registry might not be configured to use a ConfigurableAccessPolicyProvider.") })
public Response updateAccessPolicy(
@Context
final HttpServletRequest httpServletRequest,
@ApiParam(value = "The access policy id.", required = true)
@PathParam("id")
final String identifier,
@ApiParam(value = "The access policy configuration details.", required = true)
final AccessPolicy requestAccessPolicy) {
if (requestAccessPolicy == null) {
throw new IllegalArgumentException("Access policy details must be specified when updating a policy.");
}
if (!identifier.equals(requestAccessPolicy.getIdentifier())) {
throw new IllegalArgumentException(String.format("The policy id in the request body (%s) does not equal the "
+ "policy id of the requested resource (%s).", requestAccessPolicy.getIdentifier(), identifier));
}
final AccessPolicy createdPolicy = serviceFacade.updateAccessPolicy(requestAccessPolicy);
return generateOkResponse(createdPolicy).build();
}
@GET
@Path("{flowId}")
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Get flow",
notes = "Gets a flow by id.",
nickname = "globalGetFlow",
response = VersionedFlow.class,
extensions = {
@Extension(name = "access-policy", properties = {
@ExtensionProperty(name = "action", value = "read"),
@ExtensionProperty(name = "resource", value = "/buckets/{bucketId}") })
}
)
@ApiResponses({
@ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400),
@ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
@ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
@ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
@ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getFlow(
@PathParam("flowId")
@ApiParam("The flow identifier")
final String flowId) {
final VersionedFlow flow = serviceFacade.getFlow(flowId);
return Response.status(Response.Status.OK).entity(flow).build();
}
@GET
@Path("{flowId}/versions/{versionNumber: \\d+}")
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Get flow version",
notes = "Gets the given version of a flow, including metadata and flow content.",
nickname = "globalGetFlowVersion",
response = VersionedFlowSnapshot.class,
extensions = {
@Extension(name = "access-policy", properties = {
@ExtensionProperty(name = "action", value = "read"),
@ExtensionProperty(name = "resource", value = "/buckets/{bucketId}") })
}
)
@ApiResponses({
@ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400),
@ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
@ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
@ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
@ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getFlowVersion(
@PathParam("flowId")
@ApiParam("The flow identifier")
final String flowId,
@PathParam("versionNumber")
@ApiParam("The version number")
final Integer versionNumber) {
final VersionedFlowSnapshot snapshot = serviceFacade.getFlowSnapshot(flowId, versionNumber);
return Response.status(Response.Status.OK).entity(snapshot).build();
}
@GET
@Path("{flowId}/versions/latest/metadata")
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Get latest flow version metadata",
notes = "Gets the metadata for the latest version of a flow.",
nickname = "globalGetLatestFlowVersionMetadata",
response = VersionedFlowSnapshotMetadata.class,
extensions = {
@Extension(name = "access-policy", properties = {
@ExtensionProperty(name = "action", value = "read"),
@ExtensionProperty(name = "resource", value = "/buckets/{bucketId}") })
}
)
@ApiResponses({
@ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
@ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
@ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
@ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getLatestFlowVersionMetadata(
@PathParam("flowId")
@ApiParam("The flow identifier")
final String flowId) {
final VersionedFlowSnapshotMetadata latestMetadata = serviceFacade.getLatestFlowSnapshotMetadata(flowId);
return Response.status(Response.Status.OK).entity(latestMetadata).build();
}
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Get extension bundles by bucket",
notes = NON_GUARANTEED_ENDPOINT,
response = Bundle.class,
responseContainer = "List",
extensions = {
@Extension(name = "access-policy", properties = {
@ExtensionProperty(name = "action", value = "read"),
@ExtensionProperty(name = "resource", value = "/buckets/{bucketId}") })
}
)
@ApiResponses({
@ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400),
@ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
@ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
@ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
@ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getExtensionBundles(
@PathParam("bucketId")
@ApiParam(value = "The bucket identifier", required = true)
final String bucketId) {
final List<Bundle> bundles = serviceFacade.getBundlesByBucket(bucketId);
return Response.status(Response.Status.OK).entity(bundles).build();
}
@GET
@Path("{bundleId}/versions")
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Get bundle versions",
notes = "Gets the metadata for the versions of the given extension bundle. " + NON_GUARANTEED_ENDPOINT,
nickname = "globalGetBundleVersions",
response = BundleVersionMetadata.class,
responseContainer = "List",
extensions = {
@Extension(name = "access-policy", properties = {
@ExtensionProperty(name = "action", value = "read"),
@ExtensionProperty(name = "resource", value = "/buckets/{bucketId}") })
}
)
@ApiResponses({
@ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400),
@ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
@ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
@ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
@ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getBundleVersions(
@PathParam("bundleId")
@ApiParam("The extension bundle identifier")
final String bundleId) {
final SortedSet<BundleVersionMetadata> bundleVersions = serviceFacade.getBundleVersions(bundleId);
return Response.status(Response.Status.OK).entity(bundleVersions).build();
}
@GET
@Path("/count")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting the User Count",
notes = "Get the number of users in WSO2 IoTS via this REST API.",
tags = "User Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:users:count")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the user count.",
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 number of users in WSO2 IoTS.",
response = ErrorResponse.class)
})
Response getUserCount();
@GET
@Path("/all")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Retrieve device types information",
notes = "Retrieve device types information.",
response = DeviceType.class,
tags = "Device Type Management Administrative Service",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:types")
})
}
)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK. \n Successfully fetched the device type.",
response = DeviceType.class,
responseContainer = "List",
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 getDeviceTypes();
@GET
@Path("/{username}")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting Details of a User",
notes = "Get the details of a user registered with WSO2 IoTS using the REST API.",
response = BasicUserInfo.class,
tags = "User Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:users:details")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the details of the specified user.",
response = BasicUserInfo.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 = 404,
message = "Not Found. \n The specified resource does not exist.",
response = ErrorResponse.class),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported",
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server ErrorResponse. \n Server error occurred while" +
" fetching the ruser details.",
response = ErrorResponse.class)
})
Response getUser(
@ApiParam(
name = "username",
value = "Provide 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 = "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);
@GET
@Path("/search/usernames")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Searching for a User Name",
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. "
+ "You will be given a list of users having the user name in the exact order of the "
+ "characters you provided.",
tags = "User Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:users:search")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the list of users that matched 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 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 = 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 list of users that " +
"matched the given filter.",
response = ErrorResponse.class)
})
Response getUserNames(
@ApiParam(
name = "filter",
value = "Provide a character or a few character in the user name",
required = true)
@QueryParam("filter") String filter,
@ApiParam(
name = "domain",
value = "The user store domain which the user names should be fetched from",
required = false)
@QueryParam("domain") String domain,
@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 timestamp,
@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 user details you require from the starting pagination index/offset.",
required = false,
defaultValue = "5")
@QueryParam("limit") int limit);
/**
* Retrieve Geo alerts history for geo clusters
*/
@GET
@Path("alerts/history")
@ApiOperation(
consumes = "application/json",
produces = "application/json",
httpMethod = "GET",
value = "Retrieve Geo alerts history for geo clusters",
notes = "Retrieving geo alert history of all defined alerts 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"),
@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 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 getGeoAlertsHistoryForGeoClusters(
@ApiParam(
name = "from",
value = "Get stats from what time",
required = true)
@QueryParam("from") long from,
@ApiParam(
name = "to",
value = "Get stats up to what time",
required = true)
@QueryParam("to") long to);
@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);
@POST
@Path("events/publish/{type}/{deviceId}")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Publishing Events",
notes = "Publish events received by the device client to the WSO2 Data Analytics Server (DAS) using this API.",
tags = "Device Agent Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device:publish-event")
})
}
)
@ApiResponses(
value = {
@ApiResponse(code = 200, message = "OK. \n Successfully published the event",
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 = 303,
message = "See Other. \n The source can be retrieved from the URL specified in 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 format of the requested entity was not supported."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while publishing events.")
})
Response publishEvents(
@ApiParam(
name = "payloadData",
value = "Information of the agent event to be published on DAS.")
@Valid
Map<String, Object> payloadData,
@ApiParam(
name = "type",
value = "The name of the device type, such as android, ios, or windows.")
@PathParam("type") String type,
@ApiParam(
name = "deviceId",
value = "The device ID.")
@PathParam("deviceId") String deviceId);
@GET
@Path("/next-pending/operation/{type}/{id}")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
consumes = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting the Next Pending Operations of a Device",
notes = "There can be many operations that are pending on the device end. Get the next pending operation " +
"of a specific device using this API.",
tags = "Device Agent Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device:operations")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully retrieved the operation.",
response = Operation.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. 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 getNextPendingOperation(@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);
/**
* Updates a user group.
*
* @param httpServletRequest request
* @param identifier The id of the user group to update.
* @param requestUserGroup The user group with updated fields.
* @return The resulting, updated user group.
*/
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("user-groups/{id}")
@ApiOperation(
value = "Update user group",
notes = NON_GUARANTEED_ENDPOINT,
response = UserGroup.class,
extensions = {
@Extension(name = "access-policy", properties = {
@ExtensionProperty(name = "action", value = "write"),
@ExtensionProperty(name = "resource", value = "/tenants") })
}
)
@ApiResponses({
@ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400),
@ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
@ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
@ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
@ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response updateUserGroup(
@Context
final HttpServletRequest httpServletRequest,
@ApiParam(value = "The user group id.", required = true)
@PathParam("id")
final String identifier,
@ApiParam(value = "The user group configuration details.", required = true)
final UserGroup requestUserGroup) {
if (requestUserGroup == null) {
throw new IllegalArgumentException("User group details must be specified to update a user group.");
}
if (!identifier.equals(requestUserGroup.getIdentifier())) {
throw new IllegalArgumentException(String.format("The user group id in the request body (%s) does not equal the "
+ "user group id of the requested resource (%s).", requestUserGroup.getIdentifier(), identifier));
}
final UserGroup updatedUserGroup = serviceFacade.updateUserGroup(requestUserGroup);
publish(EventFactory.userGroupUpdated(updatedUserGroup));
return generateOkResponse(updatedUserGroup).build();
}
@PUT
@Path("/{type}/{id}/changestatus")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
consumes = MediaType.APPLICATION_JSON,
httpMethod = "PUT",
value = "Changing the Status of a Device",
notes = "Change the status of a device from one state to another.",
tags = "Device Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:change-status")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully changed the device status.",
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. 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 changeDeviceStatus(
@ApiParam(
name = "type",
value = "The device type, such as ios, android, or windows.",
required = true)
@PathParam("type")
@Size(max = 45)
String type,
@ApiParam(
name = "id",
value = "Device ID.",
required = true)
@PathParam("id")
@Size(max = 45)
String id,
@ApiParam(
name = "newStatus",
value = "The available device statuses are CREATED, ACTIVE, INACTIVE, UNREACHABLE, UNCLAIMED, SUSPENDED, BLOCKED, REMOVED, and DISENROLLMENT_REQUESTED.",
required = true)
@QueryParam("newStatus")
EnrolmentInfo.Status newStatus);
/**
* Retrieve Analytics for the device type
*/
@GET
@Path("connection/{deviceType}/{deviceId}")
@ApiOperation(
consumes = "application/json",
produces = "application/json",
httpMethod = "GET",
value = "Connecting to a Device",
notes = "You able to connect to a device to start a remote session using this API.",
response = Response.class,
tags = "Remote Session Service Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:remote-session-service:connect")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK.",
response = Response.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@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 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 getRemoteSessionDeviceConnect(
@ApiParam(
name = "deviceId",
value = "The device ID.",
required = true)
@PathParam("deviceId") String deviceId,
@ApiParam(
name = "device-type",
value = "The device type, such as ios, android, or windows.",
required = true)
@PathParam("deviceType")
@Size(max = 45)
String deviceType);