VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
configureController.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (c) 2026 MAK Technologies, Inc.
3  * All rights reserved.
4  ******************************************************************************/
5 
6 #pragma once
7 
8 #include <oatpp/web/server/api/ApiController.hpp>
9 #include <oatpp/parser/json/mapping/ObjectMapper.hpp>
10 #include <oatpp/core/macro/codegen.hpp>
11 #include <oatpp/core/macro/component.hpp>
12 
13 #include OATPP_CODEGEN_BEGIN(ApiController)
14 
23 class DtConfigureController : public oatpp::web::server::api::ApiController
24 {
25 public:
26  DtConfigureController(const std::shared_ptr<ObjectMapper>& objectMapper,
27  const std::string& publicDir)
28  : oatpp::web::server::api::ApiController(objectMapper)
29  , myPublicDir(publicDir)
30  {
31  if (!myPublicDir.empty() && myPublicDir.back() != '/' && myPublicDir.back() != '\\')
32  myPublicDir += '/';
33  }
34 
35  ENDPOINT_INFO(getRwCommandSpecs)
36  {
37  info->summary = "List all RW command specs including hidden status";
38  info->description =
39  "Returns all registered RW task/set types merged with any existing configuration "
40  "from commandSpecs.json. Types not yet present in the file appear with only "
41  "CommandType and DisplayName.";
42  info->addTag("Configure");
43  info->addResponse<oatpp::String>(Status::CODE_200, "application/json");
44  }
45  ENDPOINT("GET", "/api/configure/command-specs", getRwCommandSpecs,
46  REQUEST(std::shared_ptr<IncomingRequest>, request))
47  {
48  return handleGetRwCommandSpecs(request);
49  }
50 
51  ENDPOINT_INFO(updateRwCommandSpec)
52  {
53  info->summary = "Update a command spec entry in commandSpecs.json";
54  info->description =
55  "Upserts the configuration for the given command type. The entire entry JSON "
56  "replaces any existing entry for that type. Accepted fields include "
57  "DisplayName, Level, Group, Icon, hidden (bool), and Parameters.";
58  info->addTag("Configure");
59  info->pathParams["commandType"].description = "Command type identifier";
60  info->addConsumes<oatpp::String>("application/json");
61  info->addResponse<oatpp::String>(Status::CODE_200, "application/json");
62  info->addResponse<oatpp::String>(Status::CODE_400, "application/json");
63  info->addResponse<oatpp::String>(Status::CODE_500, "application/json");
64  }
65  ENDPOINT("PUT", "/api/configure/command-specs/{commandType}", updateRwCommandSpec,
66  PATH(String, commandType), REQUEST(std::shared_ptr<IncomingRequest>, request))
67  {
68  return handleUpdateRwCommandSpec(request, commandType);
69  }
70 
71  ENDPOINT_INFO(getIcons)
72  {
73  info->summary = "List icon filenames available in public/icons/";
74  info->description =
75  "Returns a JSON object with an \"icons\" array of URL paths (e.g. \"/icons/foo.svg\") "
76  "for every file found in the server's public/icons/ directory.";
77  info->addTag("Configure");
78  info->addResponse<oatpp::String>(Status::CODE_200, "application/json");
79  }
80  ENDPOINT("GET", "/api/configure/icons", getIcons,
81  REQUEST(std::shared_ptr<IncomingRequest>, request))
82  {
83  return handleGetIcons(request);
84  }
85 
86  ENDPOINT_INFO(getFilters)
87  {
88  info->summary = "List entity filter available in public/filters/";
89  info->description = "Returns a JSON object with a \"filters\" array of named filters";
90  info->addTag("Configure");
91  info->addResponse<oatpp::String>(Status::CODE_200, "application/json");
92  }
93  ENDPOINT("GET", "/api/configure/filters", getFilters, REQUEST(std::shared_ptr<IncomingRequest>, request))
94  {
95  return handleGetFilters(request);
96  }
97 
98  ENDPOINT_INFO(deleteSession)
99  {
100  info->summary = "Forcibly close an active session by integer session ID";
101  info->description =
102  "Immediately invalidates the session with the given ID. "
103  "The affected client's next API call will receive a 401. "
104  "Requires the 'session.write' permission.";
105  info->addTag("Configure");
106  info->pathParams["sessionId"].description = "Integer session ID as shown in GET /api/status";
107  info->addResponse<oatpp::String>(Status::CODE_200, "application/json");
108  info->addResponse<oatpp::String>(Status::CODE_400, "application/json");
109  info->addResponse<oatpp::String>(Status::CODE_404, "application/json");
110  }
111  ENDPOINT("DELETE", "/api/configure/sessions/{sessionId}", deleteSession,
112  PATH(String, sessionId), REQUEST(std::shared_ptr<IncomingRequest>, request))
113  {
114  return handleDeleteSession(request, sessionId);
115  }
116 
117 private:
118  std::string myPublicDir;
119 
120  std::shared_ptr<OutgoingResponse> handleGetRwCommandSpecs(
121  const std::shared_ptr<IncomingRequest>& req);
122 
123  std::shared_ptr<OutgoingResponse> handleUpdateRwCommandSpec(
124  const std::shared_ptr<IncomingRequest>& req, const String& commandType);
125 
126  std::shared_ptr<OutgoingResponse> handleGetIcons(
127  const std::shared_ptr<IncomingRequest>& req);
128 
129  std::shared_ptr<OutgoingResponse> handleGetFilters(
130  const std::shared_ptr<IncomingRequest>& req);
131 
132  std::shared_ptr<OutgoingResponse> handleDeleteSession(
133  const std::shared_ptr<IncomingRequest>& req, const String& sessionId);
134 };
135 
136 #include OATPP_CODEGEN_END(ApiController)
ENDPOINT("GET","/api/configure/icons", getIcons, REQUEST(std::shared_ptr< IncomingRequest >, request))
Definition: configureController.h:80
ENDPOINT_INFO(getIcons)
Definition: configureController.h:71
ENDPOINT_INFO(getRwCommandSpecs)
Definition: configureController.h:35
ENDPOINT("DELETE","/api/configure/sessions/{sessionId}", deleteSession, PATH(String, sessionId), REQUEST(std::shared_ptr< IncomingRequest >, request))
Definition: configureController.h:111
ENDPOINT_INFO(getFilters)
Definition: configureController.h:86
DtConfigureController(const std::shared_ptr< ObjectMapper > &objectMapper, const std::string &publicDir)
Definition: configureController.h:26
std::shared_ptr< OutgoingResponse > handleUpdateRwCommandSpec(const std::shared_ptr< IncomingRequest > &req, const String &commandType)
std::string myPublicDir
Definition: configureController.h:118
std::shared_ptr< OutgoingResponse > handleGetFilters(const std::shared_ptr< IncomingRequest > &req)
std::shared_ptr< OutgoingResponse > handleGetRwCommandSpecs(const std::shared_ptr< IncomingRequest > &req)
ENDPOINT_INFO(updateRwCommandSpec)
Definition: configureController.h:51
std::shared_ptr< OutgoingResponse > handleDeleteSession(const std::shared_ptr< IncomingRequest > &req, const String &sessionId)
std::shared_ptr< OutgoingResponse > handleGetIcons(const std::shared_ptr< IncomingRequest > &req)
ENDPOINT("GET","/api/configure/command-specs", getRwCommandSpecs, REQUEST(std::shared_ptr< IncomingRequest >, request))
Definition: configureController.h:45
ENDPOINT("PUT","/api/configure/command-specs/{commandType}", updateRwCommandSpec, PATH(String, commandType), REQUEST(std::shared_ptr< IncomingRequest >, request))
Definition: configureController.h:65
ENDPOINT_INFO(deleteSession)
Definition: configureController.h:98
DtConfigureController — REST endpoints for configuring the webserver itself.
Definition: configureController.h:23

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)