opendal/services/azdls/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/// Azure Data Lake Storage Gen2 Support.
25#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
26pub struct AzdlsConfig {
27 /// Root of this backend.
28 pub root: Option<String>,
29 /// Filesystem name of this backend.
30 pub filesystem: String,
31 /// Endpoint of this backend.
32 pub endpoint: Option<String>,
33 /// Account name of this backend.
34 pub account_name: Option<String>,
35 /// Account key of this backend.
36 /// - required for shared_key authentication
37 pub account_key: Option<String>,
38 /// client_secret
39 /// The client secret of the service principal.
40 /// - required for client_credentials authentication
41 pub client_secret: Option<String>,
42 /// tenant_id
43 /// The tenant id of the service principal.
44 /// - required for client_credentials authentication
45 pub tenant_id: Option<String>,
46 /// client_id
47 /// The client id of the service principal.
48 /// - required for client_credentials authentication
49 pub client_id: Option<String>,
50 /// sas_token
51 /// The shared access signature token.
52 /// - required for sas authentication
53 pub sas_token: Option<String>,
54 /// authority_host
55 /// The authority host of the service principal.
56 /// - required for client_credentials authentication
57 /// - default value: `https://login.microsoftonline.com`
58 pub authority_host: Option<String>,
59}
60
61impl Debug for AzdlsConfig {
62 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
63 let mut ds = f.debug_struct("AzdlsConfig");
64
65 ds.field("root", &self.root);
66 ds.field("filesystem", &self.filesystem);
67 ds.field("endpoint", &self.endpoint);
68
69 if self.account_name.is_some() {
70 ds.field("account_name", &"<redacted>");
71 }
72 if self.account_key.is_some() {
73 ds.field("account_key", &"<redacted>");
74 }
75 if self.client_secret.is_some() {
76 ds.field("client_secret", &"<redacted>");
77 }
78 if self.tenant_id.is_some() {
79 ds.field("tenant_id", &"<redacted>");
80 }
81 if self.client_id.is_some() {
82 ds.field("client_id", &"<redacted>");
83 }
84 if self.sas_token.is_some() {
85 ds.field("sas_token", &"<redacted>");
86 }
87 ds.finish()
88 }
89}