Skip to main content

hanzo_client/apis/
risk_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_risk_health`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetRiskHealthError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`risk_adopt_model`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum RiskAdoptModelError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`risk_features`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum RiskFeaturesError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`risk_learn`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum RiskLearnError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`risk_policy`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum RiskPolicyError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`risk_publish_model`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum RiskPublishModelError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`risk_score`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum RiskScoreError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`risk_search`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum RiskSearchError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`risk_search_result`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum RiskSearchResultError {
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`risk_set_policy`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum RiskSetPolicyError {
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`risk_state`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum RiskStateError {
92    UnknownValue(serde_json::Value),
93}
94
95
96/// Reports whether the per-organisation model plane is genuinely usable: that the plane was built, that the per-organisation stores can be written, and whether the event surface the feature plane is rolled up from is reachable. It is a REAL probe, not status theatre.  200 only when the plane can work. Otherwise 503 CARRYING THE REPORT — which part failed and the real error — and that body is why this is not a typed op: a typed op reaches a non-2xx by returning an error, and the envelope that produces would drop exactly the detail the probe exists to deliver.  An unreachable event surface is REPORTED and is not a failure. Scoring reads in-memory aggregates and never the warehouse, so a warm that cannot run degrades how much history a model has seen and does not stop it deciding.  It also reports how many organisations' models are resident, how many have been evicted to hold that bound, and how many of the resident ones are at their own aggregate bound. Eviction is lossless — learned state is written to that organisation's own store first and its aggregates rebuild from its own record — so a climbing count is a capacity signal, not a loss. A STRAINED model is different: it has started forgetting its own least-recently-active subjects, and each forgotten subject reads as inactive until it is active again. That is a control degrading, and it is reported here because it is otherwise silent.  It answers about the process, not about a tenant: it takes no organisation and names none.
97pub async fn get_risk_health(configuration: &configuration::Configuration, ) -> Result<(), Error<GetRiskHealthError>> {
98
99    let uri_str = format!("{}/v1/risk/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<GetRiskHealthError> = serde_json::from_str(&content).ok();
119        Err(Error::ResponseError(ResponseContent { status, content, entity }))
120    }
121}
122
123/// Puts one of your organisation's OWN PUBLISHED VALUES in force, by name — which is what an instant rollback is, what promoting a challenger is, and what installing the shape a search found is.  IT TAKES AN ADDRESS AND NEVER STATE. The masses are read from your own store, so nothing about your model has to be held by whatever is making this call. That closes the sharpest edge the previous shape had: a body of counters is something a caller can COMPOSE, and a region filled until activity inside it reads as ordinary is a model that has been shaped rather than learned. The engine's mass invariant was the only thing standing between a composed body and the model; with an address there is no body to compose.  IT ADOPTS THE SHAPE, NOT ONLY THE MASSES. A value records the model space its masses were taken in, and a value whose space differs from the one in force REPLANTS your model into that space before restoring them. That is what makes POST /v1/risk/search actionable: a search answers with the shape that fits your own history best and publishes it fitted, and its address is what you name here. Before this, a winning shape was advice nobody could take — the adoption path refused every shape change, and a winner is a different shape by definition.  WHAT ADOPTING A SEARCHED SHAPE COSTS, SAID PLAINLY: the value a search fits has learned the window the search replayed and nothing older, so installing it trades history for fit. Your appetite is untouched — that is your policy record's, with its own versions — and so is the geometry, which stays your own.  An address your organisation has not published is NOT FOUND. That includes one another organisation published, and it is not a lookup that failed: the store is per organisation and the address is a name, never an authority.
124pub async fn risk_adopt_model(configuration: &configuration::Configuration, risk_adopt_in: models::RiskAdoptIn) -> Result<models::RiskModelState, Error<RiskAdoptModelError>> {
125    // add a prefix to parameters to efficiently prevent name collisions
126    let p_risk_adopt_in = risk_adopt_in;
127
128    let uri_str = format!("{}/v1/risk/state/model", configuration.base_path);
129    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
130
131    if let Some(ref user_agent) = configuration.user_agent {
132        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
133    }
134    if let Some(ref token) = configuration.bearer_access_token {
135        req_builder = req_builder.bearer_auth(token.to_owned());
136    };
137    req_builder = req_builder.json(&p_risk_adopt_in);
138
139    let req = req_builder.build()?;
140    let resp = configuration.client.execute(req).await?;
141
142    let status = resp.status();
143    let content_type = resp
144        .headers()
145        .get("content-type")
146        .and_then(|v| v.to_str().ok())
147        .unwrap_or("application/octet-stream");
148    let content_type = super::ContentType::from(content_type);
149
150    if !status.is_client_error() && !status.is_server_error() {
151        let content = resp.text().await?;
152        match content_type {
153            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
154            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskModelState`"))),
155            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RiskModelState`")))),
156        }
157    } else {
158        let content = resp.text().await?;
159        let entity: Option<RiskAdoptModelError> = serde_json::from_str(&content).ok();
160        Err(Error::ResponseError(ResponseContent { status, content, entity }))
161    }
162}
163
164/// Features is the feature catalogue in its two honest lenses.  The MODEL lens is the governed inventory: one entry per dimension of the model space, each carrying the typology it serves, the supervisor's own words for the indicator, and the published standard those words come from — so a coverage claim is checkable rather than asserted. It is the same for every organisation.  The SURFACE lens is what THIS organisation's own event surface actually carries, measured over the window: how many of its buckets carry each dimension at all, and what the dimension reads where it is present. A dimension present in no bucket is BLIND, and saying so is the difference between no risk and no data.
165pub async fn risk_features(configuration: &configuration::Configuration, days: Option<i32>) -> Result<models::RiskCatalog, Error<RiskFeaturesError>> {
166    // add a prefix to parameters to efficiently prevent name collisions
167    let p_days = days;
168
169    let uri_str = format!("{}/v1/risk/features", configuration.base_path);
170    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
171
172    if let Some(ref param_value) = p_days {
173        req_builder = req_builder.query(&[("days", &param_value.to_string())]);
174    }
175    if let Some(ref user_agent) = configuration.user_agent {
176        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
177    }
178    if let Some(ref token) = configuration.bearer_access_token {
179        req_builder = req_builder.bearer_auth(token.to_owned());
180    };
181
182    let req = req_builder.build()?;
183    let resp = configuration.client.execute(req).await?;
184
185    let status = resp.status();
186    let content_type = resp
187        .headers()
188        .get("content-type")
189        .and_then(|v| v.to_str().ok())
190        .unwrap_or("application/octet-stream");
191    let content_type = super::ContentType::from(content_type);
192
193    if !status.is_client_error() && !status.is_server_error() {
194        let content = resp.text().await?;
195        match content_type {
196            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
197            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskCatalog`"))),
198            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RiskCatalog`")))),
199        }
200    } else {
201        let content = resp.text().await?;
202        let entity: Option<RiskFeaturesError> = serde_json::from_str(&content).ok();
203        Err(Error::ResponseError(ResponseContent { status, content, entity }))
204    }
205}
206
207/// Learn records a batch of events into the caller organisation's own aggregates and lets its model learn from them. It answers how many it learned from.  IT DOES NOT SCORE, AND THAT IS THE POINT. An observation is a value you record; learning is a transformation over observations; a verdict is a query against the result. This op is the first two. [ops.score] is the third, it is pure, and it is the ONE entry point to a verdict. They were one call, which meant you could not record without training and could not train without being answered — and the model ran twice over every event to produce a verdict the response carried and no caller read.  TO OBSERVE AND JUDGE, COMPOSE THE TWO, and mind the order. Score FIRST, then learn: the score is then the model's opinion of an event it has not yet learned from, which is the question worth asking. The other order answers for a model that has already absorbed the event it is judging.  This is the training path, and there is no job behind it: the model IS a set of mass counters over half-space trees, so learning is an increment and the model is current the instant the last event lands. Nothing from any other organisation is in it, and nothing from this organisation leaves it.  A RETRY IS INERT. The record deduplicates on the event id you send, and an event already in it moves nothing, costs nothing and is not counted — so a client that timed out can send the same batch again and its model holds what it holds. Without an id of your own there is nothing to converge on: two identical bodies are two events.
208pub async fn risk_learn(configuration: &configuration::Configuration, risk_learn_in: models::RiskLearnIn) -> Result<models::RiskLearnOut, Error<RiskLearnError>> {
209    // add a prefix to parameters to efficiently prevent name collisions
210    let p_risk_learn_in = risk_learn_in;
211
212    let uri_str = format!("{}/v1/risk/learn", configuration.base_path);
213    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
214
215    if let Some(ref user_agent) = configuration.user_agent {
216        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
217    }
218    if let Some(ref token) = configuration.bearer_access_token {
219        req_builder = req_builder.bearer_auth(token.to_owned());
220    };
221    req_builder = req_builder.json(&p_risk_learn_in);
222
223    let req = req_builder.build()?;
224    let resp = configuration.client.execute(req).await?;
225
226    let status = resp.status();
227    let content_type = resp
228        .headers()
229        .get("content-type")
230        .and_then(|v| v.to_str().ok())
231        .unwrap_or("application/octet-stream");
232    let content_type = super::ContentType::from(content_type);
233
234    if !status.is_client_error() && !status.is_server_error() {
235        let content = resp.text().await?;
236        match content_type {
237            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
238            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskLearnOut`"))),
239            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RiskLearnOut`")))),
240        }
241    } else {
242        let content = resp.text().await?;
243        let entity: Option<RiskLearnError> = serde_json::from_str(&content).ok();
244        Err(Error::ResponseError(ResponseContent { status, content, entity }))
245    }
246}
247
248/// Policy reports the caller organisation's own decision-regime history: every distinct regime it has adopted, which version is in force, and what retention has taken.  WHY IT EXISTS. Every score cites the version it was decided under ([riskScoreOut.Policy]), and the threshold that score was measured against is derived from the appetite that version states. Restate the appetite and, without this record, every earlier decision becomes unreconstructible — the cut it was judged by no longer exists anywhere. An adverse decision that cannot be explained against the policy in force when it was taken cannot be defended.  It covers ONE organisation. The history is on that organisation's own shelf, so another's versions are not filtered out of the answer — they are not in the file the answer is read from.
249pub async fn risk_policy(configuration: &configuration::Configuration, ) -> Result<models::RiskPolicyOut, Error<RiskPolicyError>> {
250
251    let uri_str = format!("{}/v1/risk/policy", configuration.base_path);
252    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
253
254    if let Some(ref user_agent) = configuration.user_agent {
255        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
256    }
257    if let Some(ref token) = configuration.bearer_access_token {
258        req_builder = req_builder.bearer_auth(token.to_owned());
259    };
260
261    let req = req_builder.build()?;
262    let resp = configuration.client.execute(req).await?;
263
264    let status = resp.status();
265    let content_type = resp
266        .headers()
267        .get("content-type")
268        .and_then(|v| v.to_str().ok())
269        .unwrap_or("application/octet-stream");
270    let content_type = super::ContentType::from(content_type);
271
272    if !status.is_client_error() && !status.is_server_error() {
273        let content = resp.text().await?;
274        match content_type {
275            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
276            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskPolicyOut`"))),
277            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RiskPolicyOut`")))),
278        }
279    } else {
280        let content = resp.text().await?;
281        let entity: Option<RiskPolicyError> = serde_json::from_str(&content).ok();
282        Err(Error::ResponseError(ResponseContent { status, content, entity }))
283    }
284}
285
286/// Publishes your organisation's model as a NAMED VALUE, so a decision taken today can be reconstructed tomorrow and a change made today can be undone.  It answers with a NAME and not with the state. The masses stay on your organisation's own encrypted store and are referred to by an address computed from their own content: the shape, the geometry seed, the position in the window, the threshold, the masses themselves as IEEE-754 bits, and the fold watermark behind them. That is what makes the value nameable without making the caller its custodian.  IT IS IDEMPOTENT ON THE VALUE. A model that has not changed publishes to the name it already has and mints nothing, reporting minted=false — so publishing at every boundary that matters is free. Ten values are retained per organisation, bounded in BYTES rather than in rows, and the oldest is disposed of past that.  A model that has learned nothing is refused: planted is not learned, and a value that reproduces nothing is not a value.  It is POST and PUT on one address because they are one plane's two verbs over one kind of thing: POST mints a value from the model in force, PUT puts a value in force. They were /v1/risk/state/snapshot and /v1/risk/state/restore — two addresses named after the operation rather than after the thing, which is how a reader ends up asking what the difference between a snapshot and a value is.
287pub async fn risk_publish_model(configuration: &configuration::Configuration, ) -> Result<models::RiskPublishOut, Error<RiskPublishModelError>> {
288
289    let uri_str = format!("{}/v1/risk/state/model", configuration.base_path);
290    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
291
292    if let Some(ref user_agent) = configuration.user_agent {
293        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
294    }
295    if let Some(ref token) = configuration.bearer_access_token {
296        req_builder = req_builder.bearer_auth(token.to_owned());
297    };
298
299    let req = req_builder.build()?;
300    let resp = configuration.client.execute(req).await?;
301
302    let status = resp.status();
303    let content_type = resp
304        .headers()
305        .get("content-type")
306        .and_then(|v| v.to_str().ok())
307        .unwrap_or("application/octet-stream");
308    let content_type = super::ContentType::from(content_type);
309
310    if !status.is_client_error() && !status.is_server_error() {
311        let content = resp.text().await?;
312        match content_type {
313            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
314            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskPublishOut`"))),
315            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RiskPublishOut`")))),
316        }
317    } else {
318        let content = resp.text().await?;
319        let entity: Option<RiskPublishModelError> = serde_json::from_str(&content).ok();
320        Err(Error::ResponseError(ResponseContent { status, content, entity }))
321    }
322}
323
324/// Score judges one event against the caller organisation's OWN model and learns nothing from it. It is how a candidate is tried against real behaviour before anything depends on the answer, and it is the model's analogue of testing a rule.  Because it records nothing, the aggregates it reads do not include the event: the numbers are the organisation's history as it stands. A model still warming declines with a reason rather than answering zero, because silence must never read as a clean result.
325pub async fn risk_score(configuration: &configuration::Configuration, risk_score_in: models::RiskScoreIn) -> Result<models::RiskScoreOut, Error<RiskScoreError>> {
326    // add a prefix to parameters to efficiently prevent name collisions
327    let p_risk_score_in = risk_score_in;
328
329    let uri_str = format!("{}/v1/risk/score", configuration.base_path);
330    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
331
332    if let Some(ref user_agent) = configuration.user_agent {
333        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
334    }
335    if let Some(ref token) = configuration.bearer_access_token {
336        req_builder = req_builder.bearer_auth(token.to_owned());
337    };
338    req_builder = req_builder.json(&p_risk_score_in);
339
340    let req = req_builder.build()?;
341    let resp = configuration.client.execute(req).await?;
342
343    let status = resp.status();
344    let content_type = resp
345        .headers()
346        .get("content-type")
347        .and_then(|v| v.to_str().ok())
348        .unwrap_or("application/octet-stream");
349    let content_type = super::ContentType::from(content_type);
350
351    if !status.is_client_error() && !status.is_server_error() {
352        let content = resp.text().await?;
353        match content_type {
354            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
355            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskScoreOut`"))),
356            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RiskScoreOut`")))),
357        }
358    } else {
359        let content = resp.text().await?;
360        let entity: Option<RiskScoreError> = serde_json::from_str(&content).ok();
361        Err(Error::ResponseError(ResponseContent { status, content, entity }))
362    }
363}
364
365/// Search runs an exhaustive search for the model shape that best fits the caller organisation's own history, and answers 202 with the run to read back.  Every candidate is replayed over that organisation's OWN feature surface in its own sandbox — its own aggregates, its own model, neither of them the live one — so a run cannot move a live threshold and cannot see another organisation's data. The result is the learning curve for each shape and the one that fit best, ranked on how closely it honoured the stated appetite, whether it warmed at all, whether it saturated, and how much of the coordinate space it left blind.  An empty history is REFUSED rather than reported as zero alerts, because \"no alerts\" is exactly what a quiet model looks like.
366pub async fn risk_search(configuration: &configuration::Configuration, risk_search_in: models::RiskSearchIn) -> Result<models::RiskSearchRun, Error<RiskSearchError>> {
367    // add a prefix to parameters to efficiently prevent name collisions
368    let p_risk_search_in = risk_search_in;
369
370    let uri_str = format!("{}/v1/risk/search", configuration.base_path);
371    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
372
373    if let Some(ref user_agent) = configuration.user_agent {
374        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
375    }
376    if let Some(ref token) = configuration.bearer_access_token {
377        req_builder = req_builder.bearer_auth(token.to_owned());
378    };
379    req_builder = req_builder.json(&p_risk_search_in);
380
381    let req = req_builder.build()?;
382    let resp = configuration.client.execute(req).await?;
383
384    let status = resp.status();
385    let content_type = resp
386        .headers()
387        .get("content-type")
388        .and_then(|v| v.to_str().ok())
389        .unwrap_or("application/octet-stream");
390    let content_type = super::ContentType::from(content_type);
391
392    if !status.is_client_error() && !status.is_server_error() {
393        let content = resp.text().await?;
394        match content_type {
395            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
396            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskSearchRun`"))),
397            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RiskSearchRun`")))),
398        }
399    } else {
400        let content = resp.text().await?;
401        let entity: Option<RiskSearchError> = serde_json::from_str(&content).ok();
402        Err(Error::ResponseError(ResponseContent { status, content, entity }))
403    }
404}
405
406/// Reads back one search run: every shape tried over this organisation's own history, best first, and the one that fit.  A run another organisation started is simply not there — the same 404 an unknown id gives, so the read is not a probe oracle.
407pub async fn risk_search_result(configuration: &configuration::Configuration, id: &str) -> Result<models::RiskSearchReport, Error<RiskSearchResultError>> {
408    // add a prefix to parameters to efficiently prevent name collisions
409    let p_id = id;
410
411    let uri_str = format!("{}/v1/risk/search/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
412    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
413
414    if let Some(ref user_agent) = configuration.user_agent {
415        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
416    }
417    if let Some(ref token) = configuration.bearer_access_token {
418        req_builder = req_builder.bearer_auth(token.to_owned());
419    };
420
421    let req = req_builder.build()?;
422    let resp = configuration.client.execute(req).await?;
423
424    let status = resp.status();
425    let content_type = resp
426        .headers()
427        .get("content-type")
428        .and_then(|v| v.to_str().ok())
429        .unwrap_or("application/octet-stream");
430    let content_type = super::ContentType::from(content_type);
431
432    if !status.is_client_error() && !status.is_server_error() {
433        let content = resp.text().await?;
434        match content_type {
435            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
436            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskSearchReport`"))),
437            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RiskSearchReport`")))),
438        }
439    } else {
440        let content = resp.text().await?;
441        let entity: Option<RiskSearchResultError> = serde_json::from_str(&content).ok();
442        Err(Error::ResponseError(ResponseContent { status, content, entity }))
443    }
444}
445
446/// States the decision regime the caller organisation's model decides under: how much of its own stream may be sent for examination, how much of the rest is sampled to measure what was missed, and whether the model may change an outcome at all.  The appetite is the decision a model is not permitted to make for itself: its output is a probability, so how likely it is to MISS something is a matter of policy that has to be stated, measured and reviewed rather than absorbed into a constant. The alert threshold is derived from it as a quantile of the scores actually observed, which is what keeps its meaning as the distribution drifts.  It is DURABLE BEFORE IT IS IN FORCE. The regime is recorded as a new version on the organisation's own shelf before anything in memory moves, so a policy that cannot be written down is refused rather than answered from state the next rollout would silently undo.  ARMING IS AN ADMIN ACT AND TUNING IS NOT. Setting `live` requires an admin of this organisation; stating the appetite and the sample is self-service for any member. Taking the model live decides whether it may change an OUTCOME at all — a payment frozen, a grant refused — for every customer this organisation has, and that is a decision an organisation takes rather than one of its members.  A RESTATEMENT OF THE REGIME IN FORCE MINTS NOTHING and answers the version already in force. Compare the version you receive with the version you had: unchanged means the numbers were the same, which is why there is no flag for it.  Learned state survives the change. The model's identity covers its SHAPE — the inventory and the geometry — and not its appetite, so restating policy unlearns nothing. It also does not REPORT the learned state: what the model is is read from the model.
447pub async fn risk_set_policy(configuration: &configuration::Configuration, risk_appetite_in: models::RiskAppetiteIn) -> Result<models::RiskPolicyOut, Error<RiskSetPolicyError>> {
448    // add a prefix to parameters to efficiently prevent name collisions
449    let p_risk_appetite_in = risk_appetite_in;
450
451    let uri_str = format!("{}/v1/risk/policy", configuration.base_path);
452    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
453
454    if let Some(ref user_agent) = configuration.user_agent {
455        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
456    }
457    if let Some(ref token) = configuration.bearer_access_token {
458        req_builder = req_builder.bearer_auth(token.to_owned());
459    };
460    req_builder = req_builder.json(&p_risk_appetite_in);
461
462    let req = req_builder.build()?;
463    let resp = configuration.client.execute(req).await?;
464
465    let status = resp.status();
466    let content_type = resp
467        .headers()
468        .get("content-type")
469        .and_then(|v| v.to_str().ok())
470        .unwrap_or("application/octet-stream");
471    let content_type = super::ContentType::from(content_type);
472
473    if !status.is_client_error() && !status.is_server_error() {
474        let content = resp.text().await?;
475        match content_type {
476            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
477            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskPolicyOut`"))),
478            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RiskPolicyOut`")))),
479        }
480    } else {
481        let content = resp.text().await?;
482        let entity: Option<RiskSetPolicyError> = serde_json::from_str(&content).ok();
483        Err(Error::ResponseError(ResponseContent { status, content, entity }))
484    }
485}
486
487/// State reports the caller organisation's own model: what it has learned, whether it is live or still in shadow, the threshold in force, the appetite it stated beside the share it actually realised, every refusal by reason, every feature that read blind, and how much of the organisation's own event surface has been folded in.  It covers ONE organisation. A caller cannot learn another's volumes, alert rate or behaviour from it, because the state is read out of a model that holds only its own.
488pub async fn risk_state(configuration: &configuration::Configuration, ) -> Result<models::RiskModelState, Error<RiskStateError>> {
489
490    let uri_str = format!("{}/v1/risk/state", configuration.base_path);
491    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
492
493    if let Some(ref user_agent) = configuration.user_agent {
494        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
495    }
496    if let Some(ref token) = configuration.bearer_access_token {
497        req_builder = req_builder.bearer_auth(token.to_owned());
498    };
499
500    let req = req_builder.build()?;
501    let resp = configuration.client.execute(req).await?;
502
503    let status = resp.status();
504    let content_type = resp
505        .headers()
506        .get("content-type")
507        .and_then(|v| v.to_str().ok())
508        .unwrap_or("application/octet-stream");
509    let content_type = super::ContentType::from(content_type);
510
511    if !status.is_client_error() && !status.is_server_error() {
512        let content = resp.text().await?;
513        match content_type {
514            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
515            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskModelState`"))),
516            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RiskModelState`")))),
517        }
518    } else {
519        let content = resp.text().await?;
520        let entity: Option<RiskStateError> = serde_json::from_str(&content).ok();
521        Err(Error::ResponseError(ResponseContent { status, content, entity }))
522    }
523}
524