Skip to main content

uptrakit_openapi_client/
update_batches.rs

1use crate::Result;
2use crate::UptrakitClient;
3use crate::types_impl::pagination::PaginatedResponse;
4use crate::types_impl::update_batches::{
5    BatchUpdateResponse, HostBatchUpdateRequest, ItemBatchUpdateRequest, UpdateBatchDetailResponse,
6    UpdateBatchListQuery, UpdateBatchSummaryResponse,
7};
8use uuid::Uuid;
9
10impl UptrakitClient {
11    /// Trigger a host-wide batch update for all outdated software items on a host.
12    pub async fn trigger_host_batch_update(
13        &self,
14        host_id: &Uuid,
15        req: &HostBatchUpdateRequest,
16    ) -> Result<BatchUpdateResponse> {
17        self.post_json(
18            &crate::paths::update_batches::host_batch_update(host_id),
19            req,
20        )
21        .await
22    }
23
24    /// Trigger an item-wide batch update to roll out a software item to hosts.
25    pub async fn trigger_item_batch_update(
26        &self,
27        item_id: &Uuid,
28        req: &ItemBatchUpdateRequest,
29    ) -> Result<BatchUpdateResponse> {
30        self.post_json(
31            &crate::paths::update_batches::item_batch_update(item_id),
32            req,
33        )
34        .await
35    }
36
37    /// List update batches with optional filters and pagination.
38    pub async fn list_update_batches(
39        &self,
40        query: &UpdateBatchListQuery,
41    ) -> Result<PaginatedResponse<UpdateBatchSummaryResponse>> {
42        self.get_with_query(crate::paths::update_batches::BASE, query)
43            .await
44    }
45
46    /// Fetch all update batches matching the given filters across all pages.
47    pub async fn list_all_update_batches(
48        &self,
49        query: &UpdateBatchListQuery,
50    ) -> Result<Vec<UpdateBatchSummaryResponse>> {
51        self.fetch_all_pages(crate::paths::update_batches::BASE, query)
52            .await
53    }
54
55    /// Get a single update batch with per-item update details.
56    pub async fn get_update_batch(&self, id: &Uuid) -> Result<UpdateBatchDetailResponse> {
57        self.get(&crate::paths::update_batches::by_id(id)).await
58    }
59
60    /// Returns the relative path for the batch progress SSE stream.
61    ///
62    /// The caller should combine this with the base URL and use an
63    /// SSE/EventSource client to consume it.
64    pub fn batch_progress_stream_path(id: &Uuid) -> String {
65        crate::paths::update_batches::stream(id)
66    }
67}