Skip to main content

pdk_script/bindings/
authentication.rs

1// Copyright (c) 2026, Salesforce, Inc.,
2// All rights reserved.
3// For full license text, see the LICENSE.txt file
4
5use std::collections::HashMap;
6
7use crate::Value;
8
9/// Binding for the top-level `authentication` variable.
10pub trait AuthenticationBinding {
11    /// Returns the `authentication.clientId` value.
12    fn client_id(&self) -> Option<String>;
13
14    /// Returns the `authentication.clientName` value.
15    fn client_name(&self) -> Option<String>;
16
17    /// Returns the `authentication.principal` value.
18    fn principal(&self) -> Option<String>;
19
20    /// Returns the `authentication.properties` value.
21    fn properties(&self) -> Option<Value>;
22
23    /// Returns the `authentication.properties` value as a map.
24    fn properties_map(&self) -> HashMap<String, Value>;
25}
26
27impl<K: AuthenticationBinding> AuthenticationBinding for Option<K> {
28    fn client_id(&self) -> Option<String> {
29        self.as_ref().and_then(K::client_id)
30    }
31
32    fn client_name(&self) -> Option<String> {
33        self.as_ref().and_then(K::client_name)
34    }
35
36    fn principal(&self) -> Option<String> {
37        self.as_ref().and_then(K::principal)
38    }
39
40    fn properties(&self) -> Option<Value> {
41        self.as_ref().and_then(K::properties)
42    }
43
44    fn properties_map(&self) -> HashMap<String, Value> {
45        self.as_ref().map(K::properties_map).unwrap_or_default()
46    }
47}