Skip to main content

uptrakit_openapi_client/
discovery_allowlist.rs

1//! Client methods for the discovery plugin allowlist endpoints.
2
3use crate::Result;
4use crate::UptrakitClient;
5use crate::types_impl::discovery_allowlist::{
6    CreateDiscoveryAllowlistEntryRequest, HostDiscoveryAllowlistEntry,
7    TenantDiscoveryAllowlistEntry,
8};
9use uuid::Uuid;
10
11impl UptrakitClient {
12    /// List all tenant-wide discovery allowlist entries.
13    ///
14    /// An empty list means no restrictions — all discovery plugin types will run.
15    pub async fn list_discovery_allowlist(&self) -> Result<Vec<TenantDiscoveryAllowlistEntry>> {
16        self.get(crate::paths::discovery_allowlist::BASE).await
17    }
18
19    /// Add a plugin type to the tenant-wide discovery allowlist.
20    ///
21    /// Idempotent: returns the existing entry if it already exists (HTTP 201).
22    pub async fn add_discovery_allowlist_entry(
23        &self,
24        req: &CreateDiscoveryAllowlistEntryRequest,
25    ) -> Result<TenantDiscoveryAllowlistEntry> {
26        self.post_json(crate::paths::discovery_allowlist::BASE, req)
27            .await
28    }
29
30    /// Remove a tenant-wide discovery allowlist entry.
31    pub async fn remove_discovery_allowlist_entry(&self, id: &Uuid) -> Result<()> {
32        self.delete(&crate::paths::discovery_allowlist::by_id(id))
33            .await
34    }
35
36    /// List host-specific discovery allowlist entries.
37    ///
38    /// An empty list means the host inherits the tenant-wide allowlist.
39    pub async fn list_host_discovery_allowlist(
40        &self,
41        host_id: &Uuid,
42    ) -> Result<Vec<HostDiscoveryAllowlistEntry>> {
43        self.get(&crate::paths::discovery_allowlist::host_base(host_id))
44            .await
45    }
46
47    /// Add a plugin type to a host's discovery allowlist.
48    ///
49    /// Idempotent: returns the existing entry if it already exists (HTTP 201).
50    pub async fn add_host_discovery_allowlist_entry(
51        &self,
52        host_id: &Uuid,
53        req: &CreateDiscoveryAllowlistEntryRequest,
54    ) -> Result<HostDiscoveryAllowlistEntry> {
55        self.post_json(&crate::paths::discovery_allowlist::host_base(host_id), req)
56            .await
57    }
58
59    /// Remove a host-specific discovery allowlist entry.
60    pub async fn remove_host_discovery_allowlist_entry(
61        &self,
62        host_id: &Uuid,
63        entry_id: &Uuid,
64    ) -> Result<()> {
65        self.delete(&crate::paths::discovery_allowlist::host_entry(
66            host_id, entry_id,
67        ))
68        .await
69    }
70}