feldera_types/query_params.rs
1//! Types for the query parameters of the pipeline endpoints.
2
3use serde::{Deserialize, Serialize};
4use utoipa::{IntoParams, ToSchema};
5
6use crate::runtime_status::RuntimeDesiredStatus;
7
8/// Circuit metrics output format.
9/// - `prometheus`: [format](https://github.com/prometheus/docs/blob/4b1b80f5f660a2f8dc25a54f52a65a502f31879a/docs/instrumenting/exposition_formats.md) expected by Prometheus
10/// - `json`: JSON format
11#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, ToSchema)]
12#[serde(rename_all = "snake_case")]
13pub enum MetricsFormat {
14 Prometheus,
15 Json,
16}
17
18/// Returns default metrics format.
19fn default_metrics_format() -> MetricsFormat {
20 MetricsFormat::Prometheus
21}
22
23/// Query parameters to retrieve pipeline circuit metrics.
24#[derive(Debug, Deserialize, IntoParams, ToSchema)]
25pub struct MetricsParameters {
26 #[serde(default = "default_metrics_format")]
27 pub format: MetricsFormat,
28}
29
30#[derive(Debug, Deserialize, IntoParams, ToSchema)]
31#[serde(default)]
32pub struct ActivateParams {
33 #[serde(with = "crate::runtime_status::snake_case_runtime_desired_status")]
34 pub initial: RuntimeDesiredStatus,
35}
36
37impl Default for ActivateParams {
38 fn default() -> Self {
39 Self {
40 initial: RuntimeDesiredStatus::Running,
41 }
42 }
43}
44
45#[derive(Debug, Deserialize, Serialize, IntoParams, ToSchema)]
46#[serde(default)]
47pub struct SamplyProfileParams {
48 /// In a multihost pipeline, the ordinal of the pipeline to sample.
49 pub ordinal: usize,
50 /// The number of seconds to sample for the profile.
51 pub duration_secs: u64,
52}
53
54/// Default query parameters for POST of a pipeline samply profile.
55impl Default for SamplyProfileParams {
56 fn default() -> Self {
57 Self {
58 ordinal: 0,
59 duration_secs: 30,
60 }
61 }
62}
63
64/// Query parameters to retrieve samply profile.
65#[derive(Debug, Default, Deserialize, Serialize, IntoParams, ToSchema)]
66#[into_params(parameter_in = Query)]
67#[serde(default)]
68pub struct SamplyProfileGetParams {
69 /// In a multihost pipeline, the ordinal of the pipeline to sample.
70 pub ordinal: usize,
71 /// If true, returns 204 redirect with Retry-After header if profile collection is in progress.
72 /// If false or not provided, returns the last collected profile.
73 pub latest: bool,
74}
75
76/// Query parameters to the `/commit_transaction` endpoint.
77#[derive(Debug, Default, Deserialize, Serialize, IntoParams, ToSchema)]
78#[into_params(parameter_in = Query)]
79#[serde(default)]
80pub struct CommitTransactionParams {
81 /// The ID of the transaction to commit, which `/start_transaction`
82 /// returned:
83 ///
84 /// - If this is the transaction that the API started and that is still
85 /// open, the request commits it.
86 /// - If this is the last transaction that `/commit_transaction`
87 /// committed, the request succeeds and does nothing, so it is safe to
88 /// retry.
89 /// - Otherwise, the request fails with 409 Conflict, for example if no
90 /// transaction with this ID has started yet.
91 ///
92 /// Without this parameter, the request commits the transaction that the
93 /// API started.
94 #[param(value_type = Option<i64>)]
95 #[schema(value_type = Option<i64>)]
96 pub transaction_id: Option<crate::transaction::TransactionId>,
97
98 /// The `incarnation_uuid` that `/start_transaction` returned. If the
99 /// pipeline restarted since then, the request fails with 400 Bad Request
100 /// and error code `IncarnationUuidMismatch`, because transaction IDs start
101 /// again after a restart.
102 pub incarnation_uuid: Option<uuid::Uuid>,
103}
104
105/// Query parameters to the `/approve` endpoint.
106#[derive(Debug, Deserialize, IntoParams, ToSchema)]
107pub struct ApproveParameters {
108 /// Bootstrap the pipeline with output connectors disabled.
109 #[serde(default)]
110 pub silent_bootstrap: bool,
111 /// Bootstrap new and modified views concurrently, keeping the pre-existing
112 /// views live while the new ones backfill. Mutually exclusive with
113 /// `silent_bootstrap`.
114 #[serde(default)]
115 pub concurrent_bootstrap: bool,
116}
117
118/// Query parameters to the `/stats` endpoint.
119#[derive(Debug, Default, Deserialize, Serialize, IntoParams, ToSchema)]
120#[into_params(parameter_in = Query)]
121pub struct StatsParams {
122 /// When `true`, the response includes the most recent error messages of
123 /// each connector. An error message can contain values from the record
124 /// that caused it. The default is `false`, which keeps the response small
125 /// for callers that poll `/stats`.
126 #[serde(default)]
127 pub include_connector_errors: bool,
128}