Skip to main content

pdk_script/bindings/
authentication.rs

1// Copyright 2023 Salesforce, Inc. All rights reserved.
2
3use crate::Value;
4
5/// Binding for the top-level `authentication` variable.
6pub trait AuthenticationBinding {
7    /// Returns the `authentication.clientId` value.
8    fn client_id(&self) -> Option<String>;
9
10    /// Returns the `authentication.clientName` value.
11    fn client_name(&self) -> Option<String>;
12
13    /// Returns the `authentication.principal` value.
14    fn principal(&self) -> Option<String>;
15
16    /// Returns the `authentication.properties` value.
17    fn properties(&self) -> Option<Value>;
18}
19
20impl<K: AuthenticationBinding> AuthenticationBinding for Option<K> {
21    fn client_id(&self) -> Option<String> {
22        self.as_ref().and_then(K::client_id)
23    }
24
25    fn client_name(&self) -> Option<String> {
26        self.as_ref().and_then(K::client_name)
27    }
28
29    fn principal(&self) -> Option<String> {
30        self.as_ref().and_then(K::principal)
31    }
32
33    fn properties(&self) -> Option<Value> {
34        self.as_ref().and_then(K::properties)
35    }
36}