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    ///
53    /// - this field if it's `is_some`
54    /// - env value: [`ALIBABA_CLOUD_ACCESS_KEY_ID`]
55    pub access_key_id: Option<String>,
56    /// Access key secret for oss.
57    ///
58    /// - this field if it's `is_some`
59    /// - env value: [`ALIBABA_CLOUD_ACCESS_KEY_SECRET`]
60    pub access_key_secret: Option<String>,
61    /// `security_token` will be loaded from
62    ///
63    /// - this field if it's `is_some`
64    /// - env value: [`ALIBABA_CLOUD_SECURITY_TOKEN`]
65    pub security_token: Option<String>,
66    /// The size of max batch operations.
67    #[deprecated(
68        since = "0.52.0",
69        note = "Please use `delete_max_size` instead of `batch_max_operations`"
70    )]
71    pub batch_max_operations: Option<usize>,
72    /// The size of max delete operations.
73    pub delete_max_size: Option<usize>,
74    /// If `role_arn` is set, we will use already known config as source
75    /// credential to assume role with `role_arn`.
76    ///
77    /// - this field if it's `is_some`
78    /// - env value: [`ALIBABA_CLOUD_ROLE_ARN`]
79    pub role_arn: Option<String>,
80    /// role_session_name for this backend.
81    pub role_session_name: Option<String>,
82    /// `oidc_provider_arn` will be loaded from
83    ///
84    /// - this field if it's `is_some`
85    /// - env value: [`ALIBABA_CLOUD_OIDC_PROVIDER_ARN`]
86    pub oidc_provider_arn: Option<String>,
87    /// `oidc_token_file` will be loaded from
88    ///
89    /// - this field if it's `is_some`
90    /// - env value: [`ALIBABA_CLOUD_OIDC_TOKEN_FILE`]
91    pub oidc_token_file: Option<String>,
92    /// `sts_endpoint` will be loaded from
93    ///
94    /// - this field if it's `is_some`
95    /// - env value: [`ALIBABA_CLOUD_STS_ENDPOINT`]
96    pub sts_endpoint: Option<String>,
97}
98
99impl Debug for OssConfig {
100    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
101        let mut d = f.debug_struct("Builder");
102        d.field("root", &self.root)
103            .field("bucket", &self.bucket)
104            .field("endpoint", &self.endpoint)
105            .field("allow_anonymous", &self.allow_anonymous);
106
107        d.finish_non_exhaustive()
108    }
109}