use crate::api_client::ApiClient;
pub struct PodClient {
api_client: ApiClient,
}
impl PodClient {
pub fn new(api_client: ApiClient) -> Self {
Self { api_client }
}
pub async fn create_pod(&self, namespace: &str, pod: serde_json::Value) -> Result<serde_json::Value, reqwest::Error> {
let path = format!("api/v1/namespaces/{}/pods", namespace);
self.api_client.send_request(reqwest::Method::POST, &path, Some(pod)).await
}
pub async fn get_pod(&self, namespace: &str, name: &str) -> Result<serde_json::Value, reqwest::Error> {
let path = format!("api/v1/namespaces/{}/pods/{}", namespace, name);
self.api_client.send_request(reqwest::Method::GET, &path, None).await
}
pub async fn list_pods(&self, namespace: &str) -> Result<serde_json::Value, reqwest::Error> {
let path = format!("api/v1/namespaces/{}/pods", namespace);
self.api_client.send_request(reqwest::Method::GET, &path, None).await
}
pub async fn update_pod(&self, namespace: &str, name: &str, pod: serde_json::Value) -> Result<serde_json::Value, reqwest::Error> {
let path = format!("api/v1/namespaces/{}/pods/{}", namespace, name);
self.api_client.send_request(reqwest::Method::PUT, &path, Some(pod)).await
}
pub async fn delete_pod(&self, namespace: &str, name: &str) -> Result<(), reqwest::Error> {
let path = format!("api/v1/namespaces/{}/pods/{}", namespace, name);
self.api_client.send_request(reqwest::Method::DELETE, &path, None).await?;
Ok(())
}
}