diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2021-05-14 22:33:26 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2021-05-14 22:33:26 +0200 |
commit | 5fdabf3e75ba16b5ceed99edb1912cb001765d03 (patch) | |
tree | d9288733c910cfac9217668b0d9b8360d72ab4e8 /src/api/s3_xml.rs | |
parent | 6ccffc316228bb056fa135cc5fceb2ed75f545f5 (diff) | |
download | garage-5fdabf3e75ba16b5ceed99edb1912cb001765d03.tar.gz garage-5fdabf3e75ba16b5ceed99edb1912cb001765d03.zip |
Add basic support for the "Versioning" command
Diffstat (limited to 'src/api/s3_xml.rs')
-rw-r--r-- | src/api/s3_xml.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/api/s3_xml.rs b/src/api/s3_xml.rs index ba9b9083..f0547961 100644 --- a/src/api/s3_xml.rs +++ b/src/api/s3_xml.rs @@ -195,6 +195,14 @@ pub struct ListBucketResult { pub common_prefixes: Vec<CommonPrefix>, } +#[derive(Debug, Serialize, PartialEq)] +pub struct VersioningConfiguration { + #[serde(serialize_with = "xmlns_tag")] + pub xmlns: (), + #[serde(rename = "Status")] + pub status: Option<Value>, +} + #[cfg(test)] mod tests { use super::*; @@ -280,6 +288,30 @@ mod tests { } #[test] + fn get_bucket_versioning_result() -> Result<(), ApiError> { + let get_bucket_versioning = VersioningConfiguration { + xmlns: (), + status: None, + }; + assert_eq!( + to_xml_with_header(&get_bucket_versioning)?, + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\ +<VersioningConfiguration xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\"/>" + ); + let get_bucket_versioning2 = VersioningConfiguration { + xmlns: (), + status: Some(Value("Suspended".to_string())), + }; + assert_eq!( + to_xml_with_header(&get_bucket_versioning2)?, + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\ +<VersioningConfiguration xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\"><Status>Suspended</Status></VersioningConfiguration>" + ); + + Ok(()) + } + + #[test] fn delete_result() -> Result<(), ApiError> { let delete_result = DeleteResult { xmlns: (), |