XRootD
XrdHttpTapeApiStore.hh
Go to the documentation of this file.
1 #ifndef __XRDHTTPTAPEAPISTORE_HH__
2 #define __XRDHTTPTAPEAPISTORE_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d H t t p T a p e A p i S t o r e . h h */
6 /* */
7 /* (c) 2026 by the XRootD Collaboration */
8 /* */
9 /* This file is part of the XRootD software suite. */
10 /* */
11 /******************************************************************************/
12 
13 #include "XrdOuc/XrdOucJson.hh"
14 
15 #include <cstdint>
16 #include <filesystem>
17 #include <mutex>
18 #include <string>
19 #include <vector>
20 
22 {
23  public:
24  struct Status
25  {
26  int code = 200;
27  std::string message;
28 
29  explicit operator bool() const { return message.empty(); }
30  };
31 
32  explicit XrdHttpTapeApiStore(std::filesystem::path root);
33 
34  Status Initialize();
35  Status CreateStage(const nlohmann::json &files, std::string &requestId);
36  Status GetStage(const std::string &requestId, nlohmann::json &response);
37  Status CancelStage(const std::string &requestId,
38  const nlohmann::json &paths);
39  Status DeleteStage(const std::string &requestId);
40  Status Release(const std::string &requestId, const nlohmann::json &paths);
41  Status ArchiveInfo(const nlohmann::json &paths, nlohmann::json &response);
42 
43  private:
44  Status ResolvePath(const std::filesystem::path &root,
45  const std::string &path,
46  std::string &normalized,
47  std::filesystem::path &resolved) const;
48  Status ReadRequest(const std::string &requestId,
49  nlohmann::json &request) const;
50  Status WriteRequest(const nlohmann::json &request) const;
51  Status ValidateRequestPaths(const nlohmann::json &request,
52  const nlohmann::json &paths,
53  std::vector<std::string> &normalized) const;
54 
55  static bool IsRequestId(const std::string &requestId);
56  static std::uint64_t Now();
57  static std::string GenerateRequestId();
58  static nlohmann::json StatusResponse(const nlohmann::json &request);
59 
60  std::filesystem::path m_root;
61  std::filesystem::path m_archiveRoot;
62  std::filesystem::path m_diskRoot;
63  std::filesystem::path m_requestsRoot;
64  mutable std::mutex m_mutex;
65 };
66 
67 #endif // __XRDHTTPTAPEAPISTORE_HH__
nlohmann::json json
Status DeleteStage(const std::string &requestId)
Status GetStage(const std::string &requestId, nlohmann::json &response)
Status CancelStage(const std::string &requestId, const nlohmann::json &paths)
Status CreateStage(const nlohmann::json &files, std::string &requestId)
Status ArchiveInfo(const nlohmann::json &paths, nlohmann::json &response)
XrdHttpTapeApiStore(std::filesystem::path root)
Status Release(const std::string &requestId, const nlohmann::json &paths)