summaryrefslogtreecommitdiffstats
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.rs26
-rw-r--r--rust/fatcat-api/src/lib.rs28
-rw-r--r--rust/fatcat-api/src/mimetypes.rs20
-rw-r--r--rust/fatcat-api/src/server.rs44
4 files changed, 82 insertions, 36 deletions
diff --git a/rust/fatcat-api/src/client.rs b/rust/fatcat-api/src/client.rs
index 6f61f773..a08e3cfe 100644
--- a/rust/fatcat-api/src/client.rs
+++ b/rust/fatcat-api/src/client.rs
@@ -1749,7 +1749,7 @@ 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::<Vec<models::ReleaseEntity>>(&buf)?;
- Ok(GetCreatorReleasesResponse::FoundEntity(body))
+ Ok(GetCreatorReleasesResponse::Found(body))
}
400 => {
let mut buf = String::new();
@@ -1809,7 +1809,7 @@ 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(GetEditgroupResponse::FoundEntity(body))
+ Ok(GetEditgroupResponse::Found(body))
}
400 => {
let mut buf = String::new();
@@ -1869,7 +1869,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::Editor>(&buf)?;
- Ok(GetEditorResponse::FoundEditor(body))
+ Ok(GetEditorResponse::Found(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(GetEditorResponse::BadRequest(body))
}
404 => {
let mut buf = String::new();
@@ -1922,7 +1929,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::<Vec<models::ChangelogEntry>>(&buf)?;
- Ok(GetEditorChangelogResponse::FoundMergedChanges(body))
+ Ok(GetEditorChangelogResponse::Found(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(GetEditorChangelogResponse::BadRequest(body))
}
404 => {
let mut buf = String::new();
@@ -2179,7 +2193,7 @@ 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::<Vec<models::FileEntity>>(&buf)?;
- Ok(GetReleaseFilesResponse::FoundEntity(body))
+ Ok(GetReleaseFilesResponse::Found(body))
}
400 => {
let mut buf = String::new();
@@ -2492,7 +2506,7 @@ 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::<Vec<models::ReleaseEntity>>(&buf)?;
- Ok(GetWorkReleasesResponse::FoundEntity(body))
+ Ok(GetWorkReleasesResponse::Found(body))
}
400 => {
let mut buf = String::new();
diff --git a/rust/fatcat-api/src/lib.rs b/rust/fatcat-api/src/lib.rs
index fc1ae2a1..a08c6e04 100644
--- a/rust/fatcat-api/src/lib.rs
+++ b/rust/fatcat-api/src/lib.rs
@@ -304,8 +304,8 @@ pub enum GetCreatorHistoryResponse {
#[derive(Debug, PartialEq)]
pub enum GetCreatorReleasesResponse {
- /// Found Entity
- FoundEntity(Vec<models::ReleaseEntity>),
+ /// Found
+ Found(Vec<models::ReleaseEntity>),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
@@ -316,8 +316,8 @@ pub enum GetCreatorReleasesResponse {
#[derive(Debug, PartialEq)]
pub enum GetEditgroupResponse {
- /// Found Entity
- FoundEntity(models::Editgroup),
+ /// Found
+ Found(models::Editgroup),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
@@ -328,8 +328,10 @@ pub enum GetEditgroupResponse {
#[derive(Debug, PartialEq)]
pub enum GetEditorResponse {
- /// Found Editor
- FoundEditor(models::Editor),
+ /// Found
+ Found(models::Editor),
+ /// Bad Request
+ BadRequest(models::ErrorResponse),
/// Not Found
NotFound(models::ErrorResponse),
/// Generic Error
@@ -338,8 +340,10 @@ pub enum GetEditorResponse {
#[derive(Debug, PartialEq)]
pub enum GetEditorChangelogResponse {
- /// Found Merged Changes
- FoundMergedChanges(Vec<models::ChangelogEntry>),
+ /// Found
+ Found(Vec<models::ChangelogEntry>),
+ /// Bad Request
+ BadRequest(models::ErrorResponse),
/// Not Found
NotFound(models::ErrorResponse),
/// Generic Error
@@ -384,8 +388,8 @@ pub enum GetReleaseResponse {
#[derive(Debug, PartialEq)]
pub enum GetReleaseFilesResponse {
- /// Found Entity
- FoundEntity(Vec<models::FileEntity>),
+ /// Found
+ Found(Vec<models::FileEntity>),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
@@ -440,8 +444,8 @@ pub enum GetWorkHistoryResponse {
#[derive(Debug, PartialEq)]
pub enum GetWorkReleasesResponse {
- /// Found Entity
- FoundEntity(Vec<models::ReleaseEntity>),
+ /// Found
+ Found(Vec<models::ReleaseEntity>),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
diff --git a/rust/fatcat-api/src/mimetypes.rs b/rust/fatcat-api/src/mimetypes.rs
index 2c54a313..ff2c12ce 100644
--- a/rust/fatcat-api/src/mimetypes.rs
+++ b/rust/fatcat-api/src/mimetypes.rs
@@ -362,7 +362,7 @@ pub mod responses {
}
/// Create Mime objects for the response content types for GetCreatorReleases
lazy_static! {
- pub static ref GET_CREATOR_RELEASES_FOUND_ENTITY: Mime = mime!(Application / Json);
+ pub static ref GET_CREATOR_RELEASES_FOUND: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for GetCreatorReleases
lazy_static! {
@@ -378,7 +378,7 @@ pub mod responses {
}
/// Create Mime objects for the response content types for GetEditgroup
lazy_static! {
- pub static ref GET_EDITGROUP_FOUND_ENTITY: Mime = mime!(Application / Json);
+ pub static ref GET_EDITGROUP_FOUND: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for GetEditgroup
lazy_static! {
@@ -394,7 +394,11 @@ pub mod responses {
}
/// Create Mime objects for the response content types for GetEditor
lazy_static! {
- pub static ref GET_EDITOR_FOUND_EDITOR: Mime = mime!(Application / Json);
+ pub static ref GET_EDITOR_FOUND: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetEditor
+ lazy_static! {
+ pub static ref GET_EDITOR_BAD_REQUEST: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for GetEditor
lazy_static! {
@@ -406,7 +410,11 @@ pub mod responses {
}
/// Create Mime objects for the response content types for GetEditorChangelog
lazy_static! {
- pub static ref GET_EDITOR_CHANGELOG_FOUND_MERGED_CHANGES: Mime = mime!(Application / Json);
+ pub static ref GET_EDITOR_CHANGELOG_FOUND: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetEditorChangelog
+ lazy_static! {
+ pub static ref GET_EDITOR_CHANGELOG_BAD_REQUEST: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for GetEditorChangelog
lazy_static! {
@@ -466,7 +474,7 @@ pub mod responses {
}
/// Create Mime objects for the response content types for GetReleaseFiles
lazy_static! {
- pub static ref GET_RELEASE_FILES_FOUND_ENTITY: Mime = mime!(Application / Json);
+ pub static ref GET_RELEASE_FILES_FOUND: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for GetReleaseFiles
lazy_static! {
@@ -538,7 +546,7 @@ pub mod responses {
}
/// Create Mime objects for the response content types for GetWorkReleases
lazy_static! {
- pub static ref GET_WORK_RELEASES_FOUND_ENTITY: Mime = mime!(Application / Json);
+ pub static ref GET_WORK_RELEASES_FOUND: Mime = mime!(Application / Json);
}
/// Create Mime objects for the response content types for GetWorkReleases
lazy_static! {
diff --git a/rust/fatcat-api/src/server.rs b/rust/fatcat-api/src/server.rs
index 04d10e14..dfc94a81 100644
--- a/rust/fatcat-api/src/server.rs
+++ b/rust/fatcat-api/src/server.rs
@@ -2361,11 +2361,11 @@ where
match api.get_creator_releases(param_id, context).wait() {
Ok(rsp) => match rsp {
- GetCreatorReleasesResponse::FoundEntity(body) => {
+ GetCreatorReleasesResponse::Found(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::GET_CREATOR_RELEASES_FOUND_ENTITY.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_CREATOR_RELEASES_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
@@ -2449,11 +2449,11 @@ where
match api.get_editgroup(param_id, context).wait() {
Ok(rsp) => match rsp {
- GetEditgroupResponse::FoundEntity(body) => {
+ GetEditgroupResponse::Found(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::GET_EDITGROUP_FOUND_ENTITY.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
@@ -2537,11 +2537,21 @@ where
match api.get_editor(param_id, context).wait() {
Ok(rsp) => match rsp {
- GetEditorResponse::FoundEditor(body) => {
+ GetEditorResponse::Found(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::GET_EDITOR_FOUND_EDITOR.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_FOUND.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ GetEditorResponse::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::GET_EDITOR_BAD_REQUEST.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
@@ -2615,11 +2625,21 @@ where
match api.get_editor_changelog(param_id, context).wait() {
Ok(rsp) => match rsp {
- GetEditorChangelogResponse::FoundMergedChanges(body) => {
+ GetEditorChangelogResponse::Found(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::GET_EDITOR_CHANGELOG_FOUND_MERGED_CHANGES.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_CHANGELOG_FOUND.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ GetEditorChangelogResponse::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::GET_EDITOR_CHANGELOG_BAD_REQUEST.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
@@ -2969,11 +2989,11 @@ where
match api.get_release_files(param_id, context).wait() {
Ok(rsp) => match rsp {
- GetReleaseFilesResponse::FoundEntity(body) => {
+ GetReleaseFilesResponse::Found(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::GET_RELEASE_FILES_FOUND_ENTITY.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_RELEASE_FILES_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
@@ -3391,11 +3411,11 @@ where
match api.get_work_releases(param_id, context).wait() {
Ok(rsp) => match rsp {
- GetWorkReleasesResponse::FoundEntity(body) => {
+ GetWorkReleasesResponse::Found(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::GET_WORK_RELEASES_FOUND_ENTITY.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_WORK_RELEASES_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));