/*
* iNaturalist API
*
* # https://api.inaturalist.org/v1/ [iNaturalist](https://www.inaturalist.org/) is a global community of naturalists, scientists, and members of the public sharing over a million wildlife sightings to teach one another about the natural world while creating high quality citizen science data for science and conservation. These API methods return data in JSON/JSONP and PNG response formats. They are meant to supplement the existing [iNaturalist API](https://www.inaturalist.org/pages/api+reference), implemented in Ruby on Rails, which has more functionality and supports more write operations, but tends to be slower and have less consistent response formats. Visit our [developers page](https://www.inaturalist.org/pages/developers) for more information. Write operations that expect and return JSON describe a single `body` parameter that represents the request body, which should be specified as JSON. See the \"Model\" of each body parameter for attributes that we accept in these JSON objects. Multiple values for a single URL parameter should be separated by commas, e.g. `taxon_id=1,2,3`. Map tiles are generated using the [node-mapnik](https://github.com/mapnik/node-mapnik) library, following the XYZ map tiling scheme. The \"Observation Tile\" methods accept nearly all the parameters of the observation search APIs, and will generate map tiles reflecting the same observations returned by searches. These \"Observation Tile\" methods have corresponding [UTFGrid](https://github.com/mapbox/utfgrid-spec) JSON responses which return information needed to make interactive maps. Authentication in the Node API is handled via JSON Web Tokens (JWT). To obtain one, make an [OAuth-authenticated request](http://www.inaturalist.org/pages/api+reference#auth) to https://www.inaturalist.org/users/api_token. Each JWT will expire after 24 hours. Authentication required for all PUT and POST requests. Some GET requests will also include private information like hidden coordinates if the authenticated user has permission to view them. Photos served from https://static.inaturalist.org and https://inaturalist-open-data.s3.amazonaws.com have multiple size variants and not all size variants are returned in responses. To access other sizes, the photo URL can be modified to replace only the size qualifier (each variant shares the exact same extension). The domain a photo is hosted under reflects the license under which the photo is being shared, and the domain may change over time if the license changes. Photos in the `inaturalist-open-data` domain are shared under open licenses. These can be accessed in bulk in the [iNaturalist AWS Open Dataset]( https://registry.opendata.aws/inaturalist-open-data/). Photos in the `static.inaturalist.org` domain do not have open licenses. The available photo sizes are: * original (max 2048px in either dimension) * large (max 1024px in either dimension) * medium (max 500px in either dimension) * small (max 240px in either dimension) * thumb (max 100px in either dimension) * square (75px square) iNaturalist Website: https://www.inaturalist.org/ Open Source Software: https://github.com/inaturalist/ ## Terms of Use Use of this API is subject to the iNaturalist [Terms of Service](https://www.inaturalist.org/terms) and [Privacy Policy](https://www.inaturalist.org/privacy). We will block any use of our API that violates our Terms or Privacy Policy without notice. The API is intended to support application development, not data scraping. For pre- generated data exports, see https://www.inaturalist.org/pages/developers. Please note that we throttle API usage to a max of 100 requests per minute, though we ask that you try to keep it to 60 requests per minute or lower, and to keep under 10,000 requests per day. If we notice usage that has serious impact on our performance we may institute blocks without notification. Terms of Service: https://www.inaturalist.org/terms Privacy Policy: https://www.inaturalist.org/privacy
*
* The version of the OpenAPI document: 1.3.0
*
* Generated by: https://openapi-generator.tech
*/
use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
/// struct for passing parameters to the method [`projects_autocomplete_get`]
#[derive(Clone, Debug)]
pub struct ProjectsAutocompleteGetParams {
/// Search by name (must start with this value) or by ID (exact match).
pub q: String,
/// Must have this ID
pub id: Option<Vec<String>>,
/// Must not have this ID
pub not_id: Option<Vec<String>>,
/// Must be within a {`radius`} kilometer circle around this lat/lng (*lat, *lng, radius)
pub lat: Option<f64>,
/// Must be within a {`radius`} kilometer circle around this lat/lng (*lat, *lng, radius)
pub lng: Option<f64>,
/// Must be associated with this place
pub place_id: Option<Vec<String>>,
/// Must be within a {`radius`} kilometer circle around this lat/lng (*lat, *lng, radius). Defaults to 500km
pub radius: Option<String>,
/// Must be marked featured for the relevant site
pub featured: Option<String>,
/// Must be marked noteworthy for the relevant site
pub noteworthy: Option<String>,
/// Site ID that applies to `featured` and `noteworthy`. Defaults to the site of the authenticated user, or to the main iNaturalist site https://www.inaturalist.org
pub site_id: Option<i32>,
/// Return more information about project rules, for example return a full taxon object instead of simply an ID
pub rule_details: Option<String>,
/// Projects must be of this type
pub r#type: Option<Vec<String>>,
/// Project must have member with this user ID
pub member_id: Option<i32>,
/// Must have search parameter requirements
pub has_params: Option<bool>,
/// Must have posts
pub has_posts: Option<bool>,
/// Number of results to return in a `page`. The maximum value is generally 200 unless otherwise noted
pub per_page: Option<String>,
}
/// struct for passing parameters to the method [`projects_get`]
#[derive(Clone, Debug)]
pub struct ProjectsGetParams {
/// Search by name (must start with this value) or by ID (exact match).
pub q: Option<String>,
/// Must have this ID
pub id: Option<Vec<String>>,
/// Must not have this ID
pub not_id: Option<Vec<String>>,
/// Must be within a {`radius`} kilometer circle around this lat/lng (*lat, *lng, radius)
pub lat: Option<f64>,
/// Must be within a {`radius`} kilometer circle around this lat/lng (*lat, *lng, radius)
pub lng: Option<f64>,
/// Must be associated with this place
pub place_id: Option<Vec<String>>,
/// Must be within a {`radius`} kilometer circle around this lat/lng (*lat, *lng, radius). Defaults to 500km
pub radius: Option<String>,
/// Must be marked featured for the relevant site
pub featured: Option<String>,
/// Must be marked noteworthy for the relevant site
pub noteworthy: Option<String>,
/// Site ID that applies to `featured` and `noteworthy`. Defaults to the site of the authenticated user, or to the main iNaturalist site https://www.inaturalist.org
pub site_id: Option<i32>,
/// Return more information about project rules, for example return a full taxon object instead of simply an ID
pub rule_details: Option<String>,
/// Projects must be of this type
pub r#type: Option<Vec<String>>,
/// Project must have member with this user ID
pub member_id: Option<i32>,
/// Must have search parameter requirements
pub has_params: Option<bool>,
/// Must have posts
pub has_posts: Option<bool>,
/// Number of results to return in a `page`. The maximum value is generally 200 unless otherwise noted
pub per_page: Option<String>,
/// Sort field
pub order_by: Option<String>,
}
/// struct for passing parameters to the method [`projects_id_add_post`]
#[derive(Clone, Debug)]
pub struct ProjectsIdAddPostParams {
/// ID of the record
pub id: i32,
/// ProjectObservation object
pub body: Option<models::PostProjectAdd>,
}
/// struct for passing parameters to the method [`projects_id_get`]
#[derive(Clone, Debug)]
pub struct ProjectsIdGetParams {
/// Must have this ID or slug
pub id: Vec<String>,
/// Return more information about project rules, for example return a full taxon object instead of simply an ID
pub rule_details: Option<String>,
}
/// struct for passing parameters to the method [`projects_id_join_post`]
#[derive(Clone, Debug)]
pub struct ProjectsIdJoinPostParams {
/// ID of the record
pub id: i32,
}
/// struct for passing parameters to the method [`projects_id_leave_delete`]
#[derive(Clone, Debug)]
pub struct ProjectsIdLeaveDeleteParams {
/// ID of the record
pub id: i32,
}
/// struct for passing parameters to the method [`projects_id_members_get`]
#[derive(Clone, Debug)]
pub struct ProjectsIdMembersGetParams {
/// ID of the record
pub id: i32,
/// Membership role
pub role: Option<String>,
/// If counts are not needed, consider setting this to true to save on processing time, resulting in faster responses
pub skip_counts: Option<bool>,
/// Pagination `page` number
pub page: Option<String>,
/// Number of results to return in a `page`. The maximum value is generally 200 unless otherwise noted
pub per_page: Option<String>,
}
/// struct for passing parameters to the method [`projects_id_membership_get`]
#[derive(Clone, Debug)]
pub struct ProjectsIdMembershipGetParams {
/// Must have this ID
pub id: Vec<i32>,
}
/// struct for passing parameters to the method [`projects_id_remove_delete`]
#[derive(Clone, Debug)]
pub struct ProjectsIdRemoveDeleteParams {
/// ID of the record
pub id: i32,
/// ProjectObservation object
pub body: Option<models::PostProjectAdd>,
}
/// struct for passing parameters to the method [`projects_id_subscriptions_get`]
#[derive(Clone, Debug)]
pub struct ProjectsIdSubscriptionsGetParams {
/// ID of the record
pub id: i32,
}
/// struct for passing parameters to the method [`subscriptions_project_id_subscribe_post`]
#[derive(Clone, Debug)]
pub struct SubscriptionsProjectIdSubscribePostParams {
/// ID of the record
pub id: i32,
}
/// struct for typed errors of method [`projects_autocomplete_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ProjectsAutocompleteGetError {
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`projects_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ProjectsGetError {
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`projects_id_add_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ProjectsIdAddPostError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`projects_id_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ProjectsIdGetError {
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`projects_id_join_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ProjectsIdJoinPostError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`projects_id_leave_delete`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ProjectsIdLeaveDeleteError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`projects_id_members_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ProjectsIdMembersGetError {
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`projects_id_membership_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ProjectsIdMembershipGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`projects_id_remove_delete`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ProjectsIdRemoveDeleteError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`projects_id_subscriptions_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ProjectsIdSubscriptionsGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`subscriptions_project_id_subscribe_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubscriptionsProjectIdSubscribePostError {
UnknownValue(serde_json::Value),
}
/// Given an string, returns projects with titles starting with the search term
pub async fn projects_autocomplete_get(
configuration: &configuration::Configuration,
params: ProjectsAutocompleteGetParams,
) -> Result<models::ProjectsResponse, Error<ProjectsAutocompleteGetError>> {
let uri_str = format!("{}/projects/autocomplete", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("q", ¶ms.q.to_string())]);
if let Some(ref param_value) = params.id {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("id".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"id",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = params.not_id {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("not_id".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"not_id",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = params.lat {
req_builder = req_builder.query(&[("lat", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.lng {
req_builder = req_builder.query(&[("lng", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.place_id {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("place_id".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"place_id",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = params.radius {
req_builder = req_builder.query(&[("radius", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.featured {
req_builder = req_builder.query(&[("featured", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.noteworthy {
req_builder = req_builder.query(&[("noteworthy", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.site_id {
req_builder = req_builder.query(&[("site_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.rule_details {
req_builder = req_builder.query(&[("rule_details", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.r#type {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("type".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"type",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = params.member_id {
req_builder = req_builder.query(&[("member_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.has_params {
req_builder = req_builder.query(&[("has_params", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.has_posts {
req_builder = req_builder.query(&[("has_posts", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.per_page {
req_builder = req_builder.query(&[("per_page", ¶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());
}
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::ProjectsResponse`"))),
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::ProjectsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ProjectsAutocompleteGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Given zero to many of following parameters, returns projects matching the search criteria
pub async fn projects_get(
configuration: &configuration::Configuration,
params: ProjectsGetParams,
) -> Result<models::ProjectsResponse, Error<ProjectsGetError>> {
let uri_str = format!("{}/projects", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = params.q {
req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.id {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("id".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"id",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = params.not_id {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("not_id".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"not_id",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = params.lat {
req_builder = req_builder.query(&[("lat", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.lng {
req_builder = req_builder.query(&[("lng", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.place_id {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("place_id".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"place_id",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = params.radius {
req_builder = req_builder.query(&[("radius", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.featured {
req_builder = req_builder.query(&[("featured", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.noteworthy {
req_builder = req_builder.query(&[("noteworthy", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.site_id {
req_builder = req_builder.query(&[("site_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.rule_details {
req_builder = req_builder.query(&[("rule_details", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.r#type {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("type".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"type",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = params.member_id {
req_builder = req_builder.query(&[("member_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.has_params {
req_builder = req_builder.query(&[("has_params", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.has_posts {
req_builder = req_builder.query(&[("has_posts", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.per_page {
req_builder = req_builder.query(&[("per_page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.order_by {
req_builder = req_builder.query(&[("order_by", ¶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());
}
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::ProjectsResponse`"))),
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::ProjectsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ProjectsGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Add an observation to a project
pub async fn projects_id_add_post(
configuration: &configuration::Configuration,
params: ProjectsIdAddPostParams,
) -> Result<(), Error<ProjectsIdAddPostError>> {
let uri_str = format!(
"{}/projects/{id}/add",
configuration.base_path,
id = params.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 apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
req_builder = req_builder.json(¶ms.body);
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<ProjectsIdAddPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Given an ID, or an array of IDs in comma-delimited format, returns corresponding projects. A maximum of 100 results will be returned
pub async fn projects_id_get(
configuration: &configuration::Configuration,
params: ProjectsIdGetParams,
) -> Result<models::ProjectsResponse, Error<ProjectsIdGetError>> {
let uri_str = format!(
"{}/projects/{id}",
configuration.base_path,
id = params
.id
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<_>>()
.join(",")
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = params.rule_details {
req_builder = req_builder.query(&[("rule_details", ¶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());
}
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::ProjectsResponse`"))),
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::ProjectsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ProjectsIdGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Join a project
pub async fn projects_id_join_post(
configuration: &configuration::Configuration,
params: ProjectsIdJoinPostParams,
) -> Result<(), Error<ProjectsIdJoinPostError>> {
let uri_str = format!(
"{}/projects/{id}/join",
configuration.base_path,
id = params.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 apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
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<ProjectsIdJoinPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Leave a project
pub async fn projects_id_leave_delete(
configuration: &configuration::Configuration,
params: ProjectsIdLeaveDeleteParams,
) -> Result<(), Error<ProjectsIdLeaveDeleteError>> {
let uri_str = format!(
"{}/projects/{id}/leave",
configuration.base_path,
id = params.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 apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
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<ProjectsIdLeaveDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Given an ID, return members of the project
pub async fn projects_id_members_get(
configuration: &configuration::Configuration,
params: ProjectsIdMembersGetParams,
) -> Result<models::ProjectMembersResponse, Error<ProjectsIdMembersGetError>> {
let uri_str = format!(
"{}/projects/{id}/members",
configuration.base_path,
id = params.id
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = params.role {
req_builder = req_builder.query(&[("role", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.skip_counts {
req_builder = req_builder.query(&[("skip_counts", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = params.per_page {
req_builder = req_builder.query(&[("per_page", ¶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());
}
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::ProjectMembersResponse`"))),
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::ProjectMembersResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ProjectsIdMembersGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Given an ID, or an array of IDs in comma-delimited format, return the details of the authenticated user's membership in these projects
pub async fn projects_id_membership_get(
configuration: &configuration::Configuration,
params: ProjectsIdMembershipGetParams,
) -> Result<(), Error<ProjectsIdMembershipGetError>> {
let uri_str = format!(
"{}/projects/{id}/membership",
configuration.base_path,
id = params
.id
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<_>>()
.join(",")
);
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 apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
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<ProjectsIdMembershipGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Remove an observation from a project
pub async fn projects_id_remove_delete(
configuration: &configuration::Configuration,
params: ProjectsIdRemoveDeleteParams,
) -> Result<(), Error<ProjectsIdRemoveDeleteError>> {
let uri_str = format!(
"{}/projects/{id}/remove",
configuration.base_path,
id = params.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 apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
req_builder = req_builder.json(¶ms.body);
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<ProjectsIdRemoveDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// [Deprecated] Subscriptions to projects are managed through joining and leaving projects, so this will not return any useful information. Given an ID, return subscription of the current user
pub async fn projects_id_subscriptions_get(
configuration: &configuration::Configuration,
params: ProjectsIdSubscriptionsGetParams,
) -> Result<(), Error<ProjectsIdSubscriptionsGetError>> {
let uri_str = format!(
"{}/projects/{id}/subscriptions",
configuration.base_path,
id = params.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 apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
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<ProjectsIdSubscriptionsGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Toggles current user's subscription to this project. If the logged-in user is not subscribed, POSTing here will subscribe them. If they are already subscribed, this will remove the subscription
pub async fn subscriptions_project_id_subscribe_post(
configuration: &configuration::Configuration,
params: SubscriptionsProjectIdSubscribePostParams,
) -> Result<(), Error<SubscriptionsProjectIdSubscribePostError>> {
let uri_str = format!(
"{}/subscriptions/project/{id}/subscribe",
configuration.base_path,
id = params.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 apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
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<SubscriptionsProjectIdSubscribePostError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}