Skip to main content

uarp_sdk/generated/api/
me.rs

1// Code generated by @uarp/codegen from spec/openapi.json. DO NOT EDIT.
2//!
3//! The calling identity: profile, tenants, head agent
4
5#![allow(unused_imports, clippy::too_many_arguments)]
6
7use reqwest::Method;
8use serde::{Deserialize, Serialize};
9
10use crate::client::{Client, Request, NO_BODY, NO_QUERY};
11use crate::error::Result;
12use crate::generated::models;
13use crate::multipart::{field_text, FilePart};
14use crate::util::encode_path;
15
16/// Query and header parameters for `exportMyAccount`.
17#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
18pub struct ExportMyAccountParams {
19    #[serde(default, skip_serializing_if = "Option::is_none")]
20    pub format: Option<models::ExportMyAccountFormat>,
21}
22
23/// The calling identity: profile, tenants, head agent
24#[derive(Debug, Clone)]
25pub struct MeApi {
26    pub(crate) client: Client,
27}
28
29impl Client {
30    /// The calling identity: profile, tenants, head agent
31    pub fn me(&self) -> MeApi {
32        MeApi { client: self.clone() }
33    }
34}
35
36impl MeApi {
37    /// Delete your own account
38    ///
39    /// Self-serve account deletion — the App Store 5.1.1(v) requirement, and the only path to it in
40    /// the mobile clients. Any authenticated member deletes their OWN account: the user record and
41    /// the email-membership index in every tenant the address belongs to, their api keys (the
42    /// per-tenant row AND the global hash, so live sessions die at once), and data tagged with them
43    /// as data subject, erased through the same sweep as `/data-subject/erasure`.
44    ///
45    /// Every refusal is checked across ALL memberships BEFORE anything is deleted, so a half-delete
46    /// cannot happen.
47    ///
48    /// WRITE SEMANTICS: replaces nothing — it removes. A second call answers 404: after a
49    /// successful delete there is no record to delete, which is the honest answer rather than a
50    /// silent success.
51    ///
52    /// `DELETE /api/v1/me`
53    pub async fn delete(&self) -> Result<models::DeleteMeResponse> {
54        self.client
55            .request_json(Request {
56                method: Method::DELETE,
57                path: "/api/v1/me".to_string(),
58                query: NO_QUERY,
59                body: NO_BODY,
60                headers: Vec::new(),
61                idempotent: true,
62            })
63            .await
64    }
65
66    /// Export everything in this account
67    ///
68    /// Chats, projects, memories and the account record. `format=zip` (the default) answers a zip
69    /// attachment; `format=json` answers the same bundle as one document, which is easier to pipe
70    /// and which a browser will show rather than download.
71    ///
72    /// Check `complete`: when a size ceiling is hit the export still succeeds and `omitted` names
73    /// what was left out. A truncated export that does not say so is the failure this field exists
74    /// to prevent.
75    ///
76    /// `GET /api/v1/me/export`
77    pub async fn export_my_account(&self, params: &ExportMyAccountParams) -> Result<models::AccountExport> {
78        self.client
79            .request_json(Request {
80                method: Method::GET,
81                path: "/api/v1/me/export".to_string(),
82                query: Some(params),
83                body: NO_BODY,
84                headers: Vec::new(),
85                idempotent: false,
86            })
87            .await
88    }
89
90    /// Read personal instructions
91    ///
92    /// Requires a credential bound to a person: an API key that carries no user identity is refused
93    /// with 403, because personal instructions belong to the account holder rather than the key.
94    ///
95    /// `GET /api/v1/me/preferences`
96    pub async fn get_my_preferences(&self) -> Result<models::UserPreferences> {
97        self.client
98            .request_json(Request {
99                method: Method::GET,
100                path: "/api/v1/me/preferences".to_string(),
101                query: NO_QUERY,
102                body: NO_BODY,
103                headers: Vec::new(),
104                idempotent: false,
105            })
106            .await
107    }
108
109    /// Set or clear your avatar
110    ///
111    /// The one field a person may change about themselves here: `avatar_url`. It must name a file
112    /// this tenant owns — `/api/v1/files/\<file_id\>/content`, absolute or relative — whose
113    /// `mime_type` is `image/*`; `null` clears it. The change is written to the caller's user row
114    /// in every tenant they belong to (`updated_rows` says how many). Anything else in the body is
115    /// ignored; a body without `avatar_url` is 400. WRITE SEMANTICS: replaces — `avatar_url` is the
116    /// whole writable surface and must be present; there is nothing to merge.
117    ///
118    /// `PATCH /api/v1/me`
119    pub async fn patch(&self, body: &models::PatchMeRequest) -> Result<models::PatchMeResponse> {
120        self.client
121            .request_json(Request {
122                method: Method::PATCH,
123                path: "/api/v1/me".to_string(),
124                query: NO_QUERY,
125                body: Some(body),
126                headers: Vec::new(),
127                idempotent: true,
128            })
129            .await
130    }
131
132    /// Switch the active workspace
133    ///
134    /// Requires a **user session (JWT)**. An API key is refused with 403, because a key is bound to
135    /// the tenant it was created in — create a key inside the target tenant instead. This endpoint
136    /// used to answer `{"switched": true}` for api-key callers and change nothing, which is why the
137    /// refusal is now explicit and documented.
138    ///
139    /// The answer carries the target context; the client re-issues a key through the normal
140    /// post-login flow.
141    ///
142    /// `POST /api/v1/me/tenants/switch`
143    pub async fn switch_tenant(&self, body: &models::SwitchTenantRequest) -> Result<models::SwitchTenantResponse> {
144        self.client
145            .request_json(Request {
146                method: Method::POST,
147                path: "/api/v1/me/tenants/switch".to_string(),
148                query: NO_QUERY,
149                body: Some(body),
150                headers: Vec::new(),
151                idempotent: true,
152            })
153            .await
154    }
155
156    /// Write personal instructions
157    ///
158    /// Both fields are optional; what is sent is merged onto the stored record. Same person-bound
159    /// credential rule as the read.
160    ///
161    /// `PUT /api/v1/me/preferences`
162    pub async fn update_my_preferences(&self, body: &models::UpdateMyPreferencesRequest) -> Result<models::UserPreferences> {
163        self.client
164            .request_json(Request {
165                method: Method::PUT,
166                path: "/api/v1/me/preferences".to_string(),
167                query: NO_QUERY,
168                body: Some(body),
169                headers: Vec::new(),
170                idempotent: true,
171            })
172            .await
173    }
174}