platz_sdk/resources/
helm_registries.rs

1use crate::client::PlatzClient;
2use anyhow::Result;
3use chrono::prelude::*;
4use kv_derive::{prelude::*, IntoVec};
5use serde::{Deserialize, Serialize};
6use uuid::Uuid;
7
8#[derive(Debug, Deserialize, Clone)]
9pub struct HelmRegistry {
10    pub id: Uuid,
11    pub created_at: DateTime<Utc>,
12    pub domain_name: String,
13    pub repo_name: String,
14    pub kind_id: Uuid,
15    pub available: bool,
16    pub fa_icon: String,
17}
18
19#[derive(Default, IntoVec)]
20pub struct HelmRegistryFilters {
21    #[kv(optional)]
22    pub repo_name: Option<String>,
23    #[kv(optional)]
24    pub kind_id: Option<Uuid>,
25}
26
27#[derive(Debug, Serialize)]
28pub struct UpdateHelmRegistry {
29    pub fa_icon: Option<String>,
30}
31
32impl PlatzClient {
33    pub async fn helm_registries(&self, filters: HelmRegistryFilters) -> Result<Vec<HelmRegistry>> {
34        Ok(self
35            .request(reqwest::Method::GET, "/api/v2/helm-registries")
36            .add_to_query(filters.into_vec())
37            .paginated()
38            .await?)
39    }
40
41    pub async fn helm_registry(&self, registry_id: Uuid) -> Result<HelmRegistry> {
42        Ok(self
43            .request(
44                reqwest::Method::GET,
45                format!("/api/v2/helm-registry/{registry_id}"),
46            )
47            .send()
48            .await?)
49    }
50
51    pub async fn update_helm_registry(
52        &self,
53        registry_id: Uuid,
54        update_registry: UpdateHelmRegistry,
55    ) -> Result<HelmRegistry> {
56        Ok(self
57            .request(
58                reqwest::Method::PUT,
59                format!("/api/v2/helm-registry/{registry_id}"),
60            )
61            .send_with_body(update_registry)
62            .await?)
63    }
64}