client_rust/resources/
pod.rs

1use crate::api_client::ApiClient;
2
3pub struct PodClient {
4    api_client: ApiClient,
5}
6
7impl PodClient {
8    pub fn new(api_client: ApiClient) -> Self {
9        Self { api_client }
10    }
11
12    pub async fn create_pod(&self, namespace: &str, pod: serde_json::Value) -> Result<serde_json::Value, reqwest::Error> {
13        let path = format!("api/v1/namespaces/{}/pods", namespace);
14        self.api_client.send_request(reqwest::Method::POST, &path, Some(pod)).await
15    }
16
17    pub async fn get_pod(&self, namespace: &str, name: &str) -> Result<serde_json::Value, reqwest::Error> {
18        let path = format!("api/v1/namespaces/{}/pods/{}", namespace, name);
19        self.api_client.send_request(reqwest::Method::GET, &path, None).await
20    }
21
22    pub async fn list_pods(&self, namespace: &str) -> Result<serde_json::Value, reqwest::Error> {
23        let path = format!("api/v1/namespaces/{}/pods", namespace);
24        self.api_client.send_request(reqwest::Method::GET, &path, None).await
25    }
26
27    pub async fn update_pod(&self, namespace: &str, name: &str, pod: serde_json::Value) -> Result<serde_json::Value, reqwest::Error> {
28        let path = format!("api/v1/namespaces/{}/pods/{}", namespace, name);
29        self.api_client.send_request(reqwest::Method::PUT, &path, Some(pod)).await
30    }
31
32    pub async fn delete_pod(&self, namespace: &str, name: &str) -> Result<(), reqwest::Error> {
33        let path = format!("api/v1/namespaces/{}/pods/{}", namespace, name);
34        self.api_client.send_request(reqwest::Method::DELETE, &path, None).await?;
35        Ok(())
36    }
37}