qiniu_apis/storage/
stat_object.rs

1// THIS FILE IS GENERATED BY api-generator, DO NOT EDIT DIRECTLY!
2//
3#[derive(Debug, Clone, Default)]
4#[doc = "调用 API 所用的路径参数"]
5pub struct PathParams {
6    r#entry: Option<std::borrow::Cow<'static, str>>,
7    extended_segments: Vec<std::borrow::Cow<'static, str>>,
8}
9impl PathParams {
10    #[inline]
11    #[must_use]
12    #[doc = "追加新的路径段"]
13    pub fn push_segment(mut self, segment: impl Into<std::borrow::Cow<'static, str>>) -> Self {
14        self.extended_segments.push(segment.into());
15        self
16    }
17    fn build(self) -> Vec<std::borrow::Cow<'static, str>> {
18        let mut all_segments: Vec<_> = Default::default();
19        if let Some(segment) = self.r#entry {
20            all_segments.push(segment);
21        }
22        all_segments.extend(self.extended_segments);
23        all_segments
24    }
25}
26impl PathParams {
27    #[inline]
28    #[must_use]
29    #[doc = "指定目标对象空间与目标对象名称"]
30    pub fn set_entry_as_str(mut self, value: impl Into<std::borrow::Cow<'static, str>>) -> Self {
31        self.r#entry = Some(qiniu_utils::base64::urlsafe(value.into().as_bytes()).into());
32        self
33    }
34}
35#[derive(Debug, Clone, Default)]
36#[doc = "调用 API 所用的 URL 查询参数"]
37pub struct QueryParams<'a> {
38    map: indexmap::IndexMap<qiniu_http_client::QueryPairKey<'a>, qiniu_http_client::QueryPairValue<'a>>,
39}
40impl<'a> QueryParams<'a> {
41    #[inline]
42    #[must_use]
43    #[doc = "插入一个新的查询参数对"]
44    pub fn insert(
45        mut self,
46        query_pair_key: qiniu_http_client::QueryPairKey<'a>,
47        query_pair_value: qiniu_http_client::QueryPairValue<'a>,
48    ) -> Self {
49        self.map.insert(query_pair_key, query_pair_value);
50        self
51    }
52    fn build(self) -> Vec<qiniu_http_client::QueryPair<'a>> {
53        Vec::from_iter(self.map)
54    }
55}
56impl<'a> From<QueryParams<'a>> for Vec<qiniu_http_client::QueryPair<'a>> {
57    #[inline]
58    fn from(map: QueryParams<'a>) -> Self {
59        map.build()
60    }
61}
62impl<'a> QueryParams<'a> {
63    #[inline]
64    #[must_use]
65    #[doc = "如果文件是通过分片上传的,是否返回对应的分片信息"]
66    pub fn set_need_parts_as_bool(self, value: bool) -> Self {
67        self.insert("needparts".into(), value.to_string().into())
68    }
69}
70#[derive(Clone, Debug, serde :: Serialize, serde :: Deserialize)]
71#[serde(transparent)]
72#[doc = "获取 API 所用的响应体参数"]
73pub struct ResponseBody(serde_json::Value);
74impl ResponseBody {
75    #[allow(dead_code)]
76    pub(crate) fn new(value: serde_json::Value) -> Self {
77        Self(value)
78    }
79}
80impl Default for ResponseBody {
81    #[inline]
82    fn default() -> Self {
83        Self(serde_json::Value::Object(Default::default()))
84    }
85}
86impl From<ResponseBody> for serde_json::Value {
87    #[inline]
88    fn from(val: ResponseBody) -> Self {
89        val.0
90    }
91}
92impl AsRef<serde_json::Value> for ResponseBody {
93    #[inline]
94    fn as_ref(&self) -> &serde_json::Value {
95        &self.0
96    }
97}
98impl AsMut<serde_json::Value> for ResponseBody {
99    #[inline]
100    fn as_mut(&mut self) -> &mut serde_json::Value {
101        &mut self.0
102    }
103}
104impl ResponseBody {
105    #[doc = "获取 对象大小,单位为字节"]
106    pub fn get_size_as_i64(&self) -> i64 {
107        self.0.as_object().unwrap().get("fsize").unwrap().as_i64().unwrap()
108    }
109}
110impl ResponseBody {
111    #[doc = "设置 对象大小,单位为字节"]
112    pub fn set_size_as_i64(&mut self, new: i64) -> Option<i64> {
113        self.0
114            .as_object_mut()
115            .unwrap()
116            .insert("fsize".to_owned(), new.into())
117            .and_then(|val| val.as_i64())
118    }
119}
120impl ResponseBody {
121    #[doc = "获取 对象大小,单位为字节"]
122    pub fn get_size_as_u64(&self) -> u64 {
123        self.0.as_object().unwrap().get("fsize").unwrap().as_u64().unwrap()
124    }
125}
126impl ResponseBody {
127    #[doc = "设置 对象大小,单位为字节"]
128    pub fn set_size_as_u64(&mut self, new: u64) -> Option<u64> {
129        self.0
130            .as_object_mut()
131            .unwrap()
132            .insert("fsize".to_owned(), new.into())
133            .and_then(|val| val.as_u64())
134    }
135}
136impl ResponseBody {
137    #[doc = "获取 对象哈希值"]
138    pub fn get_hash_as_str(&self) -> &str {
139        self.0.as_object().unwrap().get("hash").unwrap().as_str().unwrap()
140    }
141}
142impl ResponseBody {
143    #[doc = "设置 对象哈希值"]
144    pub fn set_hash_as_str(&mut self, new: String) -> Option<String> {
145        self.0
146            .as_object_mut()
147            .unwrap()
148            .insert("hash".to_owned(), new.into())
149            .and_then(|val| match val {
150                serde_json::Value::String(s) => Some(s),
151                _ => None,
152            })
153    }
154}
155impl ResponseBody {
156    #[doc = "获取 对象 MIME 类型"]
157    pub fn get_mime_type_as_str(&self) -> &str {
158        self.0.as_object().unwrap().get("mimeType").unwrap().as_str().unwrap()
159    }
160}
161impl ResponseBody {
162    #[doc = "设置 对象 MIME 类型"]
163    pub fn set_mime_type_as_str(&mut self, new: String) -> Option<String> {
164        self.0
165            .as_object_mut()
166            .unwrap()
167            .insert("mimeType".to_owned(), new.into())
168            .and_then(|val| match val {
169                serde_json::Value::String(s) => Some(s),
170                _ => None,
171            })
172    }
173}
174impl ResponseBody {
175    #[doc = "获取 对象存储类型,`0` 表示普通存储,`1` 表示低频存储,`2` 表示归档存储"]
176    pub fn get_type_as_i64(&self) -> i64 {
177        self.0.as_object().unwrap().get("type").unwrap().as_i64().unwrap()
178    }
179}
180impl ResponseBody {
181    #[doc = "设置 对象存储类型,`0` 表示普通存储,`1` 表示低频存储,`2` 表示归档存储"]
182    pub fn set_type_as_i64(&mut self, new: i64) -> Option<i64> {
183        self.0
184            .as_object_mut()
185            .unwrap()
186            .insert("type".to_owned(), new.into())
187            .and_then(|val| val.as_i64())
188    }
189}
190impl ResponseBody {
191    #[doc = "获取 对象存储类型,`0` 表示普通存储,`1` 表示低频存储,`2` 表示归档存储"]
192    pub fn get_type_as_u64(&self) -> u64 {
193        self.0.as_object().unwrap().get("type").unwrap().as_u64().unwrap()
194    }
195}
196impl ResponseBody {
197    #[doc = "设置 对象存储类型,`0` 表示普通存储,`1` 表示低频存储,`2` 表示归档存储"]
198    pub fn set_type_as_u64(&mut self, new: u64) -> Option<u64> {
199        self.0
200            .as_object_mut()
201            .unwrap()
202            .insert("type".to_owned(), new.into())
203            .and_then(|val| val.as_u64())
204    }
205}
206impl ResponseBody {
207    #[doc = "获取 文件上传时间,UNIX 时间戳格式,单位为 100 纳秒"]
208    pub fn get_put_time_as_i64(&self) -> i64 {
209        self.0.as_object().unwrap().get("putTime").unwrap().as_i64().unwrap()
210    }
211}
212impl ResponseBody {
213    #[doc = "设置 文件上传时间,UNIX 时间戳格式,单位为 100 纳秒"]
214    pub fn set_put_time_as_i64(&mut self, new: i64) -> Option<i64> {
215        self.0
216            .as_object_mut()
217            .unwrap()
218            .insert("putTime".to_owned(), new.into())
219            .and_then(|val| val.as_i64())
220    }
221}
222impl ResponseBody {
223    #[doc = "获取 文件上传时间,UNIX 时间戳格式,单位为 100 纳秒"]
224    pub fn get_put_time_as_u64(&self) -> u64 {
225        self.0.as_object().unwrap().get("putTime").unwrap().as_u64().unwrap()
226    }
227}
228impl ResponseBody {
229    #[doc = "设置 文件上传时间,UNIX 时间戳格式,单位为 100 纳秒"]
230    pub fn set_put_time_as_u64(&mut self, new: u64) -> Option<u64> {
231        self.0
232            .as_object_mut()
233            .unwrap()
234            .insert("putTime".to_owned(), new.into())
235            .and_then(|val| val.as_u64())
236    }
237}
238impl ResponseBody {
239    #[doc = "获取 归档存储文件的解冻状态,`2` 表示解冻完成,`1` 表示解冻中;归档文件冻结时,不返回该字段"]
240    pub fn get_unfreezing_status_as_i64(&self) -> Option<i64> {
241        self.0
242            .as_object()
243            .and_then(|obj| obj.get("restoreStatus"))
244            .and_then(|val| val.as_i64())
245    }
246}
247impl ResponseBody {
248    #[doc = "设置 归档存储文件的解冻状态,`2` 表示解冻完成,`1` 表示解冻中;归档文件冻结时,不返回该字段"]
249    pub fn set_unfreezing_status_as_i64(&mut self, new: i64) -> Option<i64> {
250        self.0.as_object_mut().and_then(|object| {
251            object
252                .insert("restoreStatus".to_owned(), new.into())
253                .and_then(|val| val.as_i64())
254        })
255    }
256}
257impl ResponseBody {
258    #[doc = "获取 归档存储文件的解冻状态,`2` 表示解冻完成,`1` 表示解冻中;归档文件冻结时,不返回该字段"]
259    pub fn get_unfreezing_status_as_u64(&self) -> Option<u64> {
260        self.0
261            .as_object()
262            .and_then(|obj| obj.get("restoreStatus"))
263            .and_then(|val| val.as_u64())
264    }
265}
266impl ResponseBody {
267    #[doc = "设置 归档存储文件的解冻状态,`2` 表示解冻完成,`1` 表示解冻中;归档文件冻结时,不返回该字段"]
268    pub fn set_unfreezing_status_as_u64(&mut self, new: u64) -> Option<u64> {
269        self.0.as_object_mut().and_then(|object| {
270            object
271                .insert("restoreStatus".to_owned(), new.into())
272                .and_then(|val| val.as_u64())
273        })
274    }
275}
276impl ResponseBody {
277    #[doc = "获取 文件状态。`1` 表示禁用;只有禁用状态的文件才会返回该字段"]
278    pub fn get_status_as_i64(&self) -> Option<i64> {
279        self.0
280            .as_object()
281            .and_then(|obj| obj.get("status"))
282            .and_then(|val| val.as_i64())
283    }
284}
285impl ResponseBody {
286    #[doc = "设置 文件状态。`1` 表示禁用;只有禁用状态的文件才会返回该字段"]
287    pub fn set_status_as_i64(&mut self, new: i64) -> Option<i64> {
288        self.0.as_object_mut().and_then(|object| {
289            object
290                .insert("status".to_owned(), new.into())
291                .and_then(|val| val.as_i64())
292        })
293    }
294}
295impl ResponseBody {
296    #[doc = "获取 文件状态。`1` 表示禁用;只有禁用状态的文件才会返回该字段"]
297    pub fn get_status_as_u64(&self) -> Option<u64> {
298        self.0
299            .as_object()
300            .and_then(|obj| obj.get("status"))
301            .and_then(|val| val.as_u64())
302    }
303}
304impl ResponseBody {
305    #[doc = "设置 文件状态。`1` 表示禁用;只有禁用状态的文件才会返回该字段"]
306    pub fn set_status_as_u64(&mut self, new: u64) -> Option<u64> {
307        self.0.as_object_mut().and_then(|object| {
308            object
309                .insert("status".to_owned(), new.into())
310                .and_then(|val| val.as_u64())
311        })
312    }
313}
314impl ResponseBody {
315    #[doc = "获取 对象 MD5 值,只有通过直传文件和追加文件 API 上传的文件,服务端确保有该字段返回"]
316    pub fn get_md_5_as_str(&self) -> Option<&str> {
317        self.0
318            .as_object()
319            .and_then(|obj| obj.get("md5"))
320            .and_then(|val| val.as_str())
321    }
322}
323impl ResponseBody {
324    #[doc = "设置 对象 MD5 值,只有通过直传文件和追加文件 API 上传的文件,服务端确保有该字段返回"]
325    pub fn set_md_5_as_str(&mut self, new: String) -> Option<String> {
326        self.0.as_object_mut().and_then(|object| {
327            object.insert("md5".to_owned(), new.into()).and_then(|val| match val {
328                serde_json::Value::String(s) => Some(s),
329                _ => None,
330            })
331        })
332    }
333}
334impl ResponseBody {
335    #[doc = "获取 文件过期删除日期,UNIX 时间戳格式,文件在设置过期时间后才会返回该字段"]
336    pub fn get_expiration_time_as_i64(&self) -> Option<i64> {
337        self.0
338            .as_object()
339            .and_then(|obj| obj.get("expiration"))
340            .and_then(|val| val.as_i64())
341    }
342}
343impl ResponseBody {
344    #[doc = "设置 文件过期删除日期,UNIX 时间戳格式,文件在设置过期时间后才会返回该字段"]
345    pub fn set_expiration_time_as_i64(&mut self, new: i64) -> Option<i64> {
346        self.0.as_object_mut().and_then(|object| {
347            object
348                .insert("expiration".to_owned(), new.into())
349                .and_then(|val| val.as_i64())
350        })
351    }
352}
353impl ResponseBody {
354    #[doc = "获取 文件过期删除日期,UNIX 时间戳格式,文件在设置过期时间后才会返回该字段"]
355    pub fn get_expiration_time_as_u64(&self) -> Option<u64> {
356        self.0
357            .as_object()
358            .and_then(|obj| obj.get("expiration"))
359            .and_then(|val| val.as_u64())
360    }
361}
362impl ResponseBody {
363    #[doc = "设置 文件过期删除日期,UNIX 时间戳格式,文件在设置过期时间后才会返回该字段"]
364    pub fn set_expiration_time_as_u64(&mut self, new: u64) -> Option<u64> {
365        self.0.as_object_mut().and_then(|object| {
366            object
367                .insert("expiration".to_owned(), new.into())
368                .and_then(|val| val.as_u64())
369        })
370    }
371}
372impl ResponseBody {
373    #[doc = "获取 文件生命周期中转为低频存储的日期,UNIX 时间戳格式,文件在设置转低频后才会返回该字段"]
374    pub fn get_transition_to_ia_time_as_i64(&self) -> Option<i64> {
375        self.0
376            .as_object()
377            .and_then(|obj| obj.get("transitionToIA"))
378            .and_then(|val| val.as_i64())
379    }
380}
381impl ResponseBody {
382    #[doc = "设置 文件生命周期中转为低频存储的日期,UNIX 时间戳格式,文件在设置转低频后才会返回该字段"]
383    pub fn set_transition_to_ia_time_as_i64(&mut self, new: i64) -> Option<i64> {
384        self.0.as_object_mut().and_then(|object| {
385            object
386                .insert("transitionToIA".to_owned(), new.into())
387                .and_then(|val| val.as_i64())
388        })
389    }
390}
391impl ResponseBody {
392    #[doc = "获取 文件生命周期中转为低频存储的日期,UNIX 时间戳格式,文件在设置转低频后才会返回该字段"]
393    pub fn get_transition_to_ia_time_as_u64(&self) -> Option<u64> {
394        self.0
395            .as_object()
396            .and_then(|obj| obj.get("transitionToIA"))
397            .and_then(|val| val.as_u64())
398    }
399}
400impl ResponseBody {
401    #[doc = "设置 文件生命周期中转为低频存储的日期,UNIX 时间戳格式,文件在设置转低频后才会返回该字段"]
402    pub fn set_transition_to_ia_time_as_u64(&mut self, new: u64) -> Option<u64> {
403        self.0.as_object_mut().and_then(|object| {
404            object
405                .insert("transitionToIA".to_owned(), new.into())
406                .and_then(|val| val.as_u64())
407        })
408    }
409}
410impl ResponseBody {
411    #[doc = "获取 文件生命周期中转为归档存储的日期,UNIX 时间戳格式,文件在设置转归档后才会返回该字段"]
412    pub fn get_transition_to_archive_time_as_i64(&self) -> Option<i64> {
413        self.0
414            .as_object()
415            .and_then(|obj| obj.get("transitionToARCHIVE"))
416            .and_then(|val| val.as_i64())
417    }
418}
419impl ResponseBody {
420    #[doc = "设置 文件生命周期中转为归档存储的日期,UNIX 时间戳格式,文件在设置转归档后才会返回该字段"]
421    pub fn set_transition_to_archive_time_as_i64(&mut self, new: i64) -> Option<i64> {
422        self.0.as_object_mut().and_then(|object| {
423            object
424                .insert("transitionToARCHIVE".to_owned(), new.into())
425                .and_then(|val| val.as_i64())
426        })
427    }
428}
429impl ResponseBody {
430    #[doc = "获取 文件生命周期中转为归档存储的日期,UNIX 时间戳格式,文件在设置转归档后才会返回该字段"]
431    pub fn get_transition_to_archive_time_as_u64(&self) -> Option<u64> {
432        self.0
433            .as_object()
434            .and_then(|obj| obj.get("transitionToARCHIVE"))
435            .and_then(|val| val.as_u64())
436    }
437}
438impl ResponseBody {
439    #[doc = "设置 文件生命周期中转为归档存储的日期,UNIX 时间戳格式,文件在设置转归档后才会返回该字段"]
440    pub fn set_transition_to_archive_time_as_u64(&mut self, new: u64) -> Option<u64> {
441        self.0.as_object_mut().and_then(|object| {
442            object
443                .insert("transitionToARCHIVE".to_owned(), new.into())
444                .and_then(|val| val.as_u64())
445        })
446    }
447}
448impl ResponseBody {
449    #[doc = "获取 文件生命周期中转为深度归档存储的日期,UNIX 时间戳格式,文件在设置转深度归档后才会返回该字段"]
450    pub fn get_transition_to_deep_archive_time_as_i64(&self) -> Option<i64> {
451        self.0
452            .as_object()
453            .and_then(|obj| obj.get("transitionToDeepArchive"))
454            .and_then(|val| val.as_i64())
455    }
456}
457impl ResponseBody {
458    #[doc = "设置 文件生命周期中转为深度归档存储的日期,UNIX 时间戳格式,文件在设置转深度归档后才会返回该字段"]
459    pub fn set_transition_to_deep_archive_time_as_i64(&mut self, new: i64) -> Option<i64> {
460        self.0.as_object_mut().and_then(|object| {
461            object
462                .insert("transitionToDeepArchive".to_owned(), new.into())
463                .and_then(|val| val.as_i64())
464        })
465    }
466}
467impl ResponseBody {
468    #[doc = "获取 文件生命周期中转为深度归档存储的日期,UNIX 时间戳格式,文件在设置转深度归档后才会返回该字段"]
469    pub fn get_transition_to_deep_archive_time_as_u64(&self) -> Option<u64> {
470        self.0
471            .as_object()
472            .and_then(|obj| obj.get("transitionToDeepArchive"))
473            .and_then(|val| val.as_u64())
474    }
475}
476impl ResponseBody {
477    #[doc = "设置 文件生命周期中转为深度归档存储的日期,UNIX 时间戳格式,文件在设置转深度归档后才会返回该字段"]
478    pub fn set_transition_to_deep_archive_time_as_u64(&mut self, new: u64) -> Option<u64> {
479        self.0.as_object_mut().and_then(|object| {
480            object
481                .insert("transitionToDeepArchive".to_owned(), new.into())
482                .and_then(|val| val.as_u64())
483        })
484    }
485}
486impl ResponseBody {
487    #[doc = "获取 文件生命周期中转为归档直读存储的日期,UNIX 时间戳格式,文件在设置转归档直读后才会返回该字段"]
488    pub fn get_transition_to_archive_ir_time_as_i64(&self) -> Option<i64> {
489        self.0
490            .as_object()
491            .and_then(|obj| obj.get("transitionToArchiveIR"))
492            .and_then(|val| val.as_i64())
493    }
494}
495impl ResponseBody {
496    #[doc = "设置 文件生命周期中转为归档直读存储的日期,UNIX 时间戳格式,文件在设置转归档直读后才会返回该字段"]
497    pub fn set_transition_to_archive_ir_time_as_i64(&mut self, new: i64) -> Option<i64> {
498        self.0.as_object_mut().and_then(|object| {
499            object
500                .insert("transitionToArchiveIR".to_owned(), new.into())
501                .and_then(|val| val.as_i64())
502        })
503    }
504}
505impl ResponseBody {
506    #[doc = "获取 文件生命周期中转为归档直读存储的日期,UNIX 时间戳格式,文件在设置转归档直读后才会返回该字段"]
507    pub fn get_transition_to_archive_ir_time_as_u64(&self) -> Option<u64> {
508        self.0
509            .as_object()
510            .and_then(|obj| obj.get("transitionToArchiveIR"))
511            .and_then(|val| val.as_u64())
512    }
513}
514impl ResponseBody {
515    #[doc = "设置 文件生命周期中转为归档直读存储的日期,UNIX 时间戳格式,文件在设置转归档直读后才会返回该字段"]
516    pub fn set_transition_to_archive_ir_time_as_u64(&mut self, new: u64) -> Option<u64> {
517        self.0.as_object_mut().and_then(|object| {
518            object
519                .insert("transitionToArchiveIR".to_owned(), new.into())
520                .and_then(|val| val.as_u64())
521        })
522    }
523}
524#[derive(Clone, Debug, serde :: Serialize, serde :: Deserialize)]
525#[serde(transparent)]
526#[doc = "每个分片的大小"]
527pub struct PartSizes(serde_json::Value);
528impl PartSizes {
529    #[allow(dead_code)]
530    pub(crate) fn new(value: serde_json::Value) -> Self {
531        Self(value)
532    }
533}
534impl Default for PartSizes {
535    #[inline]
536    fn default() -> Self {
537        Self(serde_json::Value::Array(Default::default()))
538    }
539}
540impl From<PartSizes> for serde_json::Value {
541    #[inline]
542    fn from(val: PartSizes) -> Self {
543        val.0
544    }
545}
546impl AsRef<serde_json::Value> for PartSizes {
547    #[inline]
548    fn as_ref(&self) -> &serde_json::Value {
549        &self.0
550    }
551}
552impl AsMut<serde_json::Value> for PartSizes {
553    #[inline]
554    fn as_mut(&mut self) -> &mut serde_json::Value {
555        &mut self.0
556    }
557}
558impl PartSizes {
559    #[doc = "获取数组的长度"]
560    pub fn len(&self) -> usize {
561        self.0.as_array().unwrap().len()
562    }
563    #[doc = "数组是否为空"]
564    pub fn is_empty(&self) -> bool {
565        self.0.as_array().unwrap().is_empty()
566    }
567}
568impl PartSizes {
569    #[doc = "解析 JSON 得到整型列表"]
570    pub fn to_i64_vec(&self) -> Vec<i64> {
571        self.0
572            .as_array()
573            .unwrap()
574            .iter()
575            .map(|ele| ele.as_i64().unwrap())
576            .collect()
577    }
578}
579impl PartSizes {
580    #[doc = "解析 JSON 得到无符号整型列表"]
581    pub fn to_u64_vec(&self) -> Vec<u64> {
582        self.0
583            .as_array()
584            .unwrap()
585            .iter()
586            .map(|ele| ele.as_u64().unwrap())
587            .collect()
588    }
589}
590impl PartSizes {
591    #[doc = "在列表的指定位置移出 JSON i64 整型"]
592    pub fn remove_as_i64(&mut self, index: usize) -> Option<i64> {
593        match self.0.as_array_mut().unwrap().remove(index) {
594            serde_json::Value::Number(s) => s.as_i64(),
595            _ => None,
596        }
597    }
598}
599impl PartSizes {
600    #[doc = "在列表尾部取出 JSON i64 整型"]
601    pub fn pop_as_i64(&mut self) -> Option<i64> {
602        self.0.as_array_mut().unwrap().pop().and_then(|val| match val {
603            serde_json::Value::Number(s) => s.as_i64(),
604            _ => None,
605        })
606    }
607}
608impl PartSizes {
609    #[doc = "在列表的指定位置移出 JSON u64 整型"]
610    pub fn remove_as_u64(&mut self, index: usize) -> Option<u64> {
611        match self.0.as_array_mut().unwrap().remove(index) {
612            serde_json::Value::Number(s) => s.as_u64(),
613            _ => None,
614        }
615    }
616}
617impl PartSizes {
618    #[doc = "在列表尾部取出 JSON u64 整型"]
619    pub fn pop_as_u64(&mut self) -> Option<u64> {
620        self.0.as_array_mut().unwrap().pop().and_then(|val| match val {
621            serde_json::Value::Number(s) => s.as_u64(),
622            _ => None,
623        })
624    }
625}
626impl From<Vec<i8>> for PartSizes {
627    #[inline]
628    fn from(val: Vec<i8>) -> Self {
629        Self(serde_json::Value::from(val))
630    }
631}
632impl PartSizes {
633    #[doc = "在列表的指定位置插入 JSON i8 整型"]
634    pub fn insert_i8(&mut self, index: usize, val: i8) {
635        self.0.as_array_mut().unwrap().insert(index, val.into());
636    }
637}
638impl PartSizes {
639    #[doc = "在列表尾部追加 JSON i8 整型"]
640    pub fn push_i8(&mut self, val: i8) {
641        self.0.as_array_mut().unwrap().push(val.into());
642    }
643}
644impl From<Vec<i16>> for PartSizes {
645    #[inline]
646    fn from(val: Vec<i16>) -> Self {
647        Self(serde_json::Value::from(val))
648    }
649}
650impl PartSizes {
651    #[doc = "在列表的指定位置插入 JSON i16 整型"]
652    pub fn insert_i16(&mut self, index: usize, val: i16) {
653        self.0.as_array_mut().unwrap().insert(index, val.into());
654    }
655}
656impl PartSizes {
657    #[doc = "在列表尾部追加 JSON i16 整型"]
658    pub fn push_i16(&mut self, val: i16) {
659        self.0.as_array_mut().unwrap().push(val.into());
660    }
661}
662impl From<Vec<i32>> for PartSizes {
663    #[inline]
664    fn from(val: Vec<i32>) -> Self {
665        Self(serde_json::Value::from(val))
666    }
667}
668impl PartSizes {
669    #[doc = "在列表的指定位置插入 JSON i32 整型"]
670    pub fn insert_i32(&mut self, index: usize, val: i32) {
671        self.0.as_array_mut().unwrap().insert(index, val.into());
672    }
673}
674impl PartSizes {
675    #[doc = "在列表尾部追加 JSON i32 整型"]
676    pub fn push_i32(&mut self, val: i32) {
677        self.0.as_array_mut().unwrap().push(val.into());
678    }
679}
680impl From<Vec<i64>> for PartSizes {
681    #[inline]
682    fn from(val: Vec<i64>) -> Self {
683        Self(serde_json::Value::from(val))
684    }
685}
686impl PartSizes {
687    #[doc = "在列表的指定位置插入 JSON i64 整型"]
688    pub fn insert_i64(&mut self, index: usize, val: i64) {
689        self.0.as_array_mut().unwrap().insert(index, val.into());
690    }
691}
692impl PartSizes {
693    #[doc = "在列表尾部追加 JSON i64 整型"]
694    pub fn push_i64(&mut self, val: i64) {
695        self.0.as_array_mut().unwrap().push(val.into());
696    }
697}
698impl From<Vec<isize>> for PartSizes {
699    #[inline]
700    fn from(val: Vec<isize>) -> Self {
701        Self(serde_json::Value::from(val))
702    }
703}
704impl PartSizes {
705    #[doc = "在列表的指定位置插入 JSON isize 整型"]
706    pub fn insert_isize(&mut self, index: usize, val: isize) {
707        self.0.as_array_mut().unwrap().insert(index, val.into());
708    }
709}
710impl PartSizes {
711    #[doc = "在列表尾部追加 JSON isize 整型"]
712    pub fn push_isize(&mut self, val: isize) {
713        self.0.as_array_mut().unwrap().push(val.into());
714    }
715}
716impl From<Vec<u8>> for PartSizes {
717    #[inline]
718    fn from(val: Vec<u8>) -> Self {
719        Self(serde_json::Value::from(val))
720    }
721}
722impl PartSizes {
723    #[doc = "在列表的指定位置插入 JSON u8 整型"]
724    pub fn insert_u8(&mut self, index: usize, val: u8) {
725        self.0.as_array_mut().unwrap().insert(index, val.into());
726    }
727}
728impl PartSizes {
729    #[doc = "在列表尾部追加 JSON u8 整型"]
730    pub fn push_u8(&mut self, val: u8) {
731        self.0.as_array_mut().unwrap().push(val.into());
732    }
733}
734impl From<Vec<u16>> for PartSizes {
735    #[inline]
736    fn from(val: Vec<u16>) -> Self {
737        Self(serde_json::Value::from(val))
738    }
739}
740impl PartSizes {
741    #[doc = "在列表的指定位置插入 JSON u16 整型"]
742    pub fn insert_u16(&mut self, index: usize, val: u16) {
743        self.0.as_array_mut().unwrap().insert(index, val.into());
744    }
745}
746impl PartSizes {
747    #[doc = "在列表尾部追加 JSON u16 整型"]
748    pub fn push_u16(&mut self, val: u16) {
749        self.0.as_array_mut().unwrap().push(val.into());
750    }
751}
752impl From<Vec<u32>> for PartSizes {
753    #[inline]
754    fn from(val: Vec<u32>) -> Self {
755        Self(serde_json::Value::from(val))
756    }
757}
758impl PartSizes {
759    #[doc = "在列表的指定位置插入 JSON u32 整型"]
760    pub fn insert_u32(&mut self, index: usize, val: u32) {
761        self.0.as_array_mut().unwrap().insert(index, val.into());
762    }
763}
764impl PartSizes {
765    #[doc = "在列表尾部追加 JSON u32 整型"]
766    pub fn push_u32(&mut self, val: u32) {
767        self.0.as_array_mut().unwrap().push(val.into());
768    }
769}
770impl From<Vec<u64>> for PartSizes {
771    #[inline]
772    fn from(val: Vec<u64>) -> Self {
773        Self(serde_json::Value::from(val))
774    }
775}
776impl PartSizes {
777    #[doc = "在列表的指定位置插入 JSON u64 整型"]
778    pub fn insert_u64(&mut self, index: usize, val: u64) {
779        self.0.as_array_mut().unwrap().insert(index, val.into());
780    }
781}
782impl PartSizes {
783    #[doc = "在列表尾部追加 JSON u64 整型"]
784    pub fn push_u64(&mut self, val: u64) {
785        self.0.as_array_mut().unwrap().push(val.into());
786    }
787}
788impl From<Vec<usize>> for PartSizes {
789    #[inline]
790    fn from(val: Vec<usize>) -> Self {
791        Self(serde_json::Value::from(val))
792    }
793}
794impl PartSizes {
795    #[doc = "在列表的指定位置插入 JSON usize 整型"]
796    pub fn insert_usize(&mut self, index: usize, val: usize) {
797        self.0.as_array_mut().unwrap().insert(index, val.into());
798    }
799}
800impl PartSizes {
801    #[doc = "在列表尾部追加 JSON usize 整型"]
802    pub fn push_usize(&mut self, val: usize) {
803        self.0.as_array_mut().unwrap().push(val.into());
804    }
805}
806impl ResponseBody {
807    #[doc = "获取 每个分片的大小,如没有指定 need_parts 参数则不返回"]
808    pub fn get_parts(&self) -> Option<PartSizes> {
809        self.0
810            .as_object()
811            .and_then(|obj| obj.get("parts"))
812            .cloned()
813            .map(PartSizes::new)
814    }
815}
816impl ResponseBody {
817    #[doc = "设置 每个分片的大小,如没有指定 need_parts 参数则不返回"]
818    pub fn set_parts(&mut self, new: PartSizes) -> Option<PartSizes> {
819        self.0
820            .as_object_mut()
821            .and_then(|object| object.insert("parts".to_owned(), new.into()).map(PartSizes::new))
822    }
823}
824#[doc = "API 调用客户端"]
825#[derive(Debug, Clone)]
826pub struct Client<'client>(&'client qiniu_http_client::HttpClient);
827impl<'client> Client<'client> {
828    pub(super) fn new(http_client: &'client qiniu_http_client::HttpClient) -> Self {
829        Self(http_client)
830    }
831}
832impl<'client> Client<'client> {
833    #[inline]
834    #[doc = "创建一个新的阻塞请求,该方法的异步版本为 [`Self::new_async_request`]"]
835    pub fn new_request<E: qiniu_http_client::EndpointsProvider + 'client>(
836        &self,
837        endpoints_provider: E,
838        path_params: PathParams,
839        credential: impl qiniu_http_client::credential::CredentialProvider + Clone + 'client,
840    ) -> SyncRequestBuilder<'client, E> {
841        RequestBuilder({
842            let mut builder = self.0.get(&[qiniu_http_client::ServiceName::Rs], endpoints_provider);
843            builder.authorization(qiniu_http_client::Authorization::v2(credential));
844            builder.idempotent(qiniu_http_client::Idempotent::Default);
845            builder.path(crate::base_utils::join_path("/stat", "", path_params.build()));
846            builder.accept_json();
847            builder
848        })
849    }
850    #[inline]
851    #[cfg(feature = "async")]
852    #[doc = "创建一个新的异步请求"]
853    pub fn new_async_request<E: qiniu_http_client::EndpointsProvider + 'client>(
854        &self,
855        endpoints_provider: E,
856        path_params: PathParams,
857        credential: impl qiniu_http_client::credential::CredentialProvider + Clone + 'client,
858    ) -> AsyncRequestBuilder<'client, E> {
859        RequestBuilder({
860            let mut builder = self
861                .0
862                .async_get(&[qiniu_http_client::ServiceName::Rs], endpoints_provider);
863            builder.authorization(qiniu_http_client::Authorization::v2(credential));
864            builder.idempotent(qiniu_http_client::Idempotent::Default);
865            builder.path(crate::base_utils::join_path("/stat", "", path_params.build()));
866            builder.accept_json();
867            builder
868        })
869    }
870}
871#[derive(Debug)]
872#[doc = "API 请求构造器"]
873pub struct RequestBuilder<'req, B, E>(qiniu_http_client::RequestBuilder<'req, B, E>);
874#[doc = "API 阻塞请求构造器"]
875pub type SyncRequestBuilder<'req, E> = RequestBuilder<'req, qiniu_http_client::SyncRequestBody<'req>, E>;
876#[cfg(feature = "async")]
877#[cfg_attr(feature = "docs", doc(cfg(feature = "async")))]
878#[doc = "API 异步请求构造器"]
879pub type AsyncRequestBuilder<'req, E> = RequestBuilder<'req, qiniu_http_client::AsyncRequestBody<'req>, E>;
880impl<'req, B, E> RequestBuilder<'req, B, E> {
881    #[inline]
882    #[doc = "设置是否使用 HTTPS"]
883    pub fn use_https(&mut self, use_https: bool) -> &mut Self {
884        self.0.use_https(use_https);
885        self
886    }
887    #[inline]
888    #[doc = "设置 HTTP 协议版本"]
889    pub fn version(&mut self, version: qiniu_http_client::http::Version) -> &mut Self {
890        self.0.version(version);
891        self
892    }
893    #[inline]
894    #[doc = "设置 HTTP 请求头"]
895    pub fn headers(
896        &mut self,
897        headers: impl Into<std::borrow::Cow<'req, qiniu_http_client::http::HeaderMap>>,
898    ) -> &mut Self {
899        self.0.headers(headers);
900        self
901    }
902    #[inline]
903    #[doc = "添加 HTTP 请求头"]
904    pub fn set_header(
905        &mut self,
906        header_name: impl qiniu_http_client::http::header::IntoHeaderName,
907        header_value: impl Into<qiniu_http_client::http::HeaderValue>,
908    ) -> &mut Self {
909        self.0.set_header(header_name, header_value);
910        self
911    }
912    #[inline]
913    #[doc = "设置查询参数"]
914    pub fn query(&mut self, query: impl Into<std::borrow::Cow<'req, str>>) -> &mut Self {
915        self.0.query(query);
916        self
917    }
918    #[inline]
919    #[doc = "设置查询参数"]
920    pub fn query_pairs(&mut self, query_pairs: impl Into<Vec<qiniu_http_client::QueryPair<'req>>>) -> &mut Self {
921        self.0.query_pairs(query_pairs);
922        self
923    }
924    #[inline]
925    #[doc = "追加查询参数"]
926    pub fn append_query_pair(
927        &mut self,
928        query_pair_key: impl Into<qiniu_http_client::QueryPairKey<'req>>,
929        query_pair_value: impl Into<qiniu_http_client::QueryPairValue<'req>>,
930    ) -> &mut Self {
931        self.0.append_query_pair(query_pair_key, query_pair_value);
932        self
933    }
934    #[inline]
935    #[doc = "设置扩展信息"]
936    pub fn extensions(&mut self, extensions: qiniu_http_client::http::Extensions) -> &mut Self {
937        self.0.extensions(extensions);
938        self
939    }
940    #[doc = "添加扩展信息"]
941    #[inline]
942    pub fn add_extension<T: Send + Sync + 'static>(&mut self, val: T) -> &mut Self {
943        self.0.add_extension(val);
944        self
945    }
946    #[inline]
947    #[doc = "上传进度回调函数"]
948    pub fn on_uploading_progress(
949        &mut self,
950        callback: impl Fn(
951                &dyn qiniu_http_client::SimplifiedCallbackContext,
952                qiniu_http_client::http::TransferProgressInfo,
953            ) -> anyhow::Result<()>
954            + Send
955            + Sync
956            + 'req,
957    ) -> &mut Self {
958        self.0.on_uploading_progress(callback);
959        self
960    }
961    #[inline]
962    #[doc = "设置响应状态码回调函数"]
963    pub fn on_receive_response_status(
964        &mut self,
965        callback: impl Fn(
966                &dyn qiniu_http_client::SimplifiedCallbackContext,
967                qiniu_http_client::http::StatusCode,
968            ) -> anyhow::Result<()>
969            + Send
970            + Sync
971            + 'req,
972    ) -> &mut Self {
973        self.0.on_receive_response_status(callback);
974        self
975    }
976    #[inline]
977    #[doc = "设置响应 HTTP 头回调函数"]
978    pub fn on_receive_response_header(
979        &mut self,
980        callback: impl Fn(
981                &dyn qiniu_http_client::SimplifiedCallbackContext,
982                &qiniu_http_client::http::HeaderName,
983                &qiniu_http_client::http::HeaderValue,
984            ) -> anyhow::Result<()>
985            + Send
986            + Sync
987            + 'req,
988    ) -> &mut Self {
989        self.0.on_receive_response_header(callback);
990        self
991    }
992    #[inline]
993    #[doc = "设置域名解析前回调函数"]
994    pub fn on_to_resolve_domain(
995        &mut self,
996        callback: impl Fn(&mut dyn qiniu_http_client::CallbackContext, &str) -> anyhow::Result<()> + Send + Sync + 'req,
997    ) -> &mut Self {
998        self.0.on_to_resolve_domain(callback);
999        self
1000    }
1001    #[inline]
1002    #[doc = "设置域名解析成功回调函数"]
1003    pub fn on_domain_resolved(
1004        &mut self,
1005        callback: impl Fn(
1006                &mut dyn qiniu_http_client::CallbackContext,
1007                &str,
1008                &qiniu_http_client::ResolveAnswers,
1009            ) -> anyhow::Result<()>
1010            + Send
1011            + Sync
1012            + 'req,
1013    ) -> &mut Self {
1014        self.0.on_domain_resolved(callback);
1015        self
1016    }
1017    #[inline]
1018    #[doc = "设置 IP 地址选择前回调函数"]
1019    pub fn on_to_choose_ips(
1020        &mut self,
1021        callback: impl Fn(&mut dyn qiniu_http_client::CallbackContext, &[qiniu_http_client::IpAddrWithPort]) -> anyhow::Result<()>
1022            + Send
1023            + Sync
1024            + 'req,
1025    ) -> &mut Self {
1026        self.0.on_to_choose_ips(callback);
1027        self
1028    }
1029    #[inline]
1030    #[doc = "设置 IP 地址选择成功回调函数"]
1031    pub fn on_ips_chosen(
1032        &mut self,
1033        callback: impl Fn(
1034                &mut dyn qiniu_http_client::CallbackContext,
1035                &[qiniu_http_client::IpAddrWithPort],
1036                &[qiniu_http_client::IpAddrWithPort],
1037            ) -> anyhow::Result<()>
1038            + Send
1039            + Sync
1040            + 'req,
1041    ) -> &mut Self {
1042        self.0.on_ips_chosen(callback);
1043        self
1044    }
1045    #[inline]
1046    #[doc = "设置 HTTP 请求签名前回调函数"]
1047    pub fn on_before_request_signed(
1048        &mut self,
1049        callback: impl Fn(&mut dyn qiniu_http_client::ExtendedCallbackContext) -> anyhow::Result<()> + Send + Sync + 'req,
1050    ) -> &mut Self {
1051        self.0.on_before_request_signed(callback);
1052        self
1053    }
1054    #[inline]
1055    #[doc = "设置 HTTP 请求前回调函数"]
1056    pub fn on_after_request_signed(
1057        &mut self,
1058        callback: impl Fn(&mut dyn qiniu_http_client::ExtendedCallbackContext) -> anyhow::Result<()> + Send + Sync + 'req,
1059    ) -> &mut Self {
1060        self.0.on_after_request_signed(callback);
1061        self
1062    }
1063    #[inline]
1064    #[doc = "设置响应成功回调函数"]
1065    pub fn on_response(
1066        &mut self,
1067        callback: impl Fn(
1068                &mut dyn qiniu_http_client::ExtendedCallbackContext,
1069                &qiniu_http_client::http::ResponseParts,
1070            ) -> anyhow::Result<()>
1071            + Send
1072            + Sync
1073            + 'req,
1074    ) -> &mut Self {
1075        self.0.on_response(callback);
1076        self
1077    }
1078    #[inline]
1079    #[doc = "设置响应错误回调函数"]
1080    pub fn on_error(
1081        &mut self,
1082        callback: impl Fn(
1083                &mut dyn qiniu_http_client::ExtendedCallbackContext,
1084                &mut qiniu_http_client::ResponseError,
1085            ) -> anyhow::Result<()>
1086            + Send
1087            + Sync
1088            + 'req,
1089    ) -> &mut Self {
1090        self.0.on_error(callback);
1091        self
1092    }
1093    #[inline]
1094    #[doc = "设置退避前回调函数"]
1095    pub fn on_before_backoff(
1096        &mut self,
1097        callback: impl Fn(&mut dyn qiniu_http_client::ExtendedCallbackContext, std::time::Duration) -> anyhow::Result<()>
1098            + Send
1099            + Sync
1100            + 'req,
1101    ) -> &mut Self {
1102        self.0.on_before_backoff(callback);
1103        self
1104    }
1105    #[inline]
1106    #[doc = "设置退避后回调函数"]
1107    pub fn on_after_backoff(
1108        &mut self,
1109        callback: impl Fn(&mut dyn qiniu_http_client::ExtendedCallbackContext, std::time::Duration) -> anyhow::Result<()>
1110            + Send
1111            + Sync
1112            + 'req,
1113    ) -> &mut Self {
1114        self.0.on_after_backoff(callback);
1115        self
1116    }
1117    #[inline]
1118    #[doc = "获取 HTTP 请求构建器部分参数"]
1119    pub fn parts(&self) -> &qiniu_http_client::RequestBuilderParts<'req> {
1120        self.0.parts()
1121    }
1122    #[inline]
1123    #[doc = "获取 HTTP 请求构建器部分参数的可变引用"]
1124    pub fn parts_mut(&mut self) -> &mut qiniu_http_client::RequestBuilderParts<'req> {
1125        self.0.parts_mut()
1126    }
1127}
1128impl<'req, E: qiniu_http_client::EndpointsProvider + Clone + 'req> SyncRequestBuilder<'req, E> {
1129    #[doc = "阻塞发起 HTTP 请求"]
1130    pub fn call(&mut self) -> qiniu_http_client::ApiResult<qiniu_http_client::Response<ResponseBody>> {
1131        let request = &mut self.0;
1132        let response = request.call()?;
1133        let parsed = response.parse_json()?;
1134        Ok(parsed)
1135    }
1136}
1137#[cfg(feature = "async")]
1138impl<'req, E: qiniu_http_client::EndpointsProvider + Clone + 'req> AsyncRequestBuilder<'req, E> {
1139    #[doc = "异步发起 HTTP 请求"]
1140    pub async fn call(&mut self) -> qiniu_http_client::ApiResult<qiniu_http_client::Response<ResponseBody>> {
1141        let request = &mut self.0;
1142        let response = request.call().await?;
1143        let parsed = response.parse_json().await?;
1144        Ok(parsed)
1145    }
1146}