proxmox_api/generated/access/domains/realm/
sync.rs1#[derive(Debug, Clone)]
2pub struct SyncClient<T> {
3 client: T,
4 path: String,
5}
6impl<T> SyncClient<T>
7where
8 T: crate::client::Client,
9{
10 pub fn new(client: T, parent_path: &str) -> Self {
11 Self {
12 client,
13 path: format!("{}{}", parent_path, "/sync"),
14 }
15 }
16}
17impl<T> SyncClient<T>
18where
19 T: crate::client::Client,
20{
21 #[doc = "Syncs users and/or groups from the configured LDAP to user.cfg. NOTE: Synced groups will have the name 'name-$realm', so make sure those groups do not exist to prevent overwriting."]
22 #[doc = ""]
23 #[doc = "Permission check: and(perm(\"/access/realm/{realm}\", [\"Realm.AllocateUser\"]), perm(\"/access/groups\", [\"User.Modify\"]))"]
24 #[doc = "'Realm.AllocateUser' on '/access/realm/\\<realm\\>' and 'User.Modify' permissions to '/access/groups/'."]
25 pub async fn post(&self, params: PostParams) -> Result<String, T::Error> {
26 let path = self.path.to_string();
27 self.client.post(&path, ¶ms).await
28 }
29}
30#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
31pub struct PostParams {
32 #[serde(rename = "dry-run")]
33 #[serde(
34 serialize_with = "crate::types::serialize_bool_optional",
35 deserialize_with = "crate::types::deserialize_bool_optional"
36 )]
37 #[serde(skip_serializing_if = "Option::is_none", default)]
38 #[doc = "If set, does not write anything."]
39 #[doc = ""]
40 pub dry_run: Option<bool>,
41 #[serde(rename = "enable-new")]
42 #[serde(
43 serialize_with = "crate::types::serialize_bool_optional",
44 deserialize_with = "crate::types::deserialize_bool_optional"
45 )]
46 #[serde(skip_serializing_if = "Option::is_none", default)]
47 #[doc = "Enable newly synced users immediately."]
48 #[doc = ""]
49 pub enable_new: Option<bool>,
50 #[serde(
51 serialize_with = "crate::types::serialize_bool_optional",
52 deserialize_with = "crate::types::deserialize_bool_optional"
53 )]
54 #[serde(skip_serializing_if = "Option::is_none", default)]
55 #[doc = "DEPRECATED: use 'remove-vanished' instead. If set, uses the LDAP Directory as source of truth, deleting users or groups not returned from the sync and removing all locally modified properties of synced users. If not set, only syncs information which is present in the synced data, and does not delete or modify anything else."]
56 #[doc = ""]
57 pub full: Option<bool>,
58 #[serde(
59 serialize_with = "crate::types::serialize_bool_optional",
60 deserialize_with = "crate::types::deserialize_bool_optional"
61 )]
62 #[serde(skip_serializing_if = "Option::is_none", default)]
63 #[doc = "DEPRECATED: use 'remove-vanished' instead. Remove ACLs for users or groups which were removed from the config during a sync."]
64 #[doc = ""]
65 pub purge: Option<bool>,
66 #[serde(rename = "remove-vanished")]
67 #[serde(skip_serializing_if = "Option::is_none", default)]
68 #[doc = "A semicolon-separated list of things to remove when they or the user vanishes during a sync. The following values are possible: 'entry' removes the user/group when not returned from the sync. 'properties' removes the set properties on existing user/group that do not appear in the source (even custom ones). 'acl' removes acls when the user/group is not returned from the sync. Instead of a list it also can be 'none' (the default)."]
69 #[doc = ""]
70 pub remove_vanished: Option<RemoveVanishedStr>,
71 #[serde(skip_serializing_if = "Option::is_none", default)]
72 #[doc = "Select what to sync."]
73 #[doc = ""]
74 pub scope: Option<Scope>,
75 #[serde(
76 flatten,
77 default,
78 skip_serializing_if = "::std::collections::HashMap::is_empty"
79 )]
80 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
81}
82#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
83#[doc = "Select what to sync."]
84#[doc = ""]
85pub enum Scope {
86 #[serde(rename = "both")]
87 Both,
88 #[serde(rename = "groups")]
89 Groups,
90 #[serde(rename = "users")]
91 Users,
92}
93impl TryFrom<&str> for Scope {
94 type Error = String;
95 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
96 match value {
97 "both" => Ok(Self::Both),
98 "groups" => Ok(Self::Groups),
99 "users" => Ok(Self::Users),
100 v => Err(format!("Unknown variant {v}")),
101 }
102 }
103}
104#[derive(Debug, Clone, PartialEq, PartialOrd)]
105pub struct RemoveVanishedStr {
106 value: String,
107}
108impl crate::types::bounded_string::BoundedString for RemoveVanishedStr {
109 const MIN_LENGTH: Option<usize> = None::<usize>;
110 const MAX_LENGTH: Option<usize> = None::<usize>;
111 const DEFAULT: Option<&'static str> = Some("none");
112 const PATTERN: Option<&'static str> =
113 Some("(?:(?:(?:acl|properties|entry);)*(?:acl|properties|entry))|none");
114 const TYPE_DESCRIPTION: &'static str = "a string with pattern r\"(?:(?:(?:acl|properties|entry);)*(?:acl|properties|entry))|none\" and no length constraints";
115 fn get_value(&self) -> &str {
116 &self.value
117 }
118 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
119 Self::validate(&value)?;
120 Ok(Self { value })
121 }
122}
123impl std::convert::TryFrom<String> for RemoveVanishedStr {
124 type Error = crate::types::bounded_string::BoundedStringError;
125 fn try_from(value: String) -> Result<Self, Self::Error> {
126 crate::types::bounded_string::BoundedString::new(value)
127 }
128}
129impl ::serde::Serialize for RemoveVanishedStr {
130 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
131 where
132 S: ::serde::Serializer,
133 {
134 crate::types::bounded_string::serialize_bounded_string(self, serializer)
135 }
136}
137impl<'de> ::serde::Deserialize<'de> for RemoveVanishedStr {
138 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
139 where
140 D: ::serde::Deserializer<'de>,
141 {
142 crate::types::bounded_string::deserialize_bounded_string(deserializer)
143 }
144}