summaryrefslogtreecommitdiffstats
path: root/rust/fatcat-api
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-06-30 16:50:32 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-06-30 16:50:32 -0700
commit3ed7db573438d3620d295813a81237acb91155cb (patch)
tree714abba5a1a84449cf9beb152b5ee56996627f37 /rust/fatcat-api
parenta96ca6e8df949f32e7647a285748712a9d842611 (diff)
downloadfatcat-3ed7db573438d3620d295813a81237acb91155cb.tar.gz
fatcat-3ed7db573438d3620d295813a81237acb91155cb.zip
refactor changelog entry spec structure
Diffstat (limited to 'rust/fatcat-api')
-rw-r--r--rust/fatcat-api/README.md2
-rw-r--r--rust/fatcat-api/api.yaml53
-rw-r--r--rust/fatcat-api/api/swagger.yaml88
-rw-r--r--rust/fatcat-api/src/client.rs2
-rw-r--r--rust/fatcat-api/src/lib.rs2
-rw-r--r--rust/fatcat-api/src/models.rs152
6 files changed, 178 insertions, 121 deletions
diff --git a/rust/fatcat-api/README.md b/rust/fatcat-api/README.md
index fe725d7f..37d2a3b2 100644
--- a/rust/fatcat-api/README.md
+++ b/rust/fatcat-api/README.md
@@ -13,7 +13,7 @@ To see how to make this your own, look here:
[README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md)
- API version: 0.1.0
-- Build date: 2018-06-28T19:08:07.508Z
+- Build date: 2018-06-30T23:46:33.844Z
This autogenerated project defines an API crate `fatcat` which contains:
* An `Api` trait defining the API in Rust.
diff --git a/rust/fatcat-api/api.yaml b/rust/fatcat-api/api.yaml
index eba6b63c..1796f32f 100644
--- a/rust/fatcat-api/api.yaml
+++ b/rust/fatcat-api/api.yaml
@@ -181,6 +181,21 @@ definitions:
<<: *ENTITYPROPS
work_type:
type: string
+ entity_history:
+ type: array
+ items:
+ type: object
+ required:
+ - edit
+ - editgroup
+ - changelog
+ properties:
+ edit:
+ $ref: "#/definitions/entity_edit"
+ editgroup:
+ $ref: "#/definitions/editgroup"
+ changelog:
+ $ref: "#/definitions/changelog_entry"
entity_edit:
type: object
required:
@@ -257,24 +272,22 @@ definitions:
type: array
items:
$ref: "#/definitions/entity_edit"
- changelogentries:
- type: array
- items:
- type: object
- required:
- - index
- - editgroup_id
- - timestamp
- properties:
- index:
- type: integer
- format: int64
- editgroup_id:
- type: integer
- format: int64
- timestamp:
- type: string
- format: date-time
+ changelog_entry:
+ type: object
+ required:
+ - index
+ - editgroup_id
+ - timestamp
+ properties:
+ index:
+ type: integer
+ format: int64
+ editgroup_id:
+ type: integer
+ format: int64
+ timestamp:
+ type: string
+ format: date-time
release_ref:
type: object
properties:
@@ -710,7 +723,9 @@ paths:
200:
description: Found Merged Changes
schema:
- $ref: "#/definitions/changelogentries"
+ type: array
+ items:
+ $ref: "#/definitions/changelog_entry"
404:
description: Not Found
schema:
diff --git a/rust/fatcat-api/api/swagger.yaml b/rust/fatcat-api/api/swagger.yaml
index 8a328822..dcb4e74f 100644
--- a/rust/fatcat-api/api/swagger.yaml
+++ b/rust/fatcat-api/api/swagger.yaml
@@ -26,7 +26,7 @@ paths:
refName: "container_entity"
formatString: "{:?}"
example: "???"
- model_key: "changelogentries_inner"
+ model_key: "editgroup_edits"
uppercase_operation_id: "CREATE_CONTAINER"
consumesJson: true
responses:
@@ -85,7 +85,7 @@ paths:
$ref: "#/definitions/container_entity"
formatString: "{:?}"
example: "&Vec::new()"
- model_key: "changelogentries_inner"
+ model_key: "editgroup_edits"
uppercase_operation_id: "CREATE_CONTAINER_BATCH"
consumesJson: true
responses:
@@ -249,7 +249,7 @@ paths:
refName: "creator_entity"
formatString: "{:?}"
example: "???"
- model_key: "changelogentries_inner"
+ model_key: "editgroup_edits"
uppercase_operation_id: "CREATE_CREATOR"
consumesJson: true
responses:
@@ -308,7 +308,7 @@ paths:
$ref: "#/definitions/creator_entity"
formatString: "{:?}"
example: "&Vec::new()"
- model_key: "changelogentries_inner"
+ model_key: "editgroup_edits"
uppercase_operation_id: "CREATE_CREATOR_BATCH"
consumesJson: true
responses:
@@ -526,7 +526,7 @@ paths:
refName: "file_entity"
formatString: "{:?}"
example: "???"
- model_key: "changelogentries_inner"
+ model_key: "editgroup_edits"
uppercase_operation_id: "CREATE_FILE"
consumesJson: true
responses:
@@ -585,7 +585,7 @@ paths:
$ref: "#/definitions/file_entity"
formatString: "{:?}"
example: "&Vec::new()"
- model_key: "changelogentries_inner"
+ model_key: "editgroup_edits"
uppercase_operation_id: "CREATE_FILE_BATCH"
consumesJson: true
responses:
@@ -749,7 +749,7 @@ paths:
refName: "release_entity"
formatString: "{:?}"
example: "???"
- model_key: "changelogentries_inner"
+ model_key: "editgroup_edits"
uppercase_operation_id: "CREATE_RELEASE"
consumesJson: true
responses:
@@ -808,7 +808,7 @@ paths:
$ref: "#/definitions/release_entity"
formatString: "{:?}"
example: "&Vec::new()"
- model_key: "changelogentries_inner"
+ model_key: "editgroup_edits"
uppercase_operation_id: "CREATE_RELEASE_BATCH"
consumesJson: true
responses:
@@ -1026,7 +1026,7 @@ paths:
refName: "work_entity"
formatString: "{:?}"
example: "???"
- model_key: "changelogentries_inner"
+ model_key: "editgroup_edits"
uppercase_operation_id: "CREATE_WORK"
consumesJson: true
responses:
@@ -1085,7 +1085,7 @@ paths:
$ref: "#/definitions/work_entity"
formatString: "{:?}"
example: "&Vec::new()"
- model_key: "changelogentries_inner"
+ model_key: "editgroup_edits"
uppercase_operation_id: "CREATE_WORK_BATCH"
consumesJson: true
responses:
@@ -1295,11 +1295,13 @@ paths:
200:
description: "Found Merged Changes"
schema:
- $ref: "#/definitions/changelogentries"
+ type: "array"
+ items:
+ $ref: "#/definitions/changelog_entry"
x-responseId: "FoundMergedChanges"
x-uppercaseResponseId: "FOUND_MERGED_CHANGES"
uppercase_operation_id: "GET_EDITOR_CHANGELOG"
- uppercase_data_type: "CHANGELOGENTRIES"
+ uppercase_data_type: "VEC<CHANGELOGENTRY>"
producesJson: true
404:
description: "Not Found"
@@ -1337,7 +1339,7 @@ paths:
refName: "editgroup"
formatString: "{:?}"
example: "???"
- model_key: "changelogentries_inner"
+ model_key: "editgroup_edits"
uppercase_operation_id: "CREATE_EDITGROUP"
consumesJson: true
responses:
@@ -1860,6 +1862,11 @@ definitions:
state: "wip"
revision: 42
upperCaseName: "WORK_ENTITY"
+ entity_history:
+ type: "array"
+ items:
+ $ref: "#/definitions/entity_history_inner"
+ upperCaseName: "ENTITY_HISTORY"
entity_edit:
type: "object"
required:
@@ -1995,11 +2002,27 @@ definitions:
editor_id: 6
id: 0
upperCaseName: "EDITGROUP"
- changelogentries:
- type: "array"
- items:
- $ref: "#/definitions/changelogentries_inner"
- upperCaseName: "CHANGELOGENTRIES"
+ changelog_entry:
+ type: "object"
+ required:
+ - "editgroup_id"
+ - "index"
+ - "timestamp"
+ properties:
+ index:
+ type: "integer"
+ format: "int64"
+ editgroup_id:
+ type: "integer"
+ format: "int64"
+ timestamp:
+ type: "string"
+ format: "date-time"
+ example:
+ index: 0
+ editgroup_id: 6
+ timestamp: "2000-01-23T04:56:07.000+00:00"
+ upperCaseName: "CHANGELOG_ENTRY"
release_ref:
type: "object"
properties:
@@ -2058,6 +2081,19 @@ definitions:
example:
extra: "{}"
upperCaseName: "STATS_RESPONSE"
+ entity_history_inner:
+ required:
+ - "changelog"
+ - "edit"
+ - "editgroup"
+ properties:
+ edit:
+ $ref: "#/definitions/entity_edit"
+ editgroup:
+ $ref: "#/definitions/editgroup"
+ changelog:
+ $ref: "#/definitions/changelog_entry"
+ upperCaseName: "ENTITY_HISTORY_INNER"
editgroup_edits:
properties:
containers:
@@ -2147,22 +2183,6 @@ definitions:
editgroup_id: 16
revision: 42
upperCaseName: "EDITGROUP_EDITS"
- changelogentries_inner:
- required:
- - "editgroup_id"
- - "index"
- - "timestamp"
- properties:
- index:
- type: "integer"
- format: "int64"
- editgroup_id:
- type: "integer"
- format: "int64"
- timestamp:
- type: "string"
- format: "date-time"
- upperCaseName: "CHANGELOGENTRIES_INNER"
x-entity-props:
state:
type: "string"
diff --git a/rust/fatcat-api/src/client.rs b/rust/fatcat-api/src/client.rs
index b94d6f42..8c7e4ef3 100644
--- a/rust/fatcat-api/src/client.rs
+++ b/rust/fatcat-api/src/client.rs
@@ -1248,7 +1248,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::Changelogentries>(&buf)?;
+ let body = serde_json::from_str::<Vec<models::ChangelogEntry>>(&buf)?;
Ok(GetEditorChangelogResponse::FoundMergedChanges(body))
}
diff --git a/rust/fatcat-api/src/lib.rs b/rust/fatcat-api/src/lib.rs
index fd0cfe54..f45e113e 100644
--- a/rust/fatcat-api/src/lib.rs
+++ b/rust/fatcat-api/src/lib.rs
@@ -235,7 +235,7 @@ pub enum GetEditorResponse {
#[derive(Debug, PartialEq)]
pub enum GetEditorChangelogResponse {
/// Found Merged Changes
- FoundMergedChanges(models::Changelogentries),
+ FoundMergedChanges(Vec<models::ChangelogEntry>),
/// Not Found
NotFound(models::ErrorResponse),
/// Generic Error
diff --git a/rust/fatcat-api/src/models.rs b/rust/fatcat-api/src/models.rs
index 60330392..7ff39789 100644
--- a/rust/fatcat-api/src/models.rs
+++ b/rust/fatcat-api/src/models.rs
@@ -10,68 +10,7 @@ use std::collections::HashMap;
use swagger;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
-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 {
+pub struct ChangelogEntry {
#[serde(rename = "index")]
pub index: i64,
@@ -82,9 +21,9 @@ pub struct ChangelogentriesInner {
pub timestamp: chrono::DateTime<chrono::Utc>,
}
-impl ChangelogentriesInner {
- pub fn new(index: i64, editgroup_id: i64, timestamp: chrono::DateTime<chrono::Utc>) -> ChangelogentriesInner {
- ChangelogentriesInner {
+impl ChangelogEntry {
+ pub fn new(index: i64, editgroup_id: i64, timestamp: chrono::DateTime<chrono::Utc>) -> ChangelogEntry {
+ ChangelogEntry {
index: index,
editgroup_id: editgroup_id,
timestamp: timestamp,
@@ -336,6 +275,89 @@ impl EntityEdit {
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+pub struct EntityHistory(Vec<EntityHistoryInner>);
+
+impl ::std::convert::From<Vec<EntityHistoryInner>> for EntityHistory {
+ fn from(x: Vec<EntityHistoryInner>) -> Self {
+ EntityHistory(x)
+ }
+}
+
+impl ::std::convert::From<EntityHistory> for Vec<EntityHistoryInner> {
+ fn from(x: EntityHistory) -> Self {
+ x.0
+ }
+}
+
+impl ::std::iter::FromIterator<EntityHistoryInner> for EntityHistory {
+ fn from_iter<U: IntoIterator<Item = EntityHistoryInner>>(u: U) -> Self {
+ EntityHistory(Vec::<EntityHistoryInner>::from_iter(u))
+ }
+}
+
+impl ::std::iter::IntoIterator for EntityHistory {
+ type Item = EntityHistoryInner;
+ type IntoIter = ::std::vec::IntoIter<EntityHistoryInner>;
+
+ fn into_iter(self) -> Self::IntoIter {
+ self.0.into_iter()
+ }
+}
+
+impl<'a> ::std::iter::IntoIterator for &'a EntityHistory {
+ type Item = &'a EntityHistoryInner;
+ type IntoIter = ::std::slice::Iter<'a, EntityHistoryInner>;
+
+ fn into_iter(self) -> Self::IntoIter {
+ (&self.0).into_iter()
+ }
+}
+
+impl<'a> ::std::iter::IntoIterator for &'a mut EntityHistory {
+ type Item = &'a mut EntityHistoryInner;
+ type IntoIter = ::std::slice::IterMut<'a, EntityHistoryInner>;
+
+ fn into_iter(self) -> Self::IntoIter {
+ (&mut self.0).into_iter()
+ }
+}
+
+impl ::std::ops::Deref for EntityHistory {
+ type Target = Vec<EntityHistoryInner>;
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
+
+impl ::std::ops::DerefMut for EntityHistory {
+ fn deref_mut(&mut self) -> &mut Self::Target {
+ &mut self.0
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+pub struct EntityHistoryInner {
+ #[serde(rename = "edit")]
+ pub edit: models::EntityEdit,
+
+ #[serde(rename = "editgroup")]
+ pub editgroup: models::Editgroup,
+
+ #[serde(rename = "changelog")]
+ pub changelog: models::ChangelogEntry,
+}
+
+impl EntityHistoryInner {
+ pub fn new(edit: models::EntityEdit, editgroup: models::Editgroup, changelog: models::ChangelogEntry) -> EntityHistoryInner {
+ EntityHistoryInner {
+ edit: edit,
+ editgroup: editgroup,
+ changelog: changelog,
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ErrorResponse {
#[serde(rename = "message")]
pub message: String,