summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2021-11-17 17:54:51 -0800
committerBryan Newbold <bnewbold@archive.org>2021-11-19 17:57:25 -0800
commit1cca4833557aa8cbc8d6219dd98ec86cef04ef5d (patch)
tree23811c1be7a9171974101d93df9a90c533e7b69d
parent1dd7fede5c8fb44a7819a25c74144ad0eff78627 (diff)
downloadfatcat-cli-1cca4833557aa8cbc8d6219dd98ec86cef04ef5d.tar.gz
fatcat-cli-1cca4833557aa8cbc8d6219dd98ec86cef04ef5d.zip
add some mutation fields for entities (file, fileset, webcapture)
Motivation is to support bulk cleanups using fatcat-cli tool
-rw-r--r--fatcat-cli/src/entities.rs55
1 files changed, 51 insertions, 4 deletions
diff --git a/fatcat-cli/src/entities.rs b/fatcat-cli/src/entities.rs
index 5e4ac06..14c9c29 100644
--- a/fatcat-cli/src/entities.rs
+++ b/fatcat-cli/src/entities.rs
@@ -220,6 +220,9 @@ impl ApiModelMutate for models::ReleaseEntity {
("subtitle", val) => {
self.subtitle = val;
}
+ ("original_title", val) => {
+ self.original_title = val;
+ }
("container_id", val) => {
self.container_id = val;
}
@@ -253,6 +256,13 @@ impl ApiModelMutate for models::ReleaseEntity {
("language", val) => {
self.language = val;
}
+ // None-only fields, for now
+ ("release_date", None) => {
+ self.release_date = None;
+ }
+ ("release_year", None) => {
+ self.release_year = None;
+ }
(field, _) => unimplemented!("setting field {} on a release", field),
}
}
@@ -276,6 +286,15 @@ impl ApiModelMutate for models::ContainerEntity {
("issnl", val) => {
self.issnl = val;
}
+ ("issne", val) => {
+ self.issne = val;
+ }
+ ("issnp", val) => {
+ self.issnp = val;
+ }
+ ("publication_status", val) => {
+ self.publication_status = val;
+ }
(field, _) => unimplemented!("setting field {} on a container", field),
}
}
@@ -331,6 +350,12 @@ impl ApiModelMutate for models::FileEntity {
("mimetype", val) => {
self.mimetype = val;
}
+ ("release_ids", None) => {
+ self.release_ids = None;
+ }
+ ("content_scope", val) => {
+ self.content_scope = val;
+ }
(field, _) => unimplemented!("setting field {} on a file", field),
}
}
@@ -339,14 +364,36 @@ impl ApiModelMutate for models::FileEntity {
}
impl ApiModelMutate for models::FilesetEntity {
- fn mutate(&mut self, _mutations: Vec<Mutation>) -> Result<()> {
- unimplemented!("mutations")
+ fn mutate(&mut self, mutations: Vec<Mutation>) -> Result<()> {
+ for m in mutations {
+ match (m.field.as_str(), m.value) {
+ ("release_ids", None) => {
+ self.release_ids = None;
+ }
+ ("content_scope", val) => {
+ self.content_scope = val;
+ }
+ (field, _) => unimplemented!("setting field {} on a fileset", field),
+ }
+ }
+ Ok(())
}
}
impl ApiModelMutate for models::WebcaptureEntity {
- fn mutate(&mut self, _mutations: Vec<Mutation>) -> Result<()> {
- unimplemented!("mutations")
+ fn mutate(&mut self, mutations: Vec<Mutation>) -> Result<()> {
+ for m in mutations {
+ match (m.field.as_str(), m.value) {
+ ("release_ids", None) => {
+ self.release_ids = None;
+ }
+ ("content_scope", val) => {
+ self.content_scope = val;
+ }
+ (field, _) => unimplemented!("setting field {} on a webcapture", field),
+ }
+ }
+ Ok(())
}
}