aboutsummaryrefslogtreecommitdiffstats
path: root/rust/fatcat-api/src
diff options
context:
space:
mode:
Diffstat (limited to 'rust/fatcat-api/src')
-rw-r--r--rust/fatcat-api/src/client.rs11
-rw-r--r--rust/fatcat-api/src/lib.rs8
-rw-r--r--rust/fatcat-api/src/mimetypes.rs6
-rw-r--r--rust/fatcat-api/src/models.rs89
-rw-r--r--rust/fatcat-api/src/server.rs14
5 files changed, 109 insertions, 19 deletions
diff --git a/rust/fatcat-api/src/client.rs b/rust/fatcat-api/src/client.rs
index 09b43e4b..0c1345de 100644
--- a/rust/fatcat-api/src/client.rs
+++ b/rust/fatcat-api/src/client.rs
@@ -616,7 +616,14 @@ impl Api for Client {
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Editgroup>(&buf)?;
- Ok(EditgroupIdGetResponse::FoundEditgroup(body))
+ Ok(EditgroupIdGetResponse::FoundEntity(body))
+ }
+ 400 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(EditgroupIdGetResponse::BadRequest(body))
}
404 => {
let mut buf = String::new();
@@ -724,7 +731,7 @@ impl Api for Client {
200 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Changelogentry>(&buf)?;
+ let body = serde_json::from_str::<models::Changelogentries>(&buf)?;
Ok(EditorUsernameChangelogGetResponse::FoundMergedChanges(body))
}
diff --git a/rust/fatcat-api/src/lib.rs b/rust/fatcat-api/src/lib.rs
index 3696a1e2..716781cb 100644
--- a/rust/fatcat-api/src/lib.rs
+++ b/rust/fatcat-api/src/lib.rs
@@ -118,8 +118,10 @@ pub enum EditgroupIdAcceptPostResponse {
#[derive(Debug, PartialEq)]
pub enum EditgroupIdGetResponse {
- /// Found Editgroup
- FoundEditgroup(models::Editgroup),
+ /// Found Entity
+ FoundEntity(models::Editgroup),
+ /// Bad Request
+ BadRequest(models::ErrorResponse),
/// Not Found
NotFound(models::ErrorResponse),
/// Generic Error
@@ -139,7 +141,7 @@ pub enum EditgroupPostResponse {
#[derive(Debug, PartialEq)]
pub enum EditorUsernameChangelogGetResponse {
/// Found Merged Changes
- FoundMergedChanges(models::Changelogentry),
+ FoundMergedChanges(models::Changelogentries),
/// Not Found
NotFound(models::ErrorResponse),
/// Generic Error
diff --git a/rust/fatcat-api/src/mimetypes.rs b/rust/fatcat-api/src/mimetypes.rs
index 9d3d91a8..6b89f7bb 100644
--- a/rust/fatcat-api/src/mimetypes.rs
+++ b/rust/fatcat-api/src/mimetypes.rs
@@ -118,7 +118,11 @@ pub mod responses {
}
/// Create Mime objects for the response content types for EditgroupIdGet
lazy_static! {
- pub static ref EDITGROUP_ID_GET_FOUND_EDITGROUP: Mime = mime!(Application / Json);
+ pub static ref EDITGROUP_ID_GET_FOUND_ENTITY: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for EditgroupIdGet
+ lazy_static! {
+ pub static ref EDITGROUP_ID_GET_BAD_REQUEST: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for EditgroupIdGet
lazy_static! {
diff --git a/rust/fatcat-api/src/models.rs b/rust/fatcat-api/src/models.rs
index 82fe7bad..0186f0a0 100644
--- a/rust/fatcat-api/src/models.rs
+++ b/rust/fatcat-api/src/models.rs
@@ -9,25 +9,84 @@ use std::collections::HashMap;
use swagger;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
-pub struct Changelogentry {
+pub struct Changelogentries(Vec<ChangelogentriesInner>);
+
+impl ::std::convert::From<Vec<ChangelogentriesInner>> for Changelogentries {
+ fn from(x: Vec<ChangelogentriesInner>) -> Self {
+ Changelogentries(x)
+ }
+}
+
+impl ::std::convert::From<Changelogentries> for Vec<ChangelogentriesInner> {
+ fn from(x: Changelogentries) -> Self {
+ x.0
+ }
+}
+
+impl ::std::iter::FromIterator<ChangelogentriesInner> for Changelogentries {
+ fn from_iter<U: IntoIterator<Item = ChangelogentriesInner>>(u: U) -> Self {
+ Changelogentries(Vec::<ChangelogentriesInner>::from_iter(u))
+ }
+}
+
+impl ::std::iter::IntoIterator for Changelogentries {
+ type Item = ChangelogentriesInner;
+ type IntoIter = ::std::vec::IntoIter<ChangelogentriesInner>;
+
+ fn into_iter(self) -> Self::IntoIter {
+ self.0.into_iter()
+ }
+}
+
+impl<'a> ::std::iter::IntoIterator for &'a Changelogentries {
+ type Item = &'a ChangelogentriesInner;
+ type IntoIter = ::std::slice::Iter<'a, ChangelogentriesInner>;
+
+ fn into_iter(self) -> Self::IntoIter {
+ (&self.0).into_iter()
+ }
+}
+
+impl<'a> ::std::iter::IntoIterator for &'a mut Changelogentries {
+ type Item = &'a mut ChangelogentriesInner;
+ type IntoIter = ::std::slice::IterMut<'a, ChangelogentriesInner>;
+
+ fn into_iter(self) -> Self::IntoIter {
+ (&mut self.0).into_iter()
+ }
+}
+
+impl ::std::ops::Deref for Changelogentries {
+ type Target = Vec<ChangelogentriesInner>;
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
+
+impl ::std::ops::DerefMut for Changelogentries {
+ fn deref_mut(&mut self) -> &mut Self::Target {
+ &mut self.0
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+pub struct ChangelogentriesInner {
#[serde(rename = "index")]
pub index: isize,
#[serde(rename = "editgroup_id")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub editgroup_id: Option<isize>,
+ pub editgroup_id: isize,
#[serde(rename = "timestamp")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub timestamp: Option<chrono::DateTime<chrono::Utc>>,
+ pub timestamp: chrono::DateTime<chrono::Utc>,
}
-impl Changelogentry {
- pub fn new(index: isize) -> Changelogentry {
- Changelogentry {
+impl ChangelogentriesInner {
+ pub fn new(index: isize, editgroup_id: isize, timestamp: chrono::DateTime<chrono::Utc>) -> ChangelogentriesInner {
+ ChangelogentriesInner {
index: index,
- editgroup_id: None,
- timestamp: None,
+ editgroup_id: editgroup_id,
+ timestamp: timestamp,
}
}
}
@@ -135,11 +194,19 @@ pub struct Editgroup {
#[serde(rename = "editor_id")]
pub editor_id: isize,
+
+ #[serde(rename = "description")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub description: Option<String>,
}
impl Editgroup {
pub fn new(editor_id: isize) -> Editgroup {
- Editgroup { id: None, editor_id: editor_id }
+ Editgroup {
+ id: None,
+ editor_id: editor_id,
+ description: None,
+ }
}
}
diff --git a/rust/fatcat-api/src/server.rs b/rust/fatcat-api/src/server.rs
index 090c45e3..902ebd6d 100644
--- a/rust/fatcat-api/src/server.rs
+++ b/rust/fatcat-api/src/server.rs
@@ -759,11 +759,21 @@ where
match api.editgroup_id_get(param_id, context).wait() {
Ok(rsp) => match rsp {
- EditgroupIdGetResponse::FoundEditgroup(body) => {
+ EditgroupIdGetResponse::FoundEntity(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::EDITGROUP_ID_GET_FOUND_EDITGROUP.clone()));
+ response.headers.set(ContentType(mimetypes::responses::EDITGROUP_ID_GET_FOUND_ENTITY.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ EditgroupIdGetResponse::BadRequest(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(mimetypes::responses::EDITGROUP_ID_GET_BAD_REQUEST.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));