Skip to main content

uptrakit_openapi_client/
autodiscovery.rs

1//! Client methods for autodiscovery endpoints.
2
3use crate::Result;
4use crate::UptrakitClient;
5use crate::types_impl::autodiscovery::{
6    CreateSoftwareIgnoreRequest, SoftwareIgnoreResponse, TriggerDiscoveryResponse,
7};
8use crate::types_impl::batch_actions::{BatchActionRequest, BatchActionResponse};
9use crate::types_impl::pagination::PaginatedResponse;
10use crate::types_impl::software_items::SoftwareItemResponse;
11use uuid::Uuid;
12
13/// Query parameters for listing software ignore rules.
14#[derive(serde::Serialize)]
15pub struct ListIgnoresParams {
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub page: Option<u64>,
18    #[serde(skip_serializing_if = "Option::is_none")]
19    pub per_page: Option<u64>,
20}
21
22impl UptrakitClient {
23    /// Approve a pending discovered software item.
24    ///
25    /// Sets `discovery_state = approved` and `enabled = true`.
26    pub async fn approve_software_item(&self, id: &Uuid) -> Result<SoftwareItemResponse> {
27        self.post_empty(&crate::paths::software_items::approve(id))
28            .await
29    }
30
31    /// Trigger autodiscovery on a specific host.
32    pub async fn discover_host(&self, host_id: &Uuid) -> Result<TriggerDiscoveryResponse> {
33        self.post_empty(&crate::paths::hosts::discover(host_id))
34            .await
35    }
36
37    /// Trigger autodiscovery for a specific plugin config across all agents.
38    pub async fn discover_plugin_config(&self, id: &Uuid) -> Result<TriggerDiscoveryResponse> {
39        self.post_empty(&crate::paths::plugin_configs::discover(id))
40            .await
41    }
42
43    /// List software ignore rules for this tenant.
44    pub async fn list_software_ignores(
45        &self,
46        params: &ListIgnoresParams,
47    ) -> Result<PaginatedResponse<SoftwareIgnoreResponse>> {
48        self.get_with_query(crate::paths::autodiscovery::IGNORES, params)
49            .await
50    }
51
52    /// Create a software ignore rule (idempotent).
53    pub async fn create_software_ignore(
54        &self,
55        req: &CreateSoftwareIgnoreRequest,
56    ) -> Result<SoftwareIgnoreResponse> {
57        self.post_json(crate::paths::autodiscovery::IGNORES, req)
58            .await
59    }
60
61    /// Delete a software ignore rule by ID.
62    pub async fn delete_software_ignore(&self, id: &Uuid) -> Result<()> {
63        self.delete(&crate::paths::autodiscovery::ignore_by_id(id))
64            .await
65    }
66
67    /// Perform a batch action on multiple software ignore rules.
68    ///
69    /// Supported actions: `delete`.
70    pub async fn batch_software_ignores(
71        &self,
72        req: &BatchActionRequest,
73    ) -> Result<BatchActionResponse> {
74        self.post_json(crate::paths::autodiscovery::BATCH, req)
75            .await
76    }
77}