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