705 lines
37 KiB
Rust
705 lines
37 KiB
Rust
|
/*
|
||
|
* Gitea API
|
||
|
*
|
||
|
* This documentation describes the Gitea API.
|
||
|
*
|
||
|
* The version of the OpenAPI document: 1.22.1
|
||
|
*
|
||
|
* Generated by: https://openapi-generator.tech
|
||
|
*/
|
||
|
|
||
|
|
||
|
use reqwest;
|
||
|
use serde::{Deserialize, Serialize};
|
||
|
use crate::{apis::ResponseContent, models};
|
||
|
use super::{Error, configuration};
|
||
|
|
||
|
|
||
|
/// struct for typed errors of method [`notify_get_list`]
|
||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
#[serde(untagged)]
|
||
|
pub enum NotifyGetListError {
|
||
|
UnknownValue(serde_json::Value),
|
||
|
}
|
||
|
|
||
|
/// struct for typed errors of method [`notify_get_repo_list`]
|
||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
#[serde(untagged)]
|
||
|
pub enum NotifyGetRepoListError {
|
||
|
UnknownValue(serde_json::Value),
|
||
|
}
|
||
|
|
||
|
/// struct for typed errors of method [`notify_get_thread`]
|
||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
#[serde(untagged)]
|
||
|
pub enum NotifyGetThreadError {
|
||
|
Status403(),
|
||
|
Status404(),
|
||
|
UnknownValue(serde_json::Value),
|
||
|
}
|
||
|
|
||
|
/// struct for typed errors of method [`notify_new_available`]
|
||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
#[serde(untagged)]
|
||
|
pub enum NotifyNewAvailableError {
|
||
|
UnknownValue(serde_json::Value),
|
||
|
}
|
||
|
|
||
|
/// struct for typed errors of method [`notify_read_list`]
|
||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
#[serde(untagged)]
|
||
|
pub enum NotifyReadListError {
|
||
|
UnknownValue(serde_json::Value),
|
||
|
}
|
||
|
|
||
|
/// struct for typed errors of method [`notify_read_repo_list`]
|
||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
#[serde(untagged)]
|
||
|
pub enum NotifyReadRepoListError {
|
||
|
UnknownValue(serde_json::Value),
|
||
|
}
|
||
|
|
||
|
/// struct for typed errors of method [`notify_read_thread`]
|
||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
#[serde(untagged)]
|
||
|
pub enum NotifyReadThreadError {
|
||
|
Status403(),
|
||
|
Status404(),
|
||
|
UnknownValue(serde_json::Value),
|
||
|
}
|
||
|
|
||
|
|
||
|
pub async fn notify_get_list(configuration: &configuration::Configuration, all: Option<bool>, status_types: Option<Vec<String>>, subject_type: Option<Vec<String>>, since: Option<String>, before: Option<String>, page: Option<i32>, limit: Option<i32>) -> Result<Vec<models::NotificationThread>, Error<NotifyGetListError>> {
|
||
|
let local_var_configuration = configuration;
|
||
|
|
||
|
let local_var_client = &local_var_configuration.client;
|
||
|
|
||
|
let local_var_uri_str = format!("{}/notifications", local_var_configuration.base_path);
|
||
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
||
|
|
||
|
if let Some(ref local_var_str) = all {
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("all", &local_var_str.to_string())]);
|
||
|
}
|
||
|
if let Some(ref local_var_str) = status_types {
|
||
|
local_var_req_builder = match "multi" {
|
||
|
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("status-types".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
|
||
|
_ => local_var_req_builder.query(&[("status-types", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
|
||
|
};
|
||
|
}
|
||
|
if let Some(ref local_var_str) = subject_type {
|
||
|
local_var_req_builder = match "multi" {
|
||
|
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("subject-type".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
|
||
|
_ => local_var_req_builder.query(&[("subject-type", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
|
||
|
};
|
||
|
}
|
||
|
if let Some(ref local_var_str) = since {
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
|
||
|
}
|
||
|
if let Some(ref local_var_str) = before {
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
|
||
|
}
|
||
|
if let Some(ref local_var_str) = page {
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
|
||
|
}
|
||
|
if let Some(ref local_var_str) = limit {
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("access_token", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("sudo", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("token", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("X-GITEA-OTP", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("Sudo", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
|
||
|
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
|
||
|
};
|
||
|
|
||
|
let local_var_req = local_var_req_builder.build()?;
|
||
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||
|
|
||
|
let local_var_status = local_var_resp.status();
|
||
|
let local_var_content = local_var_resp.text().await?;
|
||
|
|
||
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||
|
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||
|
} else {
|
||
|
let local_var_entity: Option<NotifyGetListError> = serde_json::from_str(&local_var_content).ok();
|
||
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||
|
Err(Error::ResponseError(local_var_error))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub async fn notify_get_repo_list(configuration: &configuration::Configuration, owner: &str, repo: &str, all: Option<bool>, status_types: Option<Vec<String>>, subject_type: Option<Vec<String>>, since: Option<String>, before: Option<String>, page: Option<i32>, limit: Option<i32>) -> Result<Vec<models::NotificationThread>, Error<NotifyGetRepoListError>> {
|
||
|
let local_var_configuration = configuration;
|
||
|
|
||
|
let local_var_client = &local_var_configuration.client;
|
||
|
|
||
|
let local_var_uri_str = format!("{}/repos/{owner}/{repo}/notifications", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo));
|
||
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
||
|
|
||
|
if let Some(ref local_var_str) = all {
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("all", &local_var_str.to_string())]);
|
||
|
}
|
||
|
if let Some(ref local_var_str) = status_types {
|
||
|
local_var_req_builder = match "multi" {
|
||
|
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("status-types".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
|
||
|
_ => local_var_req_builder.query(&[("status-types", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
|
||
|
};
|
||
|
}
|
||
|
if let Some(ref local_var_str) = subject_type {
|
||
|
local_var_req_builder = match "multi" {
|
||
|
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("subject-type".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
|
||
|
_ => local_var_req_builder.query(&[("subject-type", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
|
||
|
};
|
||
|
}
|
||
|
if let Some(ref local_var_str) = since {
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
|
||
|
}
|
||
|
if let Some(ref local_var_str) = before {
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
|
||
|
}
|
||
|
if let Some(ref local_var_str) = page {
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
|
||
|
}
|
||
|
if let Some(ref local_var_str) = limit {
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("access_token", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("sudo", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("token", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("X-GITEA-OTP", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("Sudo", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
|
||
|
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
|
||
|
};
|
||
|
|
||
|
let local_var_req = local_var_req_builder.build()?;
|
||
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||
|
|
||
|
let local_var_status = local_var_resp.status();
|
||
|
let local_var_content = local_var_resp.text().await?;
|
||
|
|
||
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||
|
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||
|
} else {
|
||
|
let local_var_entity: Option<NotifyGetRepoListError> = serde_json::from_str(&local_var_content).ok();
|
||
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||
|
Err(Error::ResponseError(local_var_error))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub async fn notify_get_thread(configuration: &configuration::Configuration, id: &str) -> Result<models::NotificationThread, Error<NotifyGetThreadError>> {
|
||
|
let local_var_configuration = configuration;
|
||
|
|
||
|
let local_var_client = &local_var_configuration.client;
|
||
|
|
||
|
let local_var_uri_str = format!("{}/notifications/threads/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
|
||
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
||
|
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("access_token", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("sudo", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("token", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("X-GITEA-OTP", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("Sudo", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
|
||
|
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
|
||
|
};
|
||
|
|
||
|
let local_var_req = local_var_req_builder.build()?;
|
||
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||
|
|
||
|
let local_var_status = local_var_resp.status();
|
||
|
let local_var_content = local_var_resp.text().await?;
|
||
|
|
||
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||
|
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||
|
} else {
|
||
|
let local_var_entity: Option<NotifyGetThreadError> = serde_json::from_str(&local_var_content).ok();
|
||
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||
|
Err(Error::ResponseError(local_var_error))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub async fn notify_new_available(configuration: &configuration::Configuration, ) -> Result<models::NotificationCount, Error<NotifyNewAvailableError>> {
|
||
|
let local_var_configuration = configuration;
|
||
|
|
||
|
let local_var_client = &local_var_configuration.client;
|
||
|
|
||
|
let local_var_uri_str = format!("{}/notifications/new", local_var_configuration.base_path);
|
||
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
|
||
|
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("access_token", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("sudo", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("token", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("X-GITEA-OTP", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("Sudo", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
|
||
|
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
|
||
|
};
|
||
|
|
||
|
let local_var_req = local_var_req_builder.build()?;
|
||
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||
|
|
||
|
let local_var_status = local_var_resp.status();
|
||
|
let local_var_content = local_var_resp.text().await?;
|
||
|
|
||
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||
|
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||
|
} else {
|
||
|
let local_var_entity: Option<NotifyNewAvailableError> = serde_json::from_str(&local_var_content).ok();
|
||
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||
|
Err(Error::ResponseError(local_var_error))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub async fn notify_read_list(configuration: &configuration::Configuration, last_read_at: Option<String>, all: Option<&str>, status_types: Option<Vec<String>>, to_status: Option<&str>) -> Result<Vec<models::NotificationThread>, Error<NotifyReadListError>> {
|
||
|
let local_var_configuration = configuration;
|
||
|
|
||
|
let local_var_client = &local_var_configuration.client;
|
||
|
|
||
|
let local_var_uri_str = format!("{}/notifications", local_var_configuration.base_path);
|
||
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
|
||
|
|
||
|
if let Some(ref local_var_str) = last_read_at {
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("last_read_at", &local_var_str.to_string())]);
|
||
|
}
|
||
|
if let Some(ref local_var_str) = all {
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("all", &local_var_str.to_string())]);
|
||
|
}
|
||
|
if let Some(ref local_var_str) = status_types {
|
||
|
local_var_req_builder = match "multi" {
|
||
|
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("status-types".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
|
||
|
_ => local_var_req_builder.query(&[("status-types", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
|
||
|
};
|
||
|
}
|
||
|
if let Some(ref local_var_str) = to_status {
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("to-status", &local_var_str.to_string())]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("access_token", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("sudo", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("token", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("X-GITEA-OTP", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("Sudo", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
|
||
|
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
|
||
|
};
|
||
|
|
||
|
let local_var_req = local_var_req_builder.build()?;
|
||
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||
|
|
||
|
let local_var_status = local_var_resp.status();
|
||
|
let local_var_content = local_var_resp.text().await?;
|
||
|
|
||
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||
|
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||
|
} else {
|
||
|
let local_var_entity: Option<NotifyReadListError> = serde_json::from_str(&local_var_content).ok();
|
||
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||
|
Err(Error::ResponseError(local_var_error))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub async fn notify_read_repo_list(configuration: &configuration::Configuration, owner: &str, repo: &str, all: Option<&str>, status_types: Option<Vec<String>>, to_status: Option<&str>, last_read_at: Option<String>) -> Result<Vec<models::NotificationThread>, Error<NotifyReadRepoListError>> {
|
||
|
let local_var_configuration = configuration;
|
||
|
|
||
|
let local_var_client = &local_var_configuration.client;
|
||
|
|
||
|
let local_var_uri_str = format!("{}/repos/{owner}/{repo}/notifications", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo));
|
||
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
|
||
|
|
||
|
if let Some(ref local_var_str) = all {
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("all", &local_var_str.to_string())]);
|
||
|
}
|
||
|
if let Some(ref local_var_str) = status_types {
|
||
|
local_var_req_builder = match "multi" {
|
||
|
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("status-types".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
|
||
|
_ => local_var_req_builder.query(&[("status-types", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
|
||
|
};
|
||
|
}
|
||
|
if let Some(ref local_var_str) = to_status {
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("to-status", &local_var_str.to_string())]);
|
||
|
}
|
||
|
if let Some(ref local_var_str) = last_read_at {
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("last_read_at", &local_var_str.to_string())]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("access_token", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("sudo", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("token", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("X-GITEA-OTP", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("Sudo", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
|
||
|
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
|
||
|
};
|
||
|
|
||
|
let local_var_req = local_var_req_builder.build()?;
|
||
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||
|
|
||
|
let local_var_status = local_var_resp.status();
|
||
|
let local_var_content = local_var_resp.text().await?;
|
||
|
|
||
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||
|
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||
|
} else {
|
||
|
let local_var_entity: Option<NotifyReadRepoListError> = serde_json::from_str(&local_var_content).ok();
|
||
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||
|
Err(Error::ResponseError(local_var_error))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub async fn notify_read_thread(configuration: &configuration::Configuration, id: &str, to_status: Option<&str>) -> Result<models::NotificationThread, Error<NotifyReadThreadError>> {
|
||
|
let local_var_configuration = configuration;
|
||
|
|
||
|
let local_var_client = &local_var_configuration.client;
|
||
|
|
||
|
let local_var_uri_str = format!("{}/notifications/threads/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
|
||
|
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
|
||
|
|
||
|
if let Some(ref local_var_str) = to_status {
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("to-status", &local_var_str.to_string())]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("access_token", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("sudo", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.query(&[("token", local_var_value)]);
|
||
|
}
|
||
|
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
|
||
|
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
|
||
|
}
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("X-GITEA-OTP", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
|
||
|
let local_var_key = local_var_apikey.key.clone();
|
||
|
let local_var_value = match local_var_apikey.prefix {
|
||
|
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
|
||
|
None => local_var_key,
|
||
|
};
|
||
|
local_var_req_builder = local_var_req_builder.header("Sudo", local_var_value);
|
||
|
};
|
||
|
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
|
||
|
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
|
||
|
};
|
||
|
|
||
|
let local_var_req = local_var_req_builder.build()?;
|
||
|
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||
|
|
||
|
let local_var_status = local_var_resp.status();
|
||
|
let local_var_content = local_var_resp.text().await?;
|
||
|
|
||
|
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||
|
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||
|
} else {
|
||
|
let local_var_entity: Option<NotifyReadThreadError> = serde_json::from_str(&local_var_content).ok();
|
||
|
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||
|
Err(Error::ResponseError(local_var_error))
|
||
|
}
|
||
|
}
|
||
|
|