You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by nn...@apache.org on 2015/06/06 00:00:37 UTC
mesos git commit: Added help for files endpoints.
Repository: mesos
Updated Branches:
refs/heads/master b55595b06 -> 1c8656b48
Added help for files endpoints.
Review: https://reviews.apache.org/r/34984
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1c8656b4
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1c8656b4
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1c8656b4
Branch: refs/heads/master
Commit: 1c8656b489ed8b33ffbdf4e2539e784cb8b8ec95
Parents: b55595b
Author: Aditi Dixit <ad...@gmail.com>
Authored: Fri Jun 5 14:44:00 2015 -0700
Committer: Niklas Q. Nielsen <ni...@qni.dk>
Committed: Fri Jun 5 15:00:27 2015 -0700
----------------------------------------------------------------------
src/files/files.cpp | 81 +++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 77 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/1c8656b4/src/files/files.cpp
----------------------------------------------------------------------
diff --git a/src/files/files.cpp b/src/files/files.cpp
index ce02411..3cdd38a 100644
--- a/src/files/files.cpp
+++ b/src/files/files.cpp
@@ -12,6 +12,7 @@
#include <process/deferred.hpp> // TODO(benh): This is required by Clang.
#include <process/dispatch.hpp>
#include <process/future.hpp>
+#include <process/help.hpp>
#include <process/http.hpp>
#include <process/io.hpp>
#include <process/mime.hpp>
@@ -37,6 +38,10 @@
using namespace process;
+using process::DESCRIPTION;
+using process::HELP;
+using process::TLDR;
+using process::USAGE;
using process::wait; // Necessary on some OS's to disambiguate.
using process::http::BadRequest;
@@ -95,6 +100,11 @@ private:
// Returns the internal virtual path mapping.
Future<Response> debug(const Request& request);
+ const static std::string BROWSE_HELP;
+ const static std::string READ_HELP;
+ const static std::string DOWNLOAD_HELP;
+ const static std::string DEBUG_HELP;
+
hashmap<string, string> paths;
};
@@ -106,10 +116,18 @@ FilesProcess::FilesProcess()
void FilesProcess::initialize()
{
- route("/browse.json", None(), &FilesProcess::browse);
- route("/read.json", None(), &FilesProcess::read);
- route("/download.json", None(), &FilesProcess::download);
- route("/debug.json", None(), &FilesProcess::debug);
+ route("/browse.json",
+ FilesProcess::BROWSE_HELP,
+ &FilesProcess::browse);
+ route("/read.json",
+ FilesProcess::READ_HELP,
+ &FilesProcess::read);
+ route("/download.json",
+ FilesProcess::DOWNLOAD_HELP,
+ &FilesProcess::download);
+ route("/debug.json",
+ FilesProcess::DEBUG_HELP,
+ &FilesProcess::debug);
}
@@ -149,6 +167,20 @@ void FilesProcess::detach(const string& name)
}
+const string FilesProcess::BROWSE_HELP = HELP(
+ TLDR(
+ "Returns a file listing for a directory."),
+ USAGE(
+ "/files/browse.json"),
+ DESCRIPTION(
+ "Lists files and directories contained in the path as",
+ "a JSON object.",
+ "",
+ "Query parameters:",
+ "",
+ "> path=VALUE The path of directory to browse."));
+
+
Future<Response> FilesProcess::browse(const Request& request)
{
Option<string> path = request.query.get("path");
@@ -209,6 +241,23 @@ Future<Response> _read(int fd,
}
+const string FilesProcess::READ_HELP = HELP(
+ TLDR(
+ "Reads data from a file."),
+ USAGE(
+ "/files/read.json"),
+ DESCRIPTION(
+ "This endpoint reads data from a file at a given offset and for",
+ "a given length."
+ "",
+ "Query parameters:",
+ "",
+ "> path=VALUE The path of directory to browse.",
+ "> offset=VALUE Value added to base address to obtain "
+ "a second address",
+ "> length=VALUE Length of file to read."));
+
+
Future<Response> FilesProcess::read(const Request& request)
{
Option<string> path = request.query.get("path");
@@ -322,6 +371,20 @@ Future<Response> FilesProcess::read(const Request& request)
}
+const string FilesProcess::DOWNLOAD_HELP = HELP(
+ TLDR(
+ "Returns the raw file contents for a given path."),
+ USAGE(
+ "/files/download.json"),
+ DESCRIPTION(
+ "This endpoint will return the raw file contents for the",
+ "given path.",
+ "",
+ "Query parameters:",
+ "",
+ "> path=VALUE The path of directory to browse."));
+
+
Future<Response> FilesProcess::download(const Request& request)
{
Option<string> path = request.query.get("path");
@@ -369,6 +432,16 @@ Future<Response> FilesProcess::download(const Request& request)
}
+const string FilesProcess::DEBUG_HELP = HELP(
+ TLDR(
+ "Returns the internal virtual path mapping."),
+ USAGE(
+ "/files/debug.json"),
+ DESCRIPTION(
+ "This endpoint shows the internal virtual path map as a",
+ "JSON object."));
+
+
Future<Response> FilesProcess::debug(const Request& request)
{
JSON::Object object;