Skip to main content

ve_tos_rust_sdk/
enumeration.rs

1/*
2 * Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17use reqwest::Method;
18use serde::{Deserialize, Serialize};
19
20use ve_tos_generic::FromRefAndDisplay;
21
22#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Deserialize)]
23pub enum ACLType {
24    #[default]
25    #[serde(rename = "private")]
26    ACLPrivate,
27    #[serde(rename = "public-read")]
28    ACLPublicRead,
29    #[serde(rename = "public-read-write")]
30    ACLPublicReadWrite,
31    #[serde(rename = "authenticated-read")]
32    ACLAuthenticatedRead,
33    #[serde(rename = "bucket-owner-read")]
34    ACLBucketOwnerRead,
35    #[serde(rename = "bucket-owner-full-control")]
36    ACLBucketOwnerFullControl,
37    #[serde(rename = "bucket-owner-entrusted")]
38    ACLBucketOwnerEntrusted,
39}
40
41
42impl ACLType {
43    pub fn as_str(&self) -> &str {
44        match self {
45            Self::ACLPrivate => "private",
46            Self::ACLPublicRead => "public-read",
47            Self::ACLPublicReadWrite => "public-read-write",
48            Self::ACLAuthenticatedRead => "authenticated-read",
49            Self::ACLBucketOwnerRead => "bucket-owner-read",
50            Self::ACLBucketOwnerFullControl => "bucket-owner-full-control",
51            Self::ACLBucketOwnerEntrusted => "bucket-owner-entrusted",
52        }
53    }
54    pub(crate) fn from(value: String) -> Option<Self> {
55        match value.as_str() {
56            "private" => Some(Self::ACLPrivate),
57            "public-read" => Some(Self::ACLPublicRead),
58            "public-read-write" => Some(Self::ACLPublicReadWrite),
59            "authenticated-read" => Some(Self::ACLAuthenticatedRead),
60            "bucket-owner-read" => Some(Self::ACLBucketOwnerRead),
61            "bucket-owner-full-control" => Some(Self::ACLBucketOwnerFullControl),
62            "bucket-owner-entrusted" => Some(Self::ACLBucketOwnerEntrusted),
63            _ => None,
64        }
65    }
66}
67
68#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Serialize, Deserialize)]
69pub enum StatusType {
70    #[default]
71    #[serde(rename = "Enabled")]
72    StatusEnabled,
73    #[serde(rename = "Disabled")]
74    StatusDisabled,
75}
76
77impl StatusType {
78    pub fn as_str(&self) -> &str {
79        match self {
80            Self::StatusEnabled => "Enabled",
81            Self::StatusDisabled => "Disabled",
82        }
83    }
84
85    pub(crate) fn from(value: impl AsRef<str>) -> Option<Self> {
86        match value.as_ref() {
87            "Enabled" => Some(Self::StatusEnabled),
88            "Disabled" => Some(Self::StatusDisabled),
89            _ => None,
90        }
91    }
92}
93#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Serialize, Deserialize)]
94pub enum VersioningStatusType {
95    #[default]
96    #[serde(rename = "")]
97    VersioningStatusNotSet,
98    #[serde(rename = "Enabled")]
99    VersioningStatusEnabled,
100    #[serde(rename = "Suspended")]
101    VersioningStatusSuspended,
102}
103
104impl VersioningStatusType {
105    pub fn as_str(&self) -> &str {
106        match self {
107            VersioningStatusType::VersioningStatusNotSet => "",
108            VersioningStatusType::VersioningStatusEnabled => "Enabled",
109            VersioningStatusType::VersioningStatusSuspended => "Suspended",
110        }
111    }
112}
113#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Serialize, Deserialize)]
114pub enum ProtocolType {
115    #[default]
116    #[serde(rename = "http")]
117    ProtocolHttp,
118    #[serde(rename = "https")]
119    ProtocolHttps,
120}
121impl ProtocolType {
122    pub fn as_str(&self) -> &str {
123        match self {
124            Self::ProtocolHttp => "http",
125            Self::ProtocolHttps => "https",
126        }
127    }
128}
129
130#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Serialize, Deserialize)]
131pub enum CertStatusType {
132    #[default]
133    #[serde(rename = "CertBound")]
134    CertStatusBound,
135    #[serde(rename = "CertUnbound")]
136    CertStatusUnbound,
137    #[serde(rename = "CertExpired")]
138    CertStatusExpired,
139}
140
141impl CertStatusType {
142    pub fn as_str(&self) -> &str {
143        match self {
144            Self::CertStatusBound => "CertBound",
145            Self::CertStatusUnbound => "CertUnbound",
146            Self::CertStatusExpired => "CertExpired",
147        }
148    }
149}
150
151#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Serialize, Deserialize)]
152pub enum AuthProtocolType {
153    #[default]
154    #[serde(rename = "tos")]
155    AuthProtocolTos,
156    #[serde(rename = "s3")]
157    AuthProtocolS3,
158}
159
160impl AuthProtocolType {
161    pub fn as_str(&self) -> &str {
162        match self {
163            Self::AuthProtocolTos => "tos",
164            Self::AuthProtocolS3 => "s3",
165        }
166    }
167}
168
169#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Serialize, Deserialize)]
170pub enum RedirectType {
171    #[default]
172    #[serde(rename = "Mirror")]
173    RedirectMirror,
174    #[serde(rename = "Async")]
175    RedirectAsync,
176}
177
178impl RedirectType {
179    pub fn as_str(&self) -> &str {
180        match self {
181            Self::RedirectMirror => "Mirror",
182            Self::RedirectAsync => "Async",
183        }
184    }
185
186    pub(crate) fn from(value: impl AsRef<str>) -> Option<Self> {
187        match value.as_ref() {
188            "Mirror" => Some(Self::RedirectMirror),
189            "Async" => Some(Self::RedirectAsync),
190            _ => None,
191        }
192    }
193}
194
195#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Serialize, Deserialize)]
196pub enum StorageClassType {
197    #[default]
198    #[serde(rename = "STANDARD")]
199    StorageClassStandard,
200    #[serde(rename = "IA")]
201    StorageClassIa,
202    #[serde(rename = "ARCHIVE_FR")]
203    StorageClassArchiveFr,
204    #[serde(rename = "INTELLIGENT_TIERING")]
205    StorageClassIntelligentTiering,
206    #[serde(rename = "COLD_ARCHIVE")]
207    StorageClassColdArchive,
208    #[serde(rename = "ARCHIVE")]
209    StorageClassArchive,
210    #[serde(rename = "DEEP_COLD_ARCHIVE")]
211    StorageClassDeepColdArchive,
212}
213
214
215impl StorageClassType {
216    pub fn as_str(&self) -> &str {
217        match self {
218            Self::StorageClassStandard => "STANDARD",
219            Self::StorageClassIa => "IA",
220            Self::StorageClassArchiveFr => "ARCHIVE_FR",
221            Self::StorageClassIntelligentTiering => "INTELLIGENT_TIERING",
222            Self::StorageClassColdArchive => "COLD_ARCHIVE",
223            Self::StorageClassArchive => "ARCHIVE",
224            Self::StorageClassDeepColdArchive => "DEEP_COLD_ARCHIVE",
225        }
226    }
227
228    pub(crate) fn from(value: impl AsRef<str>) -> Option<Self> {
229        match value.as_ref() {
230            "STANDARD" => Some(Self::StorageClassStandard),
231            "IA" => Some(Self::StorageClassIa),
232            "ARCHIVE_FR" => Some(Self::StorageClassArchiveFr),
233            "INTELLIGENT_TIERING" => Some(Self::StorageClassIntelligentTiering),
234            "COLD_ARCHIVE" => Some(Self::StorageClassColdArchive),
235            "ARCHIVE" => Some(Self::StorageClassArchive),
236            "DEEP_COLD_ARCHIVE" => Some(Self::StorageClassDeepColdArchive),
237            _ => None,
238        }
239    }
240}
241#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Serialize, Deserialize)]
242pub enum StorageClassInheritDirectiveType {
243    #[default]
244    #[serde(rename = "DESTINATION_BUCKET")]
245    StorageClassIDDestinationBucket,
246    #[serde(rename = "SOURCE_OBJECT")]
247    StorageClassIDSourceObject,
248}
249
250impl StorageClassInheritDirectiveType {
251    pub fn as_str(&self) -> &str {
252        match self {
253            Self::StorageClassIDDestinationBucket => "DESTINATION_BUCKET",
254            Self::StorageClassIDSourceObject => "SOURCE_OBJECT",
255        }
256    }
257}
258
259#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Deserialize)]
260pub enum AzRedundancyType {
261    #[default]
262    #[serde(rename = "single-az")]
263    AzRedundancySingleAz,
264    #[serde(rename = "multi-az")]
265    AzRedundancyMultiAz,
266}
267
268impl AzRedundancyType {
269    pub fn as_str(&self) -> &str {
270        match self {
271            Self::AzRedundancySingleAz => "single-az",
272            Self::AzRedundancyMultiAz => "multi-az",
273        }
274    }
275    pub(crate) fn from(value: impl AsRef<str>) -> Option<Self> {
276        match value.as_ref() {
277            "single-az" => Some(Self::AzRedundancySingleAz),
278            "multi-az" => Some(Self::AzRedundancyMultiAz),
279            _ => None,
280        }
281    }
282}
283#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Deserialize)]
284pub enum BucketType {
285    #[default]
286    #[serde(rename = "fns")]
287    BucketTypeFns,
288    #[serde(rename = "hns")]
289    BucketTypeHns,
290}
291
292impl BucketType {
293    pub fn as_str(&self) -> &str {
294        match self {
295            Self::BucketTypeFns => "fns",
296            Self::BucketTypeHns => "hns",
297        }
298    }
299    pub(crate) fn from(value: impl AsRef<str>) -> Option<Self> {
300        match value.as_ref() {
301            "fns" => Some(Self::BucketTypeFns),
302            "hns" => Some(Self::BucketTypeHns),
303            _ => None,
304        }
305    }
306}
307
308
309#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay)]
310pub enum MetadataDirectiveType {
311    #[default]
312    MetadataDirectiveCopy,
313    MetadataDirectiveReplace,
314    MetadataDirectiveReplaceNew,
315}
316
317impl MetadataDirectiveType {
318    pub fn as_str(&self) -> &str {
319        match self {
320            Self::MetadataDirectiveCopy => "COPY",
321            Self::MetadataDirectiveReplace => "REPLACE",
322            Self::MetadataDirectiveReplaceNew => "REPLACE_NEW",
323        }
324    }
325}
326
327
328#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay)]
329pub enum TaggingDirectiveType {
330    #[default]
331    TaggingDirectiveCopy,
332    TaggingDirectiveReplace,
333}
334
335impl TaggingDirectiveType {
336    pub fn as_str(&self) -> &str {
337        match self {
338            Self::TaggingDirectiveCopy => "COPY",
339            Self::TaggingDirectiveReplace => "REPLACE",
340        }
341    }
342}
343
344#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Deserialize, Serialize)]
345pub enum GranteeType {
346    #[default]
347    #[serde(rename = "Group")]
348    GranteeGroup,
349    #[serde(rename = "CanonicalUser")]
350    GranteeUser,
351}
352
353impl GranteeType {
354    pub fn as_str(&self) -> &str {
355        match self {
356            Self::GranteeGroup => "Group",
357            Self::GranteeUser => "CanonicalUser",
358        }
359    }
360}
361
362
363#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Deserialize, Serialize)]
364pub enum CannedType {
365    #[default]
366    #[serde(rename = "AllUsers")]
367    CannedAllUsers,
368    #[serde(rename = "AuthenticatedUsers")]
369    CannedAuthenticatedUsers,
370}
371
372impl CannedType {
373    pub fn as_str(&self) -> &str {
374        match self {
375            Self::CannedAllUsers => "AllUsers",
376            Self::CannedAuthenticatedUsers => "AuthenticatedUsers",
377        }
378    }
379}
380
381
382#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Deserialize, Serialize)]
383pub enum PermissionType {
384    #[default]
385    #[serde(rename = "READ")]
386    PermissionRead,
387    #[serde(rename = "READ_NON_LIST")]
388    PermissionReadNonList,
389    #[serde(rename = "WRITE")]
390    PermissionWrite,
391    #[serde(rename = "READ_ACP")]
392    PermissionReadAcp,
393    #[serde(rename = "WRITE_ACP")]
394    PermissionWriteAcp,
395    #[serde(rename = "FULL_CONTROL")]
396    PermissionFullControl,
397}
398
399impl PermissionType {
400    pub fn as_str(&self) -> &str {
401        match self {
402            Self::PermissionRead => "READ",
403            Self::PermissionReadNonList => "READ_NON_LIST",
404            Self::PermissionWrite => "WRITE",
405            Self::PermissionReadAcp => "READ_ACP",
406            Self::PermissionWriteAcp => "WRITE_ACP",
407            Self::PermissionFullControl => "FULL_CONTROL",
408        }
409    }
410}
411
412
413#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay)]
414pub enum ReplicationStatusType {
415    #[default]
416    ReplicationStatusPending,
417    ReplicationStatusComplete,
418    ReplicationStatusFailed,
419    ReplicationStatusReplica,
420}
421
422impl ReplicationStatusType {
423    pub fn as_str(&self) -> &str {
424        match self {
425            Self::ReplicationStatusPending => "PENDING",
426            Self::ReplicationStatusComplete => "COMPLETE",
427            Self::ReplicationStatusFailed => "FAILED",
428            Self::ReplicationStatusReplica => "REPLICA",
429        }
430    }
431
432    pub(crate) fn from(value: impl AsRef<str>) -> Option<Self> {
433        match value.as_ref() {
434            "PENDING" => Some(Self::ReplicationStatusPending),
435            "COMPLETE" => Some(Self::ReplicationStatusComplete),
436            "FAILED" => Some(Self::ReplicationStatusFailed),
437            "REPLICA" => Some(Self::ReplicationStatusReplica),
438            _ => None,
439        }
440    }
441}
442
443
444#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Serialize, Deserialize)]
445pub enum TierType {
446    #[default]
447    #[serde(rename = "Standard")]
448    TierStandard,
449    #[serde(rename = "Expedited")]
450    TierExpedited,
451    #[serde(rename = "Bulk")]
452    TierBulk,
453}
454
455impl TierType {
456    pub fn as_str(&self) -> &str {
457        match self {
458            Self::TierStandard => "Standard",
459            Self::TierExpedited => "Expedited",
460            Self::TierBulk => "Bulk",
461        }
462    }
463    pub(crate) fn from(value: impl AsRef<str>) -> Option<Self> {
464        match value.as_ref() {
465            "Standard" => Some(Self::TierStandard),
466            "Expedited" => Some(Self::TierExpedited),
467            "Bulk" => Some(Self::TierBulk),
468            _ => None,
469        }
470    }
471}
472
473
474#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay)]
475pub enum HttpMethodType {
476    #[default]
477    HttpMethodGet,
478    HttpMethodPut,
479    HttpMethodPost,
480    HttpMethodDelete,
481    HttpMethodHead,
482}
483
484
485impl HttpMethodType {
486    pub fn as_str(&self) -> &str {
487        match self {
488            Self::HttpMethodGet => "GET",
489            Self::HttpMethodPut => "PUT",
490            Self::HttpMethodPost => "POST",
491            Self::HttpMethodDelete => "DELETE",
492            Self::HttpMethodHead => "HEAD",
493        }
494    }
495
496    pub fn as_http_method(&self) -> Method {
497        match self {
498            Self::HttpMethodGet => Method::GET,
499            Self::HttpMethodPut => Method::PUT,
500            Self::HttpMethodPost => Method::POST,
501            Self::HttpMethodDelete => Method::DELETE,
502            Self::HttpMethodHead => Method::HEAD,
503        }
504    }
505}
506
507#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay)]
508pub enum DocPreviewSrcType {
509    #[default]
510    DocPreviewSrcTypeDoc,
511    DocPreviewSrcTypeDocx,
512    DocPreviewSrcTypePpt,
513    DocPreviewSrcTypePptx,
514    DocPreviewSrcTypeXls,
515    DocPreviewSrcTypeXlsx,
516}
517
518impl DocPreviewSrcType {
519    pub fn as_str(&self) -> &str {
520        match self {
521            Self::DocPreviewSrcTypeDoc => "doc",
522            Self::DocPreviewSrcTypeDocx => "docx",
523            Self::DocPreviewSrcTypePpt => "ppt",
524            Self::DocPreviewSrcTypePptx => "pptx",
525            Self::DocPreviewSrcTypeXls => "xls",
526            Self::DocPreviewSrcTypeXlsx => "xlsx",
527        }
528    }
529}
530
531#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay)]
532pub enum DocPreviewDstType {
533    #[default]
534    DocPreviewDstTypePdf,
535    DocPreviewDstTypeHtml,
536    DocPreviewDstTypePng,
537    DocPreviewDstTypeJpg,
538}
539
540impl DocPreviewDstType {
541    pub fn as_str(&self) -> &str {
542        match self {
543            Self::DocPreviewDstTypePdf => "pdf",
544            Self::DocPreviewDstTypeHtml => "html",
545            Self::DocPreviewDstTypePng => "png",
546            Self::DocPreviewDstTypeJpg => "jpg",
547        }
548    }
549}
550#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay)]
551pub enum ObjectLockModeType {
552    #[default]
553    ObjectLockModeCompliance
554}
555
556impl ObjectLockModeType {
557    pub fn as_str(&self) -> &str {
558        match self {
559            Self::ObjectLockModeCompliance => "COMPLIANCE"
560        }
561    }
562}
563#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Serialize, Deserialize)]
564pub enum InventoryIncludedObjType {
565    #[default]
566    #[serde(rename = "All")]
567    InventoryIncludedObjAll,
568    #[serde(rename = "Current")]
569    InventoryIncludedObjCurrent,
570}
571impl InventoryIncludedObjType {
572    pub fn as_str(&self) -> &str {
573        match self {
574            Self::InventoryIncludedObjAll => "All",
575            Self::InventoryIncludedObjCurrent => "Current",
576        }
577    }
578}
579#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Serialize, Deserialize)]
580pub enum InventoryFormatType {
581    #[default]
582    #[serde(rename = "CSV")]
583    InventoryFormatCsv
584}
585
586impl InventoryFormatType {
587    pub fn as_str(&self) -> &str {
588        match self {
589            Self::InventoryFormatCsv => "CSV",
590        }
591    }
592}
593#[derive(Debug, Clone, PartialEq, Default, FromRefAndDisplay, Serialize, Deserialize)]
594pub enum InventoryFrequencyType {
595    #[default]
596    #[serde(rename = "Daily")]
597    InventoryFrequencyDaily,
598    #[serde(rename = "Weekly")]
599    InventoryFrequencyWeekly,
600}
601
602impl InventoryFrequencyType {
603    pub fn as_str(&self) -> &str {
604        match self {
605            Self::InventoryFrequencyDaily => "Daily",
606            Self::InventoryFrequencyWeekly => "Weekly",
607        }
608    }
609}