Skip to main content

uptrakit_openapi_client/
access_grants.rs

1use crate::Result;
2use crate::UptrakitClient;
3use crate::types_impl::access_grants::{
4    AccessGrantResponse, CreateAccessGrantRequest, ListAccessGrantsQuery, UpdateAccessGrantRequest,
5};
6
7impl UptrakitClient {
8    /// List grants (active tenant + global rows), optionally one subject's.
9    pub async fn list_access_grants(
10        &self,
11        query: &ListAccessGrantsQuery,
12    ) -> Result<Vec<AccessGrantResponse>> {
13        self.get_with_query(crate::paths::access_grants::BASE, query)
14            .await
15    }
16
17    /// Get a single grant.
18    pub async fn get_access_grant(&self, id: &crate::Uuid) -> Result<AccessGrantResponse> {
19        self.get(&crate::paths::access_grants::by_id(id)).await
20    }
21
22    /// Create a grant.
23    pub async fn create_access_grant(
24        &self,
25        req: &CreateAccessGrantRequest,
26    ) -> Result<AccessGrantResponse> {
27        self.post_json(crate::paths::access_grants::BASE, req).await
28    }
29
30    /// Update a grant's patterns/selector/description.
31    pub async fn update_access_grant(
32        &self,
33        id: &crate::Uuid,
34        req: &UpdateAccessGrantRequest,
35    ) -> Result<AccessGrantResponse> {
36        self.put_json(&crate::paths::access_grants::by_id(id), req)
37            .await
38    }
39
40    /// Delete a grant.
41    pub async fn delete_access_grant(&self, id: &crate::Uuid) -> Result<()> {
42        self.delete(&crate::paths::access_grants::by_id(id)).await
43    }
44}