kanidm_client/
scim.rs

1use crate::{ClientError, KanidmClient};
2use kanidm_proto::scim_v1::{
3    client::{ScimEntryPostGeneric, ScimEntryPutGeneric, ScimListEntry},
4    ScimEntryGeneric, ScimEntryGetQuery, ScimSyncRequest, ScimSyncState,
5};
6
7impl KanidmClient {
8    pub async fn scim_v1_sync_status(&self) -> Result<ScimSyncState, ClientError> {
9        self.perform_get_request("/scim/v1/Sync").await
10    }
11
12    pub async fn scim_v1_sync_update(
13        &self,
14        scim_sync_request: &ScimSyncRequest,
15    ) -> Result<(), ClientError> {
16        self.perform_post_request("/scim/v1/Sync", scim_sync_request)
17            .await
18    }
19
20    /// Retrieve a Generic SCIM Entry as a JSON Value. This can retrieve any
21    /// type of entry that Kanidm supports.
22    pub async fn scim_v1_entry_get(
23        &self,
24        name_or_uuid: &str,
25        query: Option<ScimEntryGetQuery>,
26    ) -> Result<ScimEntryGeneric, ClientError> {
27        self.perform_get_request_query(format!("/scim/v1/Entry/{name_or_uuid}").as_str(), query)
28            .await
29    }
30
31    /// Retrieve a Person as a SCIM JSON Value.
32    pub async fn scim_v1_person_get(
33        &self,
34        name_or_uuid: &str,
35        query: Option<ScimEntryGetQuery>,
36    ) -> Result<ScimEntryGeneric, ClientError> {
37        self.perform_get_request_query(format!("/scim/v1/Person/{name_or_uuid}").as_str(), query)
38            .await
39    }
40
41    pub async fn scim_v1_entry_query(
42        &self,
43        query: ScimEntryGetQuery,
44    ) -> Result<ScimListEntry, ClientError> {
45        self.perform_get_request_query("/scim/v1/Entry", Some(query))
46            .await
47    }
48
49    pub async fn scim_v1_entry_create(
50        &self,
51        entry: ScimEntryPostGeneric,
52    ) -> Result<ScimEntryGeneric, ClientError> {
53        self.perform_post_request("/scim/v1/Entry", entry).await
54    }
55
56    pub async fn scim_v1_entry_update(
57        &self,
58        entry: ScimEntryPutGeneric,
59    ) -> Result<ScimEntryGeneric, ClientError> {
60        self.perform_put_request("/scim/v1/Entry", entry).await
61    }
62
63    pub async fn scim_v1_entry_delete(&self, id: &str) -> Result<(), ClientError> {
64        self.perform_delete_request(format!("/scim/v1/Entry/{id}").as_str())
65            .await
66    }
67}