opendal/services/oss/config.rs
1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18use std::fmt::Debug;
19use std::fmt::Formatter;
20
21use serde::Deserialize;
22use serde::Serialize;
23
24/// Config for Aliyun Object Storage Service (OSS) support.
25#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
26#[serde(default)]
27#[non_exhaustive]
28pub struct OssConfig {
29 /// Root for oss.
30 pub root: Option<String>,
31
32 /// Endpoint for oss.
33 pub endpoint: Option<String>,
34 /// Presign endpoint for oss.
35 pub presign_endpoint: Option<String>,
36 /// Bucket for oss.
37 pub bucket: String,
38
39 /// is bucket versioning enabled for this bucket
40 pub enable_versioning: bool,
41
42 // OSS features
43 /// Server side encryption for oss.
44 pub server_side_encryption: Option<String>,
45 /// Server side encryption key id for oss.
46 pub server_side_encryption_key_id: Option<String>,
47 /// Allow anonymous for oss.
48 pub allow_anonymous: bool,
49
50 // authenticate options
51 /// Access key id for oss.
52 pub access_key_id: Option<String>,
53 /// Access key secret for oss.
54 pub access_key_secret: Option<String>,
55 /// The size of max batch operations.
56 #[deprecated(
57 since = "0.52.0",
58 note = "Please use `delete_max_size` instead of `batch_max_operations`"
59 )]
60 pub batch_max_operations: Option<usize>,
61 /// The size of max delete operations.
62 pub delete_max_size: Option<usize>,
63 /// If `role_arn` is set, we will use already known config as source
64 /// credential to assume role with `role_arn`.
65 pub role_arn: Option<String>,
66 /// role_session_name for this backend.
67 pub role_session_name: Option<String>,
68 /// `oidc_provider_arn` will be loaded from
69 ///
70 /// - this field if it's `is_some`
71 /// - env value: [`ALIBABA_CLOUD_OIDC_PROVIDER_ARN`]
72 pub oidc_provider_arn: Option<String>,
73 /// `oidc_token_file` will be loaded from
74 ///
75 /// - this field if it's `is_some`
76 /// - env value: [`ALIBABA_CLOUD_OIDC_TOKEN_FILE`]
77 pub oidc_token_file: Option<String>,
78 /// `sts_endpoint` will be loaded from
79 ///
80 /// - this field if it's `is_some`
81 /// - env value: [`ALIBABA_CLOUD_STS_ENDPOINT`]
82 pub sts_endpoint: Option<String>,
83}
84
85impl Debug for OssConfig {
86 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
87 let mut d = f.debug_struct("Builder");
88 d.field("root", &self.root)
89 .field("bucket", &self.bucket)
90 .field("endpoint", &self.endpoint)
91 .field("allow_anonymous", &self.allow_anonymous);
92
93 d.finish_non_exhaustive()
94 }
95}