/*
* SpatioAPI
*
* 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.
*
* The version of the OpenAPI document: v1
* Contact: hello@spatio.app
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for typed errors of method [`create_calendar_event`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCalendarEventError {
Status400(models::ApiError),
Status401(models::ApiError),
Status500(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_calendar_event`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCalendarEventError {
Status400(models::ApiError),
Status401(models::ApiError),
Status404(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_calendar_capabilities`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCalendarCapabilitiesError {
Status400(models::ApiError),
Status401(models::ApiError),
Status404(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_calendar_event`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCalendarEventError {
Status400(models::ApiError),
Status401(models::ApiError),
Status404(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_calendar_events`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCalendarEventsError {
Status401(models::ApiError),
Status500(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_calendar_providers`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCalendarProvidersError {
Status401(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`sync_calendar`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SyncCalendarError {
Status401(models::ApiError),
Status503(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_calendar_event`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCalendarEventError {
Status400(models::ApiError),
Status401(models::ApiError),
Status404(models::ApiError),
Status500(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`workspace_create_calendar_event`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WorkspaceCreateCalendarEventError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`workspace_delete_calendar_event`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WorkspaceDeleteCalendarEventError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`workspace_get_calendar_event`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WorkspaceGetCalendarEventError {
Status401(models::ApiError),
Status403(models::ApiError),
Status404(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`workspace_list_calendar_events`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WorkspaceListCalendarEventsError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`workspace_list_calendar_providers`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WorkspaceListCalendarProvidersError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`workspace_update_calendar_event`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WorkspaceUpdateCalendarEventError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// Single-account create. `account_id` is required (no auto-resolve for write operations). Reminder array is mirrored into native tasks under the hood; conference data is auto-attached when `conference_type` is supplied.
pub async fn create_calendar_event(configuration: &configuration::Configuration, create_event_request: models::CreateEventRequest, x_workspace_id: Option<&str>) -> Result<models::CreateCalendarEvent201Response, Error<CreateCalendarEventError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_event_request = create_event_request;
let p_header_x_workspace_id = x_workspace_id;
let uri_str = format!("{}/v1/calendar/events", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_x_workspace_id {
req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_event_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateCalendarEvent201Response`"))),
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::CreateCalendarEvent201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Hard delete (no soft-delete / trash). Cascades to any reminder tasks the platform created from this event.
pub async fn delete_calendar_event(configuration: &configuration::Configuration, id: &str, account_id: &str, x_workspace_id: Option<&str>) -> Result<models::CalendarOperationResult, Error<DeleteCalendarEventError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_id = id;
let p_query_account_id = account_id;
let p_header_x_workspace_id = x_workspace_id;
let uri_str = format!("{}/v1/calendar/events/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
req_builder = req_builder.query(&[("account_id", &p_query_account_id.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_x_workspace_id {
req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CalendarOperationResult`"))),
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::CalendarOperationResult`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Returns the capabilities the provider declares for the given connected account. The renderer uses these to enable/disable form fields (recurrence picker, attendee inputs, etc.).
pub async fn get_calendar_capabilities(configuration: &configuration::Configuration, account_id: &str) -> Result<models::CalendarCapabilitiesResponse, Error<GetCalendarCapabilitiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let uri_str = format!("{}/v1/calendar/capabilities", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("account_id", &p_query_account_id.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CalendarCapabilitiesResponse`"))),
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::CalendarCapabilitiesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCalendarCapabilitiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Requires `?account_id=` to identify the source account. Response is the bare `Event` (not wrapped in CalendarOperationResult — distinct from the list/create/update shapes).
pub async fn get_calendar_event(configuration: &configuration::Configuration, id: &str, account_id: &str, x_workspace_id: Option<&str>) -> Result<models::SpatioEvent, Error<GetCalendarEventError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_id = id;
let p_query_account_id = account_id;
let p_header_x_workspace_id = x_workspace_id;
let uri_str = format!("{}/v1/calendar/events/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("account_id", &p_query_account_id.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_x_workspace_id {
req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpatioEvent`"))),
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::SpatioEvent`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Fan-out list. Returns events across every connected calendar provider unless filtered by `account_ids[]` or `providers[]`. Supports the cross-platform repeated-or-comma-separated filter syntax (`?account_ids=a&account_ids=b` or `?account_ids=a,b`). Time bounds (`timeMin` / `timeMax`) accept both RFC3339 and RFC3339Nano. The handler also accepts the snake_case `time_min` / `time_max` for direct curl callers; the spec models the camelCase form because that's what the renderer and SDKs use.
pub async fn list_calendar_events(configuration: &configuration::Configuration, account_ids: Option<Vec<String>>, providers: Option<Vec<String>>, x_workspace_id: Option<&str>, time_min: Option<chrono::DateTime<chrono::FixedOffset>>, time_max: Option<chrono::DateTime<chrono::FixedOffset>>, limit: Option<i32>) -> Result<models::ListCalendarEvents200Response, Error<ListCalendarEventsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_ids = account_ids;
let p_query_providers = providers;
let p_header_x_workspace_id = x_workspace_id;
let p_query_time_min = time_min;
let p_query_time_max = time_max;
let p_query_limit = limit;
let uri_str = format!("{}/v1/calendar/events", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_account_ids {
req_builder = match "multi" {
"multi" => req_builder.query(¶m_value.into_iter().map(|p| ("account_ids".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => req_builder.query(&[("account_ids", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref param_value) = p_query_providers {
req_builder = match "multi" {
"multi" => req_builder.query(¶m_value.into_iter().map(|p| ("providers".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => req_builder.query(&[("providers", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref param_value) = p_query_time_min {
req_builder = req_builder.query(&[("timeMin", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_time_max {
req_builder = req_builder.query(&[("timeMax", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_x_workspace_id {
req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListCalendarEvents200Response`"))),
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::ListCalendarEvents200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCalendarEventsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Static list of provider ids the Calendar platform can connect to. Returned regardless of which providers the caller has actually authorized.
pub async fn list_calendar_providers(configuration: &configuration::Configuration, ) -> Result<models::CalendarProvidersInfo, Error<ListCalendarProvidersError>> {
let uri_str = format!("{}/v1/calendar/providers", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CalendarProvidersInfo`"))),
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::CalendarProvidersInfo`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCalendarProvidersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Enqueues sync jobs (one per connected calendar account) and returns immediately with the job ids. Pass `?wait=true` to block until all jobs complete (10-second polling budget); the response is then `200` with `waited: true` and a `timed_out` flag if any job didn't finish in time.
pub async fn sync_calendar(configuration: &configuration::Configuration, wait: Option<bool>) -> Result<models::CalendarSyncResponse, Error<SyncCalendarError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_wait = wait;
let uri_str = format!("{}/v1/calendar/sync", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_wait {
req_builder = req_builder.query(&[("wait", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CalendarSyncResponse`"))),
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::CalendarSyncResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SyncCalendarError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Partial update. `account_id` may be supplied in the body (preferred) or as `?account_id=` query param — the renderer's update path puts it in the URL while create puts it in the body. `updates` is a free-form map; the platform's capability gate rejects fields the provider doesn't support.
pub async fn update_calendar_event(configuration: &configuration::Configuration, id: &str, update_event_request: models::UpdateEventRequest, x_workspace_id: Option<&str>, account_id: Option<&str>) -> Result<models::CreateCalendarEvent201Response, Error<UpdateCalendarEventError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_id = id;
let p_body_update_event_request = update_event_request;
let p_header_x_workspace_id = x_workspace_id;
let p_query_account_id = account_id;
let uri_str = format!("{}/v1/calendar/events/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("account_id", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_x_workspace_id {
req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_event_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateCalendarEvent201Response`"))),
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::CreateCalendarEvent201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn workspace_create_calendar_event(configuration: &configuration::Configuration, org: &str, workspace: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceCreateCalendarEventError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_org = org;
let p_path_workspace = workspace;
let p_body_request_body = request_body;
let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/calendar/events", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_request_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<WorkspaceCreateCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn workspace_delete_calendar_event(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<(), Error<WorkspaceDeleteCalendarEventError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_org = org;
let p_path_workspace = workspace;
let p_path_id = id;
let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/calendar/events/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<WorkspaceDeleteCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn workspace_get_calendar_event(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceGetCalendarEventError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_org = org;
let p_path_workspace = workspace;
let p_path_id = id;
let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/calendar/events/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<WorkspaceGetCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn workspace_list_calendar_events(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListCalendarEventsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_org = org;
let p_path_workspace = workspace;
let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/calendar/events", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<WorkspaceListCalendarEventsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn workspace_list_calendar_providers(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListCalendarProvidersError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_org = org;
let p_path_workspace = workspace;
let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/calendar/providers", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<WorkspaceListCalendarProvidersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn workspace_update_calendar_event(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceUpdateCalendarEventError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_org = org;
let p_path_workspace = workspace;
let p_path_id = id;
let p_body_request_body = request_body;
let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/calendar/events/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_request_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<WorkspaceUpdateCalendarEventError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}