/*
* 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 [`accept_workspace_invitation`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AcceptWorkspaceInvitationError {
Status401(models::ApiError),
Status404(models::ApiError),
Status410(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`add_workspace_member`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddWorkspaceMemberError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_workspace`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateWorkspaceError {
Status400(models::ApiError),
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_workspace_invitation`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateWorkspaceInvitationError {
Status401(models::ApiError),
Status402(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_public_invitation`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetPublicInvitationError {
Status404(models::ApiError),
Status410(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_workspace`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetWorkspaceError {
Status401(models::ApiError),
Status403(models::ApiError),
Status404(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_my_workspaces`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListMyWorkspacesError {
Status401(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_workspace_invitations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListWorkspaceInvitationsError {
Status401(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_workspace_members`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListWorkspaceMembersError {
Status401(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`remove_workspace_member`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RemoveWorkspaceMemberError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`revoke_workspace_invitation`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RevokeWorkspaceInvitationError {
Status401(models::ApiError),
Status404(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_workspace`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateWorkspaceError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_workspace_member`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateWorkspaceMemberError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
pub async fn accept_workspace_invitation(configuration: &configuration::Configuration, token: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<AcceptWorkspaceInvitationError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_token = token;
let uri_str = format!("{}/v1/invitations/{token}/accept", configuration.base_path, token=crate::apis::urlencode(p_path_token));
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());
};
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<AcceptWorkspaceInvitationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn add_workspace_member(configuration: &configuration::Configuration, workspace_id: &str, add_workspace_member_request: models::AddWorkspaceMemberRequest) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<AddWorkspaceMemberError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_workspace_id = workspace_id;
let p_body_add_workspace_member_request = add_workspace_member_request;
let uri_str = format!("{}/v1/workspaces/{workspaceId}/members", configuration.base_path, workspaceId=crate::apis::urlencode(p_path_workspace_id));
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_add_workspace_member_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 `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<AddWorkspaceMemberError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_workspace(configuration: &configuration::Configuration, create_workspace_request: models::CreateWorkspaceRequest) -> Result<models::WorkspaceEnvelope, Error<CreateWorkspaceError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_workspace_request = create_workspace_request;
let uri_str = format!("{}/v1/workspaces", 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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_workspace_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::WorkspaceEnvelope`"))),
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::WorkspaceEnvelope`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateWorkspaceError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_workspace_invitation(configuration: &configuration::Configuration, workspace_id: &str, create_workspace_invitation_request: models::CreateWorkspaceInvitationRequest) -> Result<models::WorkspaceInvitation, Error<CreateWorkspaceInvitationError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_workspace_id = workspace_id;
let p_body_create_workspace_invitation_request = create_workspace_invitation_request;
let uri_str = format!("{}/v1/workspaces/{workspaceId}/invitations", configuration.base_path, workspaceId=crate::apis::urlencode(p_path_workspace_id));
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_create_workspace_invitation_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::WorkspaceInvitation`"))),
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::WorkspaceInvitation`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateWorkspaceInvitationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_public_invitation(configuration: &configuration::Configuration, token: &str) -> Result<models::PublicInvitationPayload, Error<GetPublicInvitationError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_token = token;
let uri_str = format!("{}/invitations/{token}", configuration.base_path, token=crate::apis::urlencode(p_path_token));
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::PublicInvitationPayload`"))),
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::PublicInvitationPayload`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetPublicInvitationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_workspace(configuration: &configuration::Configuration, workspace_id: &str) -> Result<models::WorkspaceEnvelope, Error<GetWorkspaceError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_workspace_id = workspace_id;
let uri_str = format!("{}/v1/workspaces/{workspaceId}", configuration.base_path, workspaceId=crate::apis::urlencode(p_path_workspace_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 `models::WorkspaceEnvelope`"))),
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::WorkspaceEnvelope`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetWorkspaceError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn list_my_workspaces(configuration: &configuration::Configuration, ) -> Result<models::WorkspaceListResponse, Error<ListMyWorkspacesError>> {
let uri_str = format!("{}/v1/workspaces", 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::WorkspaceListResponse`"))),
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::WorkspaceListResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListMyWorkspacesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn list_workspace_invitations(configuration: &configuration::Configuration, workspace_id: &str) -> Result<models::WorkspaceInvitationListResponse, Error<ListWorkspaceInvitationsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_workspace_id = workspace_id;
let uri_str = format!("{}/v1/workspaces/{workspaceId}/invitations", configuration.base_path, workspaceId=crate::apis::urlencode(p_path_workspace_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 `models::WorkspaceInvitationListResponse`"))),
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::WorkspaceInvitationListResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListWorkspaceInvitationsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn list_workspace_members(configuration: &configuration::Configuration, workspace_id: &str) -> Result<models::WorkspaceMemberListResponse, Error<ListWorkspaceMembersError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_workspace_id = workspace_id;
let uri_str = format!("{}/v1/workspaces/{workspaceId}/members", configuration.base_path, workspaceId=crate::apis::urlencode(p_path_workspace_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 `models::WorkspaceMemberListResponse`"))),
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::WorkspaceMemberListResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListWorkspaceMembersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn remove_workspace_member(configuration: &configuration::Configuration, workspace_id: &str, member_id: &str) -> Result<(), Error<RemoveWorkspaceMemberError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_workspace_id = workspace_id;
let p_path_member_id = member_id;
let uri_str = format!("{}/v1/workspaces/{workspaceId}/members/{memberId}", configuration.base_path, workspaceId=crate::apis::urlencode(p_path_workspace_id), memberId=crate::apis::urlencode(p_path_member_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<RemoveWorkspaceMemberError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn revoke_workspace_invitation(configuration: &configuration::Configuration, workspace_id: &str, invitation_id: &str) -> Result<(), Error<RevokeWorkspaceInvitationError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_workspace_id = workspace_id;
let p_path_invitation_id = invitation_id;
let uri_str = format!("{}/v1/workspaces/{workspaceId}/invitations/{invitationId}", configuration.base_path, workspaceId=crate::apis::urlencode(p_path_workspace_id), invitationId=crate::apis::urlencode(p_path_invitation_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<RevokeWorkspaceInvitationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn update_workspace(configuration: &configuration::Configuration, workspace_id: &str, update_workspace_request: models::UpdateWorkspaceRequest) -> Result<models::WorkspaceEnvelope, Error<UpdateWorkspaceError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_workspace_id = workspace_id;
let p_body_update_workspace_request = update_workspace_request;
let uri_str = format!("{}/v1/workspaces/{workspaceId}", configuration.base_path, workspaceId=crate::apis::urlencode(p_path_workspace_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_update_workspace_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::WorkspaceEnvelope`"))),
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::WorkspaceEnvelope`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateWorkspaceError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn update_workspace_member(configuration: &configuration::Configuration, workspace_id: &str, member_id: &str, update_workspace_member_request: models::UpdateWorkspaceMemberRequest) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<UpdateWorkspaceMemberError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_workspace_id = workspace_id;
let p_path_member_id = member_id;
let p_body_update_workspace_member_request = update_workspace_member_request;
let uri_str = format!("{}/v1/workspaces/{workspaceId}/members/{memberId}", configuration.base_path, workspaceId=crate::apis::urlencode(p_path_workspace_id), memberId=crate::apis::urlencode(p_path_member_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_update_workspace_member_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 `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<UpdateWorkspaceMemberError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}