2018-12-04 16:34:55 +00:00
|
|
|
package api;
|
|
|
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
2018-12-07 17:42:31 +00:00
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
2018-12-04 16:34:55 +00:00
|
|
|
import io.swagger.v3.oas.annotations.extensions.Extension;
|
|
|
|
import io.swagger.v3.oas.annotations.extensions.ExtensionProperty;
|
|
|
|
import io.swagger.v3.oas.annotations.media.Content;
|
|
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.ws.rs.GET;
|
|
|
|
import javax.ws.rs.Path;
|
|
|
|
import javax.ws.rs.Produces;
|
|
|
|
import javax.ws.rs.core.Context;
|
|
|
|
import javax.ws.rs.core.MediaType;
|
2018-12-05 11:32:55 +00:00
|
|
|
|
|
|
|
import controller.Controller;
|
2018-12-04 16:34:55 +00:00
|
|
|
|
|
|
|
@Path("admin")
|
|
|
|
@Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN})
|
|
|
|
@Extension(name = "translation", properties = {
|
|
|
|
@ExtensionProperty(name="path", value="/Api/AdminResource")
|
|
|
|
}
|
|
|
|
)
|
|
|
|
@Tag(name = "admin")
|
|
|
|
public class AdminResource {
|
|
|
|
|
|
|
|
@Context
|
|
|
|
HttpServletRequest request;
|
|
|
|
|
2018-12-07 17:42:31 +00:00
|
|
|
@GET
|
|
|
|
@Path("/dud")
|
|
|
|
@Parameter(name = "blockSignature", description = "Block signature", schema = @Schema(type = "string", format = "byte", minLength = 84, maxLength=88))
|
|
|
|
@Parameter(in = ParameterIn.QUERY, name = "limit", description = "Maximum number of entries to return", schema = @Schema(type = "integer", defaultValue = "10"))
|
|
|
|
@Parameter(in = ParameterIn.QUERY, name = "offset", description = "Starting entry in results", schema = @Schema(type = "integer"))
|
|
|
|
@Parameter(in = ParameterIn.QUERY, name = "includeTransactions", description = "Include associated transactions in results", schema = @Schema(type = "boolean"))
|
|
|
|
public String globalParameters() {
|
|
|
|
return "";
|
2018-12-04 16:34:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@GET
|
|
|
|
@Path("/uptime")
|
|
|
|
@Operation(
|
|
|
|
summary = "Fetch running time of server",
|
|
|
|
description = "Returns uptime in milliseconds",
|
|
|
|
extensions = {
|
|
|
|
@Extension(name = "translation", properties = {
|
|
|
|
@ExtensionProperty(name="description.key", value="operation:description")
|
|
|
|
})
|
|
|
|
},
|
|
|
|
responses = {
|
|
|
|
@ApiResponse(
|
|
|
|
description = "uptime in milliseconds",
|
|
|
|
content = @Content(schema = @Schema(implementation = String.class)),
|
|
|
|
extensions = {
|
|
|
|
@Extension(name = "translation", properties = {
|
|
|
|
@ExtensionProperty(name="description.key", value="success_response:description")
|
|
|
|
})
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
public String uptime() {
|
2018-12-07 17:42:31 +00:00
|
|
|
return Long.toString(System.currentTimeMillis() - Controller.startTime);
|
2018-12-04 16:34:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@GET
|
|
|
|
@Path("/stop")
|
|
|
|
@Operation(
|
|
|
|
summary = "Shutdown",
|
|
|
|
description = "Shutdown",
|
|
|
|
extensions = {
|
|
|
|
@Extension(name = "translation", properties = {
|
|
|
|
@ExtensionProperty(name="description.key", value="operation:description")
|
|
|
|
})
|
|
|
|
},
|
|
|
|
responses = {
|
|
|
|
@ApiResponse(
|
|
|
|
description = "\"true\"",
|
|
|
|
content = @Content(schema = @Schema(implementation = String.class)),
|
|
|
|
extensions = {
|
|
|
|
@Extension(name = "translation", properties = {
|
|
|
|
@ExtensionProperty(name="description.key", value="success_response:description")
|
|
|
|
})
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
public String shutdown() {
|
2018-12-07 17:42:31 +00:00
|
|
|
Security.checkApiCallAllowed(request);
|
2018-12-04 16:34:55 +00:00
|
|
|
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2018-12-05 11:32:55 +00:00
|
|
|
Controller.shutdown();
|
2018-12-04 16:34:55 +00:00
|
|
|
}
|
2018-12-07 17:42:31 +00:00
|
|
|
}).start();
|
2018-12-04 16:34:55 +00:00
|
|
|
|
2018-12-07 17:42:31 +00:00
|
|
|
return "true";
|
2018-12-04 16:34:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|