rustfs_obs/entry/
args.rs

1// Copyright 2024 RustFS Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use crate::entry::ObjectVersion;
16use serde::{Deserialize, Serialize};
17use std::collections::HashMap;
18
19/// Args - defines the arguments for API operations
20/// Args is used to define the arguments for API operations.
21///
22/// # Example
23/// ```
24/// use rustfs_obs::Args;
25/// use std::collections::HashMap;
26///
27/// let args = Args::new()
28///     .set_bucket(Some("my-bucket".to_string()))
29///     .set_object(Some("my-object".to_string()))
30///     .set_version_id(Some("123".to_string()))
31///     .set_metadata(Some(HashMap::new()));
32/// ```
33#[derive(Debug, Clone, Serialize, Deserialize, Default, Eq, PartialEq)]
34pub struct Args {
35    #[serde(rename = "bucket", skip_serializing_if = "Option::is_none")]
36    pub bucket: Option<String>,
37    #[serde(rename = "object", skip_serializing_if = "Option::is_none")]
38    pub object: Option<String>,
39    #[serde(rename = "versionId", skip_serializing_if = "Option::is_none")]
40    pub version_id: Option<String>,
41    #[serde(rename = "objects", skip_serializing_if = "Option::is_none")]
42    pub objects: Option<Vec<ObjectVersion>>,
43    #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")]
44    pub metadata: Option<HashMap<String, String>>,
45}
46
47impl Args {
48    /// Create a new Args object
49    pub fn new() -> Self {
50        Args {
51            bucket: None,
52            object: None,
53            version_id: None,
54            objects: None,
55            metadata: None,
56        }
57    }
58
59    /// Set the bucket
60    pub fn set_bucket(mut self, bucket: Option<String>) -> Self {
61        self.bucket = bucket;
62        self
63    }
64
65    /// Set the object
66    pub fn set_object(mut self, object: Option<String>) -> Self {
67        self.object = object;
68        self
69    }
70
71    /// Set the version ID
72    pub fn set_version_id(mut self, version_id: Option<String>) -> Self {
73        self.version_id = version_id;
74        self
75    }
76
77    /// Set the objects
78    pub fn set_objects(mut self, objects: Option<Vec<ObjectVersion>>) -> Self {
79        self.objects = objects;
80        self
81    }
82
83    /// Set the metadata
84    pub fn set_metadata(mut self, metadata: Option<HashMap<String, String>>) -> Self {
85        self.metadata = metadata;
86        self
87    }
88}