/*
* 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 [`bulk_delete_tasks`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BulkDeleteTasksError {
Status400(models::ApiError),
Status401(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`bulk_update_tasks`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BulkUpdateTasksError {
Status400(models::ApiError),
Status401(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`complete_task`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CompleteTaskError {
Status401(models::ApiError),
Status404(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_task`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateTaskError {
Status400(models::CreateNote400Response),
Status401(models::ApiError),
Status500(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_task_comment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateTaskCommentError {
Status400(models::ApiError),
Status401(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_task`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteTaskError {
Status401(models::ApiError),
Status404(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_task_comment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteTaskCommentError {
Status400(models::ApiError),
Status401(models::ApiError),
Status403(models::ApiError),
Status404(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_task`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetTaskError {
Status400(models::CreateNote400Response),
Status401(models::ApiError),
Status404(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_task_comments`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListTaskCommentsError {
Status400(models::ApiError),
Status401(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_task_providers`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListTaskProvidersError {
Status401(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_tasks`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListTasksError {
Status401(models::ApiError),
Status500(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_task`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateTaskError {
Status400(models::ApiError),
Status401(models::ApiError),
Status404(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_task_comment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateTaskCommentError {
Status400(models::ApiError),
Status401(models::ApiError),
Status403(models::ApiError),
Status404(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`workspace_complete_task`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WorkspaceCompleteTaskError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`workspace_complete_task_alias`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WorkspaceCompleteTaskAliasError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`workspace_create_task`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WorkspaceCreateTaskError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`workspace_create_task_alias`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WorkspaceCreateTaskAliasError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`workspace_delete_task`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WorkspaceDeleteTaskError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`workspace_get_task`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WorkspaceGetTaskError {
Status401(models::ApiError),
Status403(models::ApiError),
Status404(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`workspace_list_task_providers`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WorkspaceListTaskProvidersError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`workspace_list_tasks`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WorkspaceListTasksError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`workspace_list_tasks_alias`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WorkspaceListTasksAliasError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`workspace_update_task`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WorkspaceUpdateTaskError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`workspace_update_task_alias`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WorkspaceUpdateTaskAliasError {
Status401(models::ApiError),
Status403(models::ApiError),
UnknownValue(serde_json::Value),
}
/// Replaces the legacy BFF that looped DELETE /v1/tasks/:id. Per-id errors are collected in `failed` rather than failing the whole call — partial success is the norm.
pub async fn bulk_delete_tasks(configuration: &configuration::Configuration, bulk_delete_tasks_request: models::BulkDeleteTasksRequest) -> Result<models::BulkDeleteTasksResponse, Error<BulkDeleteTasksError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_bulk_delete_tasks_request = bulk_delete_tasks_request;
let uri_str = format!("{}/v1/tasks/delete", 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_bulk_delete_tasks_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::BulkDeleteTasksResponse`"))),
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::BulkDeleteTasksResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<BulkDeleteTasksError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Same `updates` payload applied to every id in `taskIds`. As with bulk delete, per-id failures collect in `failed`.
pub async fn bulk_update_tasks(configuration: &configuration::Configuration, bulk_update_tasks_request: models::BulkUpdateTasksRequest) -> Result<models::BulkUpdateTasksResponse, Error<BulkUpdateTasksError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_bulk_update_tasks_request = bulk_update_tasks_request;
let uri_str = format!("{}/v1/tasks/bulk-update", 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_bulk_update_tasks_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::BulkUpdateTasksResponse`"))),
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::BulkUpdateTasksResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<BulkUpdateTasksError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Idempotent — completing an already-completed task is a no-op that still returns success. The legacy `POST /v1/tasks/complete/task` endpoint accepts the same operation with the task id in the JSON body instead of the URL; that variant is a renderer-compat shim and is not modeled in the spec.
pub async fn complete_task(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::SuccessFlag, Error<CompleteTaskError>> {
// 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/tasks/{id}/complete", configuration.base_path, id=crate::apis::urlencode(p_path_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶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::SuccessFlag`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CompleteTaskError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Creates a new task under the target account. Target resolution mirrors `POST /v1/notes`: body `accountId` → `?accountId=` → body `provider` → `?provider=` → caller's single connected account (errors `ambiguous_account` if more than one and no selector).
pub async fn create_task(configuration: &configuration::Configuration, create_task_request: models::CreateTaskRequest, account_id: Option<&str>, provider: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::Task, Error<CreateTaskError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_task_request = create_task_request;
let p_query_account_id = account_id;
let p_query_provider = provider;
let p_header_x_workspace_id = x_workspace_id;
let uri_str = format!("{}/v1/tasks", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_provider {
req_builder = req_builder.query(&[("provider", ¶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_create_task_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::Task`"))),
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::Task`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateTaskError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_task_comment(configuration: &configuration::Configuration, id: &str, task_comment_request: models::TaskCommentRequest, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::TaskCommentMutationResponse, Error<CreateTaskCommentError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_id = id;
let p_body_task_comment_request = task_comment_request;
let p_query_account_id = account_id;
let p_header_x_workspace_id = x_workspace_id;
let uri_str = format!("{}/v1/tasks/{id}/comments", configuration.base_path, id=crate::apis::urlencode(p_path_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶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_task_comment_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::TaskCommentMutationResponse`"))),
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::TaskCommentMutationResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateTaskCommentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_task(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::SuccessFlag, Error<DeleteTaskError>> {
// 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/tasks/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶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::SuccessFlag`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteTaskError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Allowed for the comment author and (for native comments) for the task owner.
pub async fn delete_task_comment(configuration: &configuration::Configuration, id: &str, comment_id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::SuccessFlag, Error<DeleteTaskCommentError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_id = id;
let p_path_comment_id = comment_id;
let p_query_account_id = account_id;
let p_header_x_workspace_id = x_workspace_id;
let uri_str = format!("{}/v1/tasks/{id}/comments/{commentId}", configuration.base_path, id=crate::apis::urlencode(p_path_id), commentId=crate::apis::urlencode(p_path_comment_id));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶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::SuccessFlag`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteTaskCommentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_task(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::Task, Error<GetTaskError>> {
// 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/tasks/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶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::Task`"))),
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::Task`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetTaskError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Returns active comments. When `?accountId=` targets an external provider that supports comments (e.g. Linear), the provider is queried directly; otherwise the native `TaskComment` table is used.
pub async fn list_task_comments(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::TaskCommentList, Error<ListTaskCommentsError>> {
// 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/tasks/{id}/comments", configuration.base_path, id=crate::apis::urlencode(p_path_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶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::TaskCommentList`"))),
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::TaskCommentList`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListTaskCommentsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Returns the registered task-provider ids and the platform's own metadata. Useful for clients that need to render provider-specific UI (icons, capability flags) before committing to a particular `provider`.
pub async fn list_task_providers(configuration: &configuration::Configuration, ) -> Result<models::TaskProvidersInfo, Error<ListTaskProvidersError>> {
let uri_str = format!("{}/v1/tasks/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::TaskProvidersInfo`"))),
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::TaskProvidersInfo`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListTaskProvidersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Fan-out list. Returns every task visible to the caller across every connected tasks provider. Pass `?accountId=` or `?provider=` to scope to a single source.
pub async fn list_tasks(configuration: &configuration::Configuration, account_id: Option<&str>, provider: Option<&str>, x_workspace_id: Option<&str>, completed: Option<bool>, labels: Option<Vec<String>>, parent_task_id: Option<&str>, r#type: Option<&str>, source_platform: Option<&str>, source_id: Option<&str>, limit: Option<i32>, offset: Option<i32>) -> Result<models::TaskListEnvelope, Error<ListTasksError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_provider = provider;
let p_header_x_workspace_id = x_workspace_id;
let p_query_completed = completed;
let p_query_labels = labels;
let p_query_parent_task_id = parent_task_id;
let p_query_type = r#type;
let p_query_source_platform = source_platform;
let p_query_source_id = source_id;
let p_query_limit = limit;
let p_query_offset = offset;
let uri_str = format!("{}/v1/tasks", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_provider {
req_builder = req_builder.query(&[("provider", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_completed {
req_builder = req_builder.query(&[("completed", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_labels {
req_builder = match "multi" {
"multi" => req_builder.query(¶m_value.into_iter().map(|p| ("labels".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => req_builder.query(&[("labels", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref param_value) = p_query_parent_task_id {
req_builder = req_builder.query(&[("parentTaskId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_type {
req_builder = req_builder.query(&[("type", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_source_platform {
req_builder = req_builder.query(&[("sourcePlatform", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_source_id {
req_builder = req_builder.query(&[("sourceId", ¶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 param_value) = p_query_offset {
req_builder = req_builder.query(&[("offset", ¶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::TaskListEnvelope`"))),
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::TaskListEnvelope`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListTasksError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn update_task(configuration: &configuration::Configuration, id: &str, update_task_request: models::UpdateTaskRequest, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::Task, Error<UpdateTaskError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_id = id;
let p_body_update_task_request = update_task_request;
let p_query_account_id = account_id;
let p_header_x_workspace_id = x_workspace_id;
let uri_str = format!("{}/v1/tasks/{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(&[("accountId", ¶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_task_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::Task`"))),
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::Task`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateTaskError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Only the comment author can edit.
pub async fn update_task_comment(configuration: &configuration::Configuration, id: &str, comment_id: &str, task_comment_request: models::TaskCommentRequest, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::TaskCommentMutationResponse, Error<UpdateTaskCommentError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_id = id;
let p_path_comment_id = comment_id;
let p_body_task_comment_request = task_comment_request;
let p_query_account_id = account_id;
let p_header_x_workspace_id = x_workspace_id;
let uri_str = format!("{}/v1/tasks/{id}/comments/{commentId}", configuration.base_path, id=crate::apis::urlencode(p_path_id), commentId=crate::apis::urlencode(p_path_comment_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(&[("accountId", ¶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_task_comment_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::TaskCommentMutationResponse`"))),
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::TaskCommentMutationResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateTaskCommentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn workspace_complete_task(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceCompleteTaskError>> {
// 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}/tasks/{id}/complete", 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::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<WorkspaceCompleteTaskError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn workspace_complete_task_alias(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<WorkspaceCompleteTaskAliasError>> {
// 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}/tasks/complete/task", 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<WorkspaceCompleteTaskAliasError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn workspace_create_task(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<WorkspaceCreateTaskError>> {
// 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}/tasks", 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<WorkspaceCreateTaskError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn workspace_create_task_alias(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<WorkspaceCreateTaskAliasError>> {
// 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}/tasks/task", 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<WorkspaceCreateTaskAliasError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn workspace_delete_task(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<(), Error<WorkspaceDeleteTaskError>> {
// 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}/tasks/{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<WorkspaceDeleteTaskError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn workspace_get_task(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceGetTaskError>> {
// 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}/tasks/{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<WorkspaceGetTaskError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn workspace_list_task_providers(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListTaskProvidersError>> {
// 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}/tasks/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<WorkspaceListTaskProvidersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn workspace_list_tasks(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListTasksError>> {
// 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}/tasks", 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<WorkspaceListTasksError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn workspace_list_tasks_alias(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListTasksAliasError>> {
// 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}/tasks/tasks", 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<WorkspaceListTasksAliasError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn workspace_update_task(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<WorkspaceUpdateTaskError>> {
// 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}/tasks/{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<WorkspaceUpdateTaskError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn workspace_update_task_alias(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<WorkspaceUpdateTaskAliasError>> {
// 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}/tasks/task/{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::PUT, &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<WorkspaceUpdateTaskAliasError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}