18#include <reusex/pipeline/JobRunner.hpp>
19#include <reusex/pipeline/stages.hpp>
21#include <nlohmann/json.hpp>
91 : std::runtime_error(std::move(message)), status_(
status) {}
93 int status() const noexcept {
return status_; }
120 void set(std::string key, std::string value);
121 std::optional<std::string>
find(std::string_view key)
const;
124 std::string
str(std::string_view key, std::string fallback)
const;
128 long long integer(std::string_view key,
long long fallback)
const;
136 std::optional<bool>
boolean(std::string_view key)
const;
139 std::map<std::string, std::string, std::less<>> values_;
175 long long max_limit);
189nlohmann::json
error_json(
int status, std::string_view message);
195 const std::filesystem::path &project);
216 const std::string &name);
233 const std::string &name,
const Params ¶ms);
239 std::optional<nlohmann::json>
body;
244 std::vector<std::pair<std::string, std::string>>
headers;
251 const std::string &name,
const Params ¶ms);
258 const std::string &name);
261 const std::string &texture);
313 const std::string &name);
317 const std::string &guid);
319 const std::string &cloud,
const Params ¶ms);
331 const std::string &stage);
341 std::string_view project);
348nlohmann::json
jobs_json(
const std::vector<reusex::pipeline::JobRecord> &jobs,
349 std::string_view project);
354 std::string_view project,
const Params ¶ms);
356 std::string_view project);
357nlohmann::json
hello_json(
const std::vector<reusex::pipeline::JobRecord> &jobs,
358 const std::filesystem::path &project);
380 std::string_view open_project);
388 std::string_view body,
389 const std::function<
void(std::optional<std::string>)> &subscribe);
394 const std::optional<std::string> &subscription);
HttpError(int status, std::string message)
int status() const noexcept
Already-decoded query parameters, so handlers never touch crow::request.
std::optional< std::string > find(std::string_view key) const
long long integer(std::string_view key, long long fallback) const
Integer value, or fallback when absent.
void set(std::string key, std::string value)
std::string str(std::string_view key, std::string fallback) const
String value, or fallback when absent/empty.
std::optional< bool > boolean(std::string_view key) const
Boolean value, or nullopt when absent/empty.
JobStage
A pipeline stage that can be executed as a job.
@ clouds
back-project sensor frames into "cloud" + "normals"
PageWindow page_window(const PageRequest &page, size_t total)
Clamp page onto a collection of total items.
constexpr int kWriteLockTimeoutMs
How long a mutating request waits for the project's writer lock before answering 503.
constexpr std::string_view kApiPrefix
nlohmann::json error_json(int status, std::string_view message)
constexpr std::string_view kApiVersion
Contract version served under kApiPrefix.
nlohmann::json mesh_textures_json(const reusex::ProjectDB &db, const std::string &name)
nlohmann::json health_json(const reusex::ProjectDB *db, const std::filesystem::path &project)
nlohmann::json project_summary_json(const reusex::ProjectDB &db)
The dashboard payload.
nlohmann::json cloud_labels_json(const reusex::ProjectDB &db, const std::string &name)
Label id → name for one cloud, as {"labels": {...}}.
nlohmann::json endpoints_json()
nlohmann::json components_json(const reusex::ProjectDB &db, const Params ¶ms)
constexpr int kDefaultLogEntries
ImageResponse frame_image(const reusex::ProjectDB &db, int id, const Params ¶ms)
One of a frame's images, encoded as PNG.
nlohmann::json frames_json(const reusex::ProjectDB &db, const Params ¶ms)
constexpr int kMaxCollectionItems
Upper bound on limit for the ordinary object collections (clouds, meshes, panoramas,...
nlohmann::json jobs_page_json(const std::vector< reusex::pipeline::JobRecord > &jobs, std::string_view project, const Params ¶ms)
GET /jobs: one page of the job store, with the shared envelope.
const std::vector< Endpoint > & endpoint_table()
Every endpoint this server serves, in documentation order.
nlohmann::json cloud_json(const reusex::ProjectDB &db, const std::string &name)
constexpr size_t kMaxPointsPerPage
Upper bound on limit for the paged points endpoint, so a stray query cannot ask the server to materia...
nlohmann::json mesh_json(const reusex::ProjectDB &db, const std::string &name)
nlohmann::json panoramas_json(const reusex::ProjectDB &db, const Params ¶ms)
std::optional< nlohmann::json > handle_ws_message(std::string_view body, const std::function< void(std::optional< std::string >)> &subscribe)
Handle one client message on the WebSocket channel.
nlohmann::json jobs_json(const std::vector< reusex::pipeline::JobRecord > &jobs, std::string_view project)
Every supplied job, unpaged, as {"jobs": [...]}.
nlohmann::json component_json(const reusex::ProjectDB &db, const std::string &name)
nlohmann::json panorama_json(const reusex::ProjectDB &db, int id)
nlohmann::json stages_json(const reusex::ProjectDB &db)
nlohmann::json clouds_json(const reusex::ProjectDB &db, const Params ¶ms)
Blob mesh_texture_blob(const reusex::ProjectDB &db, const std::string &name, const std::string &texture)
nlohmann::json meshes_json(const reusex::ProjectDB &db, const Params ¶ms)
nlohmann::json hello_json(const std::vector< reusex::pipeline::JobRecord > &jobs, const std::filesystem::path &project)
nlohmann::json stage_validation_json(const reusex::ProjectDB &db, const std::string &stage)
Input-contract validation for a single stage.
nlohmann::json pipeline_log_json(const reusex::ProjectDB &db, const Params ¶ms)
nlohmann::json material_json(const reusex::ProjectDB &db, const std::string &guid)
nlohmann::json instances_json(const reusex::ProjectDB &db, const std::string &cloud, const Params ¶ms)
nlohmann::json job_event_json(const reusex::pipeline::JobEvent &event, std::string_view project)
nlohmann::json job_json(const reusex::pipeline::JobRecord &record, std::string_view project)
constexpr int kMaxImageSize
Upper bound on the max_size image parameter.
PointsResponse cloud_points(const reusex::ProjectDB &db, const std::string &name, const Params ¶ms)
Serve one page of point data in the requested wire format.
nlohmann::json cloud_points_json(const reusex::ProjectDB &db, const std::string &name, const Params ¶ms)
One page of point data as JSON, ignoring format.
constexpr size_t kDefaultPointsPerPage
Blob panorama_image_blob(const reusex::ProjectDB &db, int id, const Params ¶ms)
The equirectangular image, JPEG-encoded.
constexpr int kMaxFrameIds
Upper bound on limit for the sensor-frame id list.
JobSubmission parse_job_request(std::string_view body)
Parse and validate a job submission body.
nlohmann::json projects_json(const reusex::ProjectDB &db, const Params ¶ms)
constexpr std::string_view kImplementation
Identifies which implementation of the contract is answering.
void add_page_envelope(nlohmann::json &object, const PageWindow &window)
Add the shared offset/count/total envelope to a collection response.
nlohmann::json frame_json(const reusex::ProjectDB &db, int id)
nlohmann::json materials_json(const reusex::ProjectDB &db, const Params ¶ms)
void check_job_project(const JobSubmission &submission, std::string_view open_project)
Reject a submission aimed at a different project.
PageRequest parse_page_request(const Params ¶ms, long long default_limit, long long max_limit)
Parse and clamp offset/limit for a paged collection.
bool event_matches_subscription(const reusex::pipeline::JobEvent &event, const std::optional< std::string > &subscription)
True when event should be delivered to a connection filtered to subscription (nullopt = unfiltered,...
Blob mesh_data_blob(const reusex::ProjectDB &db, const std::string &name)
constexpr int kMaxLogEntries
Upper bound on limit for the pipeline-log endpoint.
One notification about a job.
A job as reported by the runner. Snapshot; never a live view.
A non-JSON response body (image, mesh blob).
std::vector< uint8_t > data
One row of the route table.
bool binary
True when the response is not JSON.
std::string path
Crow route pattern, e.g. "/api/v1/clouds/<string>".
std::string summary
Matches the OpenAPI summary for the same path.
An encoded image plus the provenance of any rendering applied to it.
ValueRange range
Only populated for a normalized single-channel kind.
A validated POST /jobs body.
std::optional< std::string > project
Project the client believes it is addressing.
std::string parameters
Serialized JSON object, "" when omitted.
reusex::pipeline::JobStage stage
The half-open [first, last) index range a page covers, plus the size of the collection it was taken f...
size_t count() const noexcept
One points-endpoint response.
std::optional< nlohmann::json > body
Set on format=json.
std::optional< Blob > blob
Set on format=binary (RUXP v1).
std::vector< std::pair< std::string, std::string > > headers
X-Ruxp-* mirrors of the body header, set on the binary path only.
Range of the valid stored values a normalize=true rendering mapped.