Skip to main content

spatio_sdk/apis/
sheets_api.rs

1/*
2 * SpatioAPI
3 *
4 * The REST API that owns every resource in your Spatio workspace: notes, sheets, slides, tasks, calendar events, mail, chat, files, and contacts. SpatioMCP wraps this API; Spatio Desktop reads from it. You can call it directly from your own code.  All requests must be authenticated with a Personal Access Token (`Authorization: Bearer pat_...`) or an OAuth 2.1 access token, and use HTTPS.  Official SDKs (MIT, generated from this spec on every release):  - TypeScript: https://github.com/spatio-labs/spatio-ts (`npm install @spatio-labs/spatio-ts`) - Python: https://github.com/spatio-labs/spatio-py (`pip install spatio-sdk`) - Go: https://github.com/spatio-labs/spatio-go (`go get github.com/spatio-labs/spatio-go`)  This specification is generated from the platform-service Go source on every push to `main`. The spec, not hand-written documentation, is the source of truth: server stubs and SDKs are generated from it, and any drift between the spec and the running service fails CI. 
5 *
6 * The version of the OpenAPI document: v1
7 * Contact: hello@spatio.app
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 [`create_sheet`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateSheetError {
22    Status400(models::CreateNote400Response),
23    Status401(models::ApiError),
24    Status500(models::ApiError),
25    UnknownValue(serde_json::Value),
26}
27
28/// struct for typed errors of method [`create_sheet_row`]
29#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum CreateSheetRowError {
32    Status400(models::ApiError),
33    Status401(models::ApiError),
34    Status404(models::ApiError),
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method [`delete_sheet`]
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum DeleteSheetError {
42    Status401(models::ApiError),
43    Status404(models::ApiError),
44    UnknownValue(serde_json::Value),
45}
46
47/// struct for typed errors of method [`delete_sheet_row`]
48#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(untagged)]
50pub enum DeleteSheetRowError {
51    Status400(models::ApiError),
52    Status401(models::ApiError),
53    Status404(models::ApiError),
54    UnknownValue(serde_json::Value),
55}
56
57/// struct for typed errors of method [`get_sheet`]
58#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(untagged)]
60pub enum GetSheetError {
61    Status400(models::CreateNote400Response),
62    Status401(models::ApiError),
63    Status404(models::ApiError),
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`list_sheet_rows`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum ListSheetRowsError {
71    Status401(models::ApiError),
72    Status404(models::ApiError),
73    UnknownValue(serde_json::Value),
74}
75
76/// struct for typed errors of method [`list_sheets`]
77#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum ListSheetsError {
80    Status401(models::ApiError),
81    Status500(models::ApiError),
82    UnknownValue(serde_json::Value),
83}
84
85/// struct for typed errors of method [`update_sheet`]
86#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum UpdateSheetError {
89    Status400(models::ApiError),
90    Status401(models::ApiError),
91    Status404(models::ApiError),
92    UnknownValue(serde_json::Value),
93}
94
95/// struct for typed errors of method [`update_sheet_cell`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum UpdateSheetCellError {
99    Status400(models::ApiError),
100    Status401(models::ApiError),
101    Status404(models::ApiError),
102    UnknownValue(serde_json::Value),
103}
104
105/// struct for typed errors of method [`update_sheet_row`]
106#[derive(Debug, Clone, Serialize, Deserialize)]
107#[serde(untagged)]
108pub enum UpdateSheetRowError {
109    Status400(models::ApiError),
110    Status401(models::ApiError),
111    Status404(models::ApiError),
112    UnknownValue(serde_json::Value),
113}
114
115
116/// Creates a new sheet under the target account. Target resolution mirrors `POST /v1/notes`: body `accountId` → `?accountId=` → body `provider` → `?provider=` → caller's single connected account (errors with `ambiguous_account` if more than one is connected and no selector is supplied). 
117pub async fn create_sheet(configuration: &configuration::Configuration, create_sheet_request: models::CreateSheetRequest, account_id: Option<&str>, provider: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::Sheet, Error<CreateSheetError>> {
118    // add a prefix to parameters to efficiently prevent name collisions
119    let p_body_create_sheet_request = create_sheet_request;
120    let p_query_account_id = account_id;
121    let p_query_provider = provider;
122    let p_header_x_workspace_id = x_workspace_id;
123
124    let uri_str = format!("{}/v1/sheets", configuration.base_path);
125    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
126
127    if let Some(ref param_value) = p_query_account_id {
128        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
129    }
130    if let Some(ref param_value) = p_query_provider {
131        req_builder = req_builder.query(&[("provider", &param_value.to_string())]);
132    }
133    if let Some(ref user_agent) = configuration.user_agent {
134        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
135    }
136    if let Some(param_value) = p_header_x_workspace_id {
137        req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
138    }
139    if let Some(ref token) = configuration.bearer_access_token {
140        req_builder = req_builder.bearer_auth(token.to_owned());
141    };
142    req_builder = req_builder.json(&p_body_create_sheet_request);
143
144    let req = req_builder.build()?;
145    let resp = configuration.client.execute(req).await?;
146
147    let status = resp.status();
148    let content_type = resp
149        .headers()
150        .get("content-type")
151        .and_then(|v| v.to_str().ok())
152        .unwrap_or("application/octet-stream");
153    let content_type = super::ContentType::from(content_type);
154
155    if !status.is_client_error() && !status.is_server_error() {
156        let content = resp.text().await?;
157        match content_type {
158            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
159            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Sheet`"))),
160            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::Sheet`")))),
161        }
162    } else {
163        let content = resp.text().await?;
164        let entity: Option<CreateSheetError> = serde_json::from_str(&content).ok();
165        Err(Error::ResponseError(ResponseContent { status, content, entity }))
166    }
167}
168
169/// Inserts a row at `index` (zero-based) or appends to the end when `index` is omitted. 
170pub async fn create_sheet_row(configuration: &configuration::Configuration, id: &str, create_row_request: models::CreateRowRequest, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::Row, Error<CreateSheetRowError>> {
171    // add a prefix to parameters to efficiently prevent name collisions
172    let p_path_id = id;
173    let p_body_create_row_request = create_row_request;
174    let p_query_account_id = account_id;
175    let p_header_x_workspace_id = x_workspace_id;
176
177    let uri_str = format!("{}/v1/sheets/{id}/rows", configuration.base_path, id=crate::apis::urlencode(p_path_id));
178    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
179
180    if let Some(ref param_value) = p_query_account_id {
181        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
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(param_value) = p_header_x_workspace_id {
187        req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
188    }
189    if let Some(ref token) = configuration.bearer_access_token {
190        req_builder = req_builder.bearer_auth(token.to_owned());
191    };
192    req_builder = req_builder.json(&p_body_create_row_request);
193
194    let req = req_builder.build()?;
195    let resp = configuration.client.execute(req).await?;
196
197    let status = resp.status();
198    let content_type = resp
199        .headers()
200        .get("content-type")
201        .and_then(|v| v.to_str().ok())
202        .unwrap_or("application/octet-stream");
203    let content_type = super::ContentType::from(content_type);
204
205    if !status.is_client_error() && !status.is_server_error() {
206        let content = resp.text().await?;
207        match content_type {
208            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
209            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Row`"))),
210            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::Row`")))),
211        }
212    } else {
213        let content = resp.text().await?;
214        let entity: Option<CreateSheetRowError> = serde_json::from_str(&content).ok();
215        Err(Error::ResponseError(ResponseContent { status, content, entity }))
216    }
217}
218
219pub async fn delete_sheet(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::SuccessFlag, Error<DeleteSheetError>> {
220    // add a prefix to parameters to efficiently prevent name collisions
221    let p_path_id = id;
222    let p_query_account_id = account_id;
223    let p_header_x_workspace_id = x_workspace_id;
224
225    let uri_str = format!("{}/v1/sheets/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
226    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
227
228    if let Some(ref param_value) = p_query_account_id {
229        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
230    }
231    if let Some(ref user_agent) = configuration.user_agent {
232        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
233    }
234    if let Some(param_value) = p_header_x_workspace_id {
235        req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
236    }
237    if let Some(ref token) = configuration.bearer_access_token {
238        req_builder = req_builder.bearer_auth(token.to_owned());
239    };
240
241    let req = req_builder.build()?;
242    let resp = configuration.client.execute(req).await?;
243
244    let status = resp.status();
245    let content_type = resp
246        .headers()
247        .get("content-type")
248        .and_then(|v| v.to_str().ok())
249        .unwrap_or("application/octet-stream");
250    let content_type = super::ContentType::from(content_type);
251
252    if !status.is_client_error() && !status.is_server_error() {
253        let content = resp.text().await?;
254        match content_type {
255            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
256            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessFlag`"))),
257            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::SuccessFlag`")))),
258        }
259    } else {
260        let content = resp.text().await?;
261        let entity: Option<DeleteSheetError> = serde_json::from_str(&content).ok();
262        Err(Error::ResponseError(ResponseContent { status, content, entity }))
263    }
264}
265
266pub async fn delete_sheet_row(configuration: &configuration::Configuration, id: &str, row_index: i32, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::SuccessFlag, Error<DeleteSheetRowError>> {
267    // add a prefix to parameters to efficiently prevent name collisions
268    let p_path_id = id;
269    let p_path_row_index = row_index;
270    let p_query_account_id = account_id;
271    let p_header_x_workspace_id = x_workspace_id;
272
273    let uri_str = format!("{}/v1/sheets/{id}/rows/{rowIndex}", configuration.base_path, id=crate::apis::urlencode(p_path_id), rowIndex=p_path_row_index);
274    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
275
276    if let Some(ref param_value) = p_query_account_id {
277        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
278    }
279    if let Some(ref user_agent) = configuration.user_agent {
280        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
281    }
282    if let Some(param_value) = p_header_x_workspace_id {
283        req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
284    }
285    if let Some(ref token) = configuration.bearer_access_token {
286        req_builder = req_builder.bearer_auth(token.to_owned());
287    };
288
289    let req = req_builder.build()?;
290    let resp = configuration.client.execute(req).await?;
291
292    let status = resp.status();
293    let content_type = resp
294        .headers()
295        .get("content-type")
296        .and_then(|v| v.to_str().ok())
297        .unwrap_or("application/octet-stream");
298    let content_type = super::ContentType::from(content_type);
299
300    if !status.is_client_error() && !status.is_server_error() {
301        let content = resp.text().await?;
302        match content_type {
303            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
304            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessFlag`"))),
305            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::SuccessFlag`")))),
306        }
307    } else {
308        let content = resp.text().await?;
309        let entity: Option<DeleteSheetRowError> = serde_json::from_str(&content).ok();
310        Err(Error::ResponseError(ResponseContent { status, content, entity }))
311    }
312}
313
314pub async fn get_sheet(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::Sheet, Error<GetSheetError>> {
315    // add a prefix to parameters to efficiently prevent name collisions
316    let p_path_id = id;
317    let p_query_account_id = account_id;
318    let p_header_x_workspace_id = x_workspace_id;
319
320    let uri_str = format!("{}/v1/sheets/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
321    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
322
323    if let Some(ref param_value) = p_query_account_id {
324        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
325    }
326    if let Some(ref user_agent) = configuration.user_agent {
327        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
328    }
329    if let Some(param_value) = p_header_x_workspace_id {
330        req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
331    }
332    if let Some(ref token) = configuration.bearer_access_token {
333        req_builder = req_builder.bearer_auth(token.to_owned());
334    };
335
336    let req = req_builder.build()?;
337    let resp = configuration.client.execute(req).await?;
338
339    let status = resp.status();
340    let content_type = resp
341        .headers()
342        .get("content-type")
343        .and_then(|v| v.to_str().ok())
344        .unwrap_or("application/octet-stream");
345    let content_type = super::ContentType::from(content_type);
346
347    if !status.is_client_error() && !status.is_server_error() {
348        let content = resp.text().await?;
349        match content_type {
350            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
351            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Sheet`"))),
352            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::Sheet`")))),
353        }
354    } else {
355        let content = resp.text().await?;
356        let entity: Option<GetSheetError> = serde_json::from_str(&content).ok();
357        Err(Error::ResponseError(ResponseContent { status, content, entity }))
358    }
359}
360
361/// Single-account row list. Unlike `GET /v1/sheets`, row listing always targets the one account that owns the sheet, so the response is a plain `{ rows, total }` rather than a fan-out envelope. 
362pub async fn list_sheet_rows(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>, limit: Option<i32>, offset: Option<i32>) -> Result<models::RowList, Error<ListSheetRowsError>> {
363    // add a prefix to parameters to efficiently prevent name collisions
364    let p_path_id = id;
365    let p_query_account_id = account_id;
366    let p_header_x_workspace_id = x_workspace_id;
367    let p_query_limit = limit;
368    let p_query_offset = offset;
369
370    let uri_str = format!("{}/v1/sheets/{id}/rows", configuration.base_path, id=crate::apis::urlencode(p_path_id));
371    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
372
373    if let Some(ref param_value) = p_query_account_id {
374        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
375    }
376    if let Some(ref param_value) = p_query_limit {
377        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
378    }
379    if let Some(ref param_value) = p_query_offset {
380        req_builder = req_builder.query(&[("offset", &param_value.to_string())]);
381    }
382    if let Some(ref user_agent) = configuration.user_agent {
383        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
384    }
385    if let Some(param_value) = p_header_x_workspace_id {
386        req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
387    }
388    if let Some(ref token) = configuration.bearer_access_token {
389        req_builder = req_builder.bearer_auth(token.to_owned());
390    };
391
392    let req = req_builder.build()?;
393    let resp = configuration.client.execute(req).await?;
394
395    let status = resp.status();
396    let content_type = resp
397        .headers()
398        .get("content-type")
399        .and_then(|v| v.to_str().ok())
400        .unwrap_or("application/octet-stream");
401    let content_type = super::ContentType::from(content_type);
402
403    if !status.is_client_error() && !status.is_server_error() {
404        let content = resp.text().await?;
405        match content_type {
406            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
407            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RowList`"))),
408            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::RowList`")))),
409        }
410    } else {
411        let content = resp.text().await?;
412        let entity: Option<ListSheetRowsError> = serde_json::from_str(&content).ok();
413        Err(Error::ResponseError(ResponseContent { status, content, entity }))
414    }
415}
416
417/// Fan-out list. Returns every sheet visible to the caller across every connected sheets provider, paginated by `limit` / `offset`. Pass `?accountId=` or `?provider=` to scope to a single source. 
418pub async fn list_sheets(configuration: &configuration::Configuration, account_id: Option<&str>, provider: Option<&str>, x_workspace_id: Option<&str>, limit: Option<i32>, offset: Option<i32>) -> Result<models::SheetListEnvelope, Error<ListSheetsError>> {
419    // add a prefix to parameters to efficiently prevent name collisions
420    let p_query_account_id = account_id;
421    let p_query_provider = provider;
422    let p_header_x_workspace_id = x_workspace_id;
423    let p_query_limit = limit;
424    let p_query_offset = offset;
425
426    let uri_str = format!("{}/v1/sheets", configuration.base_path);
427    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
428
429    if let Some(ref param_value) = p_query_account_id {
430        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
431    }
432    if let Some(ref param_value) = p_query_provider {
433        req_builder = req_builder.query(&[("provider", &param_value.to_string())]);
434    }
435    if let Some(ref param_value) = p_query_limit {
436        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
437    }
438    if let Some(ref param_value) = p_query_offset {
439        req_builder = req_builder.query(&[("offset", &param_value.to_string())]);
440    }
441    if let Some(ref user_agent) = configuration.user_agent {
442        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
443    }
444    if let Some(param_value) = p_header_x_workspace_id {
445        req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
446    }
447    if let Some(ref token) = configuration.bearer_access_token {
448        req_builder = req_builder.bearer_auth(token.to_owned());
449    };
450
451    let req = req_builder.build()?;
452    let resp = configuration.client.execute(req).await?;
453
454    let status = resp.status();
455    let content_type = resp
456        .headers()
457        .get("content-type")
458        .and_then(|v| v.to_str().ok())
459        .unwrap_or("application/octet-stream");
460    let content_type = super::ContentType::from(content_type);
461
462    if !status.is_client_error() && !status.is_server_error() {
463        let content = resp.text().await?;
464        match content_type {
465            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
466            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SheetListEnvelope`"))),
467            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::SheetListEnvelope`")))),
468        }
469    } else {
470        let content = resp.text().await?;
471        let entity: Option<ListSheetsError> = serde_json::from_str(&content).ok();
472        Err(Error::ResponseError(ResponseContent { status, content, entity }))
473    }
474}
475
476/// Partial update of sheet metadata. The renderer also calls this via `PUT /v1/sheets/{id}` for autosave parity; both verbs invoke the same handler. Per-cell and per-row mutations live on their dedicated endpoints, not here. 
477pub async fn update_sheet(configuration: &configuration::Configuration, id: &str, update_sheet_request: models::UpdateSheetRequest, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::Sheet, Error<UpdateSheetError>> {
478    // add a prefix to parameters to efficiently prevent name collisions
479    let p_path_id = id;
480    let p_body_update_sheet_request = update_sheet_request;
481    let p_query_account_id = account_id;
482    let p_header_x_workspace_id = x_workspace_id;
483
484    let uri_str = format!("{}/v1/sheets/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
485    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
486
487    if let Some(ref param_value) = p_query_account_id {
488        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
489    }
490    if let Some(ref user_agent) = configuration.user_agent {
491        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
492    }
493    if let Some(param_value) = p_header_x_workspace_id {
494        req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
495    }
496    if let Some(ref token) = configuration.bearer_access_token {
497        req_builder = req_builder.bearer_auth(token.to_owned());
498    };
499    req_builder = req_builder.json(&p_body_update_sheet_request);
500
501    let req = req_builder.build()?;
502    let resp = configuration.client.execute(req).await?;
503
504    let status = resp.status();
505    let content_type = resp
506        .headers()
507        .get("content-type")
508        .and_then(|v| v.to_str().ok())
509        .unwrap_or("application/octet-stream");
510    let content_type = super::ContentType::from(content_type);
511
512    if !status.is_client_error() && !status.is_server_error() {
513        let content = resp.text().await?;
514        match content_type {
515            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
516            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Sheet`"))),
517            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::Sheet`")))),
518        }
519    } else {
520        let content = resp.text().await?;
521        let entity: Option<UpdateSheetError> = serde_json::from_str(&content).ok();
522        Err(Error::ResponseError(ResponseContent { status, content, entity }))
523    }
524}
525
526pub async fn update_sheet_cell(configuration: &configuration::Configuration, id: &str, row_index: i32, column: &str, update_cell_request: models::UpdateCellRequest, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::Cell, Error<UpdateSheetCellError>> {
527    // add a prefix to parameters to efficiently prevent name collisions
528    let p_path_id = id;
529    let p_path_row_index = row_index;
530    let p_path_column = column;
531    let p_body_update_cell_request = update_cell_request;
532    let p_query_account_id = account_id;
533    let p_header_x_workspace_id = x_workspace_id;
534
535    let uri_str = format!("{}/v1/sheets/{id}/rows/{rowIndex}/cells/{column}", configuration.base_path, id=crate::apis::urlencode(p_path_id), rowIndex=p_path_row_index, column=crate::apis::urlencode(p_path_column));
536    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
537
538    if let Some(ref param_value) = p_query_account_id {
539        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
540    }
541    if let Some(ref user_agent) = configuration.user_agent {
542        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
543    }
544    if let Some(param_value) = p_header_x_workspace_id {
545        req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
546    }
547    if let Some(ref token) = configuration.bearer_access_token {
548        req_builder = req_builder.bearer_auth(token.to_owned());
549    };
550    req_builder = req_builder.json(&p_body_update_cell_request);
551
552    let req = req_builder.build()?;
553    let resp = configuration.client.execute(req).await?;
554
555    let status = resp.status();
556    let content_type = resp
557        .headers()
558        .get("content-type")
559        .and_then(|v| v.to_str().ok())
560        .unwrap_or("application/octet-stream");
561    let content_type = super::ContentType::from(content_type);
562
563    if !status.is_client_error() && !status.is_server_error() {
564        let content = resp.text().await?;
565        match content_type {
566            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
567            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Cell`"))),
568            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::Cell`")))),
569        }
570    } else {
571        let content = resp.text().await?;
572        let entity: Option<UpdateSheetCellError> = serde_json::from_str(&content).ok();
573        Err(Error::ResponseError(ResponseContent { status, content, entity }))
574    }
575}
576
577/// Sparse update — keys present in `cells` overwrite that column; keys absent are preserved. 
578pub async fn update_sheet_row(configuration: &configuration::Configuration, id: &str, row_index: i32, update_row_request: models::UpdateRowRequest, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::Row, Error<UpdateSheetRowError>> {
579    // add a prefix to parameters to efficiently prevent name collisions
580    let p_path_id = id;
581    let p_path_row_index = row_index;
582    let p_body_update_row_request = update_row_request;
583    let p_query_account_id = account_id;
584    let p_header_x_workspace_id = x_workspace_id;
585
586    let uri_str = format!("{}/v1/sheets/{id}/rows/{rowIndex}", configuration.base_path, id=crate::apis::urlencode(p_path_id), rowIndex=p_path_row_index);
587    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
588
589    if let Some(ref param_value) = p_query_account_id {
590        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
591    }
592    if let Some(ref user_agent) = configuration.user_agent {
593        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
594    }
595    if let Some(param_value) = p_header_x_workspace_id {
596        req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
597    }
598    if let Some(ref token) = configuration.bearer_access_token {
599        req_builder = req_builder.bearer_auth(token.to_owned());
600    };
601    req_builder = req_builder.json(&p_body_update_row_request);
602
603    let req = req_builder.build()?;
604    let resp = configuration.client.execute(req).await?;
605
606    let status = resp.status();
607    let content_type = resp
608        .headers()
609        .get("content-type")
610        .and_then(|v| v.to_str().ok())
611        .unwrap_or("application/octet-stream");
612    let content_type = super::ContentType::from(content_type);
613
614    if !status.is_client_error() && !status.is_server_error() {
615        let content = resp.text().await?;
616        match content_type {
617            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
618            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Row`"))),
619            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::Row`")))),
620        }
621    } else {
622        let content = resp.text().await?;
623        let entity: Option<UpdateSheetRowError> = serde_json::from_str(&content).ok();
624        Err(Error::ResponseError(ResponseContent { status, content, entity }))
625    }
626}
627