From 1cca4833557aa8cbc8d6219dd98ec86cef04ef5d Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 17 Nov 2021 17:54:51 -0800 Subject: add some mutation fields for entities (file, fileset, webcapture) Motivation is to support bulk cleanups using fatcat-cli tool --- fatcat-cli/src/entities.rs | 55 ++++++++++++++++++++++++++++++++++++++++++---- 1 file 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) -> Result<()> { - unimplemented!("mutations") + fn mutate(&mut self, mutations: Vec) -> 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) -> Result<()> { - unimplemented!("mutations") + fn mutate(&mut self, mutations: Vec) -> 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(()) } } -- cgit v1.2.3