Skip to main content

hanzo_client/apis/
metrics_api.rs

1/*
2 * Hanzo Cloud API
3 *
4 * The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
5 *
6 * The version of the OpenAPI document: v1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`get_metrics_health`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetMetricsHealthError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`get_metrics_logs_health`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetMetricsLogsHealthError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_metrics_logs_query`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetMetricsLogsQueryError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`get_metrics_query`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetMetricsQueryError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`get_metrics_traces_health`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetMetricsTracesHealthError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`get_metrics_traces_query`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetMetricsTracesQueryError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`get_metrics_traces_trace`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetMetricsTracesTraceError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`post_metrics_batch`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum PostMetricsBatchError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`post_metrics_logs_write`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum PostMetricsLogsWriteError {
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`post_metrics_traces_write`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum PostMetricsTracesWriteError {
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`post_metrics_write`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum PostMetricsWriteError {
92    UnknownValue(serde_json::Value),
93}
94
95
96/// Reports the native metrics store's live state for the calling tenant: the subsystem version, the resolved `org`, and `series` — the number of distinct series actually held right now, read out of the store rather than a constant. It is not a dependency probe and has nothing downstream to fail on: the store is in-process, so this answers 200 whenever the process is up.  The tenant is the gateway-minted `X-Org-Id` header, falling back to the deployment brand and then `default`. This surface trusts the edge rather than re-deriving the org from a validated claim of its own, so it belongs behind the gateway and nowhere else.
97pub async fn get_metrics_health(configuration: &configuration::Configuration, ) -> Result<(), Error<GetMetricsHealthError>> {
98
99    let uri_str = format!("{}/v1/metrics/health", configuration.base_path);
100    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
101
102    if let Some(ref user_agent) = configuration.user_agent {
103        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
104    }
105    if let Some(ref token) = configuration.bearer_access_token {
106        req_builder = req_builder.bearer_auth(token.to_owned());
107    };
108
109    let req = req_builder.build()?;
110    let resp = configuration.client.execute(req).await?;
111
112    let status = resp.status();
113
114    if !status.is_client_error() && !status.is_server_error() {
115        Ok(())
116    } else {
117        let content = resp.text().await?;
118        let entity: Option<GetMetricsHealthError> = serde_json::from_str(&content).ok();
119        Err(Error::ResponseError(ResponseContent { status, content, entity }))
120    }
121}
122
123/// Reports the native log store's live state for the calling tenant: the subsystem version and `records`, the count actually held right now rather than a constant. Not a dependency probe — the store is in-process, so this answers 200 whenever the process is up.  The tenant is the gateway-minted `X-Org-Id` header, falling back to the deployment brand and then `default`.
124pub async fn get_metrics_logs_health(configuration: &configuration::Configuration, ) -> Result<(), Error<GetMetricsLogsHealthError>> {
125
126    let uri_str = format!("{}/v1/metrics/logs/health", configuration.base_path);
127    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
128
129    if let Some(ref user_agent) = configuration.user_agent {
130        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
131    }
132    if let Some(ref token) = configuration.bearer_access_token {
133        req_builder = req_builder.bearer_auth(token.to_owned());
134    };
135
136    let req = req_builder.build()?;
137    let resp = configuration.client.execute(req).await?;
138
139    let status = resp.status();
140
141    if !status.is_client_error() && !status.is_server_error() {
142        Ok(())
143    } else {
144        let content = resp.text().await?;
145        let entity: Option<GetMetricsLogsHealthError> = serde_json::from_str(&content).ok();
146        Err(Error::ResponseError(ResponseContent { status, content, entity }))
147    }
148}
149
150/// Answers `{count, records}`, newest first. `match` is the same `k=v,k2=v2` superset label matcher the metrics query uses; `contains` is a case-insensitive substring test against the record body; `start` and `end` are nanosecond bounds.  A bound that is absent, empty or unparseable becomes 0, which means UNBOUNDED — a malformed `start` widens the search rather than failing it. `limit` caps the page and defaults to 100 when absent or non-positive, so an unfiltered read is never the whole ring.  The tenant is the gateway-minted `X-Org-Id` header, falling back to the deployment brand and then `default`, so a search can only reach the org the edge asserted.
151pub async fn get_metrics_logs_query(configuration: &configuration::Configuration, ) -> Result<(), Error<GetMetricsLogsQueryError>> {
152
153    let uri_str = format!("{}/v1/metrics/logs/query", configuration.base_path);
154    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
155
156    if let Some(ref user_agent) = configuration.user_agent {
157        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
158    }
159    if let Some(ref token) = configuration.bearer_access_token {
160        req_builder = req_builder.bearer_auth(token.to_owned());
161    };
162
163    let req = req_builder.build()?;
164    let resp = configuration.client.execute(req).await?;
165
166    let status = resp.status();
167
168    if !status.is_client_error() && !status.is_server_error() {
169        Ok(())
170    } else {
171        let content = resp.text().await?;
172        let entity: Option<GetMetricsLogsQueryError> = serde_json::from_str(&content).ok();
173        Err(Error::ResponseError(ResponseContent { status, content, entity }))
174    }
175}
176
177/// Answers `{count, series}`, where `count` is the number of matching SERIES and each series carries the samples that fall inside the window. `name` selects one series name, and an absent or empty `name` returns every series the org holds. `match` is a `k=v,k2=v2` label matcher applied as a SUPERSET test: a series matches when it carries all the named labels with those values, extra labels and all.  `start` and `end` are nanoseconds since the Unix epoch, and here is the rule worth knowing: a bound that is absent, empty or unparseable becomes 0, which this store reads as UNBOUNDED. A malformed `start` therefore silently widens the query instead of failing it. There is no limit parameter — the window and the matcher are the whole of what bounds the answer.  The tenant is the gateway-minted `X-Org-Id` header, falling back to the deployment brand and then `default`, so a query can only ever read the org the edge asserted.
178pub async fn get_metrics_query(configuration: &configuration::Configuration, ) -> Result<(), Error<GetMetricsQueryError>> {
179
180    let uri_str = format!("{}/v1/metrics/query", configuration.base_path);
181    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
182
183    if let Some(ref user_agent) = configuration.user_agent {
184        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
185    }
186    if let Some(ref token) = configuration.bearer_access_token {
187        req_builder = req_builder.bearer_auth(token.to_owned());
188    };
189
190    let req = req_builder.build()?;
191    let resp = configuration.client.execute(req).await?;
192
193    let status = resp.status();
194
195    if !status.is_client_error() && !status.is_server_error() {
196        Ok(())
197    } else {
198        let content = resp.text().await?;
199        let entity: Option<GetMetricsQueryError> = serde_json::from_str(&content).ok();
200        Err(Error::ResponseError(ResponseContent { status, content, entity }))
201    }
202}
203
204/// Reports the native trace store's live state for the calling tenant: the subsystem version and `spans`, the count actually held right now. Not a dependency probe — the store is in-process, so this answers 200 whenever the process is up.  The tenant is the gateway-minted `X-Org-Id` header, falling back to the deployment brand and then `default`.
205pub async fn get_metrics_traces_health(configuration: &configuration::Configuration, ) -> Result<(), Error<GetMetricsTracesHealthError>> {
206
207    let uri_str = format!("{}/v1/metrics/traces/health", configuration.base_path);
208    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
209
210    if let Some(ref user_agent) = configuration.user_agent {
211        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
212    }
213    if let Some(ref token) = configuration.bearer_access_token {
214        req_builder = req_builder.bearer_auth(token.to_owned());
215    };
216
217    let req = req_builder.build()?;
218    let resp = configuration.client.execute(req).await?;
219
220    let status = resp.status();
221
222    if !status.is_client_error() && !status.is_server_error() {
223        Ok(())
224    } else {
225        let content = resp.text().await?;
226        let entity: Option<GetMetricsTracesHealthError> = serde_json::from_str(&content).ok();
227        Err(Error::ResponseError(ResponseContent { status, content, entity }))
228    }
229}
230
231/// Answers `{count, spans}`, newest first, filtered on each span's START time. `start` and `end` are nanosecond bounds where 0 — which is what an absent, empty or unparseable value becomes — means UNBOUNDED, so a malformed bound widens the listing instead of failing it. `limit` defaults to 100 when absent or non-positive.  It lists SPANS, not traces: several spans of one trace each count separately and each take a slot against `limit`. Assembling one trace is /v1/metrics/traces/trace. The tenant is the gateway-minted `X-Org-Id` header, falling back to the deployment brand and then `default`.
232pub async fn get_metrics_traces_query(configuration: &configuration::Configuration, ) -> Result<(), Error<GetMetricsTracesQueryError>> {
233
234    let uri_str = format!("{}/v1/metrics/traces/query", configuration.base_path);
235    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
236
237    if let Some(ref user_agent) = configuration.user_agent {
238        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
239    }
240    if let Some(ref token) = configuration.bearer_access_token {
241        req_builder = req_builder.bearer_auth(token.to_owned());
242    };
243
244    let req = req_builder.build()?;
245    let resp = configuration.client.execute(req).await?;
246
247    let status = resp.status();
248
249    if !status.is_client_error() && !status.is_server_error() {
250        Ok(())
251    } else {
252        let content = resp.text().await?;
253        let entity: Option<GetMetricsTracesQueryError> = serde_json::from_str(&content).ok();
254        Err(Error::ResponseError(ResponseContent { status, content, entity }))
255    }
256}
257
258/// Answers `{spans}`: every span the org holds for the trace id in `id`, in the order they were appended, which is what a waterfall view renders. Unlike the other reads there is no count, no time range and no limit — a trace is addressed by id or not at all.  An id with no spans answers an EMPTY list, never a 404: the store cannot tell a trace that never existed from one whose spans retention has already dropped, so it does not pretend to. The tenant is the gateway-minted `X-Org-Id` header, falling back to the deployment brand and then `default`, and a trace id belonging to another org is simply not in this org's store.
259pub async fn get_metrics_traces_trace(configuration: &configuration::Configuration, ) -> Result<(), Error<GetMetricsTracesTraceError>> {
260
261    let uri_str = format!("{}/v1/metrics/traces/trace", configuration.base_path);
262    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
263
264    if let Some(ref user_agent) = configuration.user_agent {
265        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
266    }
267    if let Some(ref token) = configuration.bearer_access_token {
268        req_builder = req_builder.bearer_auth(token.to_owned());
269    };
270
271    let req = req_builder.build()?;
272    let resp = configuration.client.execute(req).await?;
273
274    let status = resp.status();
275
276    if !status.is_client_error() && !status.is_server_error() {
277        Ok(())
278    } else {
279        let content = resp.text().await?;
280        let entity: Option<GetMetricsTracesTraceError> = serde_json::from_str(&content).ok();
281        Err(Error::ResponseError(ResponseContent { status, content, entity }))
282    }
283}
284
285/// Writes every sample in a luxfi/metric `MetricBatch` into the calling org's store and answers `{written}`: the number of SAMPLES stored, not families and not metrics. This is the exact wire shape the ZAP `MsgMetricBatch` transport carries, so the HTTP endpoint and the optional ZAP push receiver share one code path and one meaning — the transport is an optimisation, never a different contract.  A counter or gauge lands as one sample. A histogram or summary contributes DERIVED `<name>_sum` and `<name>_count` series, so one metric can write more than one sample and `written` can exceed the number of metrics you sent. The batch's own `TimestampNs` stamps every sample it carries.  The tenant is the gateway-minted `X-Org-Id` header, falling back to the deployment brand and then `default`; each org gets its own store, WAL-durable under the deployment's data dir. A body that does not decode is 400.
286pub async fn post_metrics_batch(configuration: &configuration::Configuration, ) -> Result<(), Error<PostMetricsBatchError>> {
287
288    let uri_str = format!("{}/v1/metrics/batch", configuration.base_path);
289    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
290
291    if let Some(ref user_agent) = configuration.user_agent {
292        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
293    }
294    if let Some(ref token) = configuration.bearer_access_token {
295        req_builder = req_builder.bearer_auth(token.to_owned());
296    };
297
298    let req = req_builder.build()?;
299    let resp = configuration.client.execute(req).await?;
300
301    let status = resp.status();
302
303    if !status.is_client_error() && !status.is_server_error() {
304        Ok(())
305    } else {
306        let content = resp.text().await?;
307        let entity: Option<PostMetricsBatchError> = serde_json::from_str(&content).ok();
308        Err(Error::ResponseError(ResponseContent { status, content, entity }))
309    }
310}
311
312/// Takes `{records:[{t, level, body, labels}]}`, appends each one, and answers `{written}`. Bodies are stored verbatim; `labels` are the indexed dimensions a query filters on, so what you do not label you can only find by substring.  `t` is NANOSECONDS since the Unix epoch. A record sent without one is stored at 0 and then falls outside any query carrying a lower bound — the usual reason a successful write does not read back. Retention is a bounded ring, 1048576 records per org, oldest evicted first. No record is validated or rejected, so `written` is the number of records SENT; only a body that does not decode at all is 400.  The tenant is the gateway-minted `X-Org-Id` header, falling back to the deployment brand and then `default`; each org's records live in its own WAL-durable store.
313pub async fn post_metrics_logs_write(configuration: &configuration::Configuration, ) -> Result<(), Error<PostMetricsLogsWriteError>> {
314
315    let uri_str = format!("{}/v1/metrics/logs/write", configuration.base_path);
316    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
317
318    if let Some(ref user_agent) = configuration.user_agent {
319        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
320    }
321    if let Some(ref token) = configuration.bearer_access_token {
322        req_builder = req_builder.bearer_auth(token.to_owned());
323    };
324
325    let req = req_builder.build()?;
326    let resp = configuration.client.execute(req).await?;
327
328    let status = resp.status();
329
330    if !status.is_client_error() && !status.is_server_error() {
331        Ok(())
332    } else {
333        let content = resp.text().await?;
334        let entity: Option<PostMetricsLogsWriteError> = serde_json::from_str(&content).ok();
335        Err(Error::ResponseError(ResponseContent { status, content, entity }))
336    }
337}
338
339/// Takes `{spans:[{traceId, spanId, parentId, name, startNs, endNs, attrs}]}`, appends each, and answers `{written}` — the number of spans sent. Every span is indexed by its trace id as it lands, which is what makes the waterfall read possible without a second store.  Times are NANOSECONDS since the Unix epoch. Retention is a bounded ring of 1048576 spans per org: past that the OLDEST are evicted to keep the newest 1048576, and the trace index is rebuilt — so a long-lived trace can lose its early spans while its later ones survive, and a waterfall read is best-effort against retention, not a guarantee.  The tenant is the gateway-minted `X-Org-Id` header, falling back to the deployment brand and then `default`. A body that does not decode is 400.
340pub async fn post_metrics_traces_write(configuration: &configuration::Configuration, ) -> Result<(), Error<PostMetricsTracesWriteError>> {
341
342    let uri_str = format!("{}/v1/metrics/traces/write", configuration.base_path);
343    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
344
345    if let Some(ref user_agent) = configuration.user_agent {
346        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
347    }
348    if let Some(ref token) = configuration.bearer_access_token {
349        req_builder = req_builder.bearer_auth(token.to_owned());
350    };
351
352    let req = req_builder.build()?;
353    let resp = configuration.client.execute(req).await?;
354
355    let status = resp.status();
356
357    if !status.is_client_error() && !status.is_server_error() {
358        Ok(())
359    } else {
360        let content = resp.text().await?;
361        let entity: Option<PostMetricsTracesWriteError> = serde_json::from_str(&content).ok();
362        Err(Error::ResponseError(ResponseContent { status, content, entity }))
363    }
364}
365
366/// Takes `{series:[{name, labels, samples:[{t, v}]}]}`, appends every sample, creating each series on first write, and answers `{written}` — again counting SAMPLES, so three series of ten samples is 30.  A series is identified by its name PLUS its whole label set, so adding one label makes a different series rather than annotating an existing one. Timestamps `t` are NANOSECONDS since the Unix epoch; a sample sent without one is stored at 0 and is then excluded by any query that sets a lower bound, which is the usual reason a write that reported success does not read back. Retention is per series and bounded — past 65536 samples the oldest are evicted.  The tenant is the gateway-minted `X-Org-Id` header, falling back to the deployment brand and then `default`. A body that does not decode is 400; nothing else is validated or rejected.
367pub async fn post_metrics_write(configuration: &configuration::Configuration, ) -> Result<(), Error<PostMetricsWriteError>> {
368
369    let uri_str = format!("{}/v1/metrics/write", configuration.base_path);
370    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
371
372    if let Some(ref user_agent) = configuration.user_agent {
373        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
374    }
375    if let Some(ref token) = configuration.bearer_access_token {
376        req_builder = req_builder.bearer_auth(token.to_owned());
377    };
378
379    let req = req_builder.build()?;
380    let resp = configuration.client.execute(req).await?;
381
382    let status = resp.status();
383
384    if !status.is_client_error() && !status.is_server_error() {
385        Ok(())
386    } else {
387        let content = resp.text().await?;
388        let entity: Option<PostMetricsWriteError> = serde_json::from_str(&content).ok();
389        Err(Error::ResponseError(ResponseContent { status, content, entity }))
390    }
391}
392