Skip to main content

uarp_sdk/generated/api/
reports.rs

1// Code generated by @uarp/codegen from spec/openapi.json. DO NOT EDIT.
2//!
3//! Content reports — abuse/moderation reporting for authenticated users and anonymous
4//! public-chat visitors, plus the operator inbox
5
6#![allow(unused_imports, clippy::too_many_arguments)]
7
8use reqwest::Method;
9use serde::{Deserialize, Serialize};
10use futures_core::Stream;
11
12use crate::client::{Client, Request, NO_BODY, NO_QUERY};
13use crate::error::Result;
14use crate::generated::models;
15use crate::multipart::{field_text, FilePart};
16use crate::pagination::CursorGuard;
17use crate::util::encode_path;
18
19/// Query and header parameters for `listAllContentReports`.
20#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
21pub struct ListAllContentReportsParams {
22    #[serde(default, skip_serializing_if = "Option::is_none")]
23    pub limit: Option<i64>,
24    #[serde(default, skip_serializing_if = "Option::is_none")]
25    pub cursor: Option<String>,
26}
27
28/// Query and header parameters for `listContentReports`.
29#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
30pub struct ListContentReportsParams {
31    #[serde(default, skip_serializing_if = "Option::is_none")]
32    pub limit: Option<i64>,
33    #[serde(default, skip_serializing_if = "Option::is_none")]
34    pub cursor: Option<String>,
35}
36
37/// Content reports — abuse/moderation reporting for authenticated users and anonymous
38/// public-chat visitors, plus the operator inbox
39#[derive(Debug, Clone)]
40pub struct ReportsApi {
41    pub(crate) client: Client,
42}
43
44impl Client {
45    /// Content reports — abuse/moderation reporting for authenticated users and anonymous
46    /// public-chat visitors, plus the operator inbox
47    pub fn reports(&self) -> ReportsApi {
48        ReportsApi { client: self.clone() }
49    }
50}
51
52impl ReportsApi {
53    /// File a content report
54    ///
55    /// Report a message, session or agent. Available to any authenticated principal — deliberately
56    /// not role- or scope-gated, since reporting abuse must never be blocked by RBAC. Rate limited
57    /// to 10/minute per caller. `self_harm` is still accepted with 202 but raises the operator
58    /// notification to critical priority.
59    ///
60    /// `POST /api/v1/reports`
61    pub async fn create_content_report(&self, body: &models::ContentReportInput) -> Result<models::ContentReportAccepted> {
62        self.client
63            .request_json(Request {
64                method: Method::POST,
65                path: "/api/v1/reports".to_string(),
66                query: NO_QUERY,
67                body: Some(body),
68                headers: Vec::new(),
69                idempotent: true,
70            })
71            .await
72    }
73
74    /// List content reports platform-wide (super-admin)
75    ///
76    /// Every report across every tenant, newest first. A tenant whose agent is the problem must not
77    /// be the only party holding the evidence.
78    ///
79    /// `GET /api/v1/admin/reports`
80    ///
81    /// Required scopes: `admin`.
82    pub async fn list_all_content_reports(&self, params: &ListAllContentReportsParams) -> Result<models::ListAllContentReportsResponse> {
83        self.client
84            .request_json(Request {
85                method: Method::GET,
86                path: "/api/v1/admin/reports".to_string(),
87                query: Some(params),
88                body: NO_BODY,
89                headers: Vec::new(),
90                idempotent: false,
91            })
92            .await
93    }
94
95    /// Stream every item returned by `listAllContentReports`, following the `cursor` cursor until
96    /// the server reports no further pages.
97    pub fn list_all_content_reports_all<'a>(&'a self, params: &'a ListAllContentReportsParams) -> impl Stream<Item = Result<models::ContentReport>> + 'a {
98        async_stream::try_stream! {
99            let mut guard = CursorGuard::new();
100            let mut cursor = params.cursor.clone();
101            loop {
102                let mut page_params = params.clone();
103                page_params.cursor = cursor.clone();
104                let page = self.list_all_content_reports(&page_params).await?;
105                let items = page.items;
106                let was_empty = items.is_empty();
107                for item in items {
108                    yield item;
109                }
110                match guard.advance(page.cursor, Some(page.has_more), was_empty) {
111                    Some(next) => cursor = Some(next),
112                    None => break,
113                }
114            }
115        }
116    }
117
118    /// List content reports for this tenant (admin+)
119    ///
120    /// Moderation queue for the tenant that owns the reported content, newest first. Requires the
121    /// admin role — reports carry reporter free text and there is no moderation duty below admin.
122    ///
123    /// `GET /api/v1/reports`
124    pub async fn list_content_reports(&self, params: &ListContentReportsParams) -> Result<models::ListContentReportsResponse> {
125        self.client
126            .request_json(Request {
127                method: Method::GET,
128                path: "/api/v1/reports".to_string(),
129                query: Some(params),
130                body: NO_BODY,
131                headers: Vec::new(),
132                idempotent: false,
133            })
134            .await
135    }
136
137    /// Stream every item returned by `listContentReports`, following the `cursor` cursor until the
138    /// server reports no further pages.
139    pub fn list_content_reports_all<'a>(&'a self, params: &'a ListContentReportsParams) -> impl Stream<Item = Result<models::ContentReport>> + 'a {
140        async_stream::try_stream! {
141            let mut guard = CursorGuard::new();
142            let mut cursor = params.cursor.clone();
143            loop {
144                let mut page_params = params.clone();
145                page_params.cursor = cursor.clone();
146                let page = self.list_content_reports(&page_params).await?;
147                let items = page.items;
148                let was_empty = items.is_empty();
149                for item in items {
150                    yield item;
151                }
152                match guard.advance(page.cursor, Some(page.has_more), was_empty) {
153                    Some(next) => cursor = Some(next),
154                    None => break,
155                }
156            }
157        }
158    }
159}