#![allow(unused_imports, clippy::too_many_arguments)]
use reqwest::Method;
use serde::{Deserialize, Serialize};
use crate::client::{Client, Request, NO_BODY, NO_QUERY};
use crate::error::Result;
use crate::generated::models;
use crate::multipart::{field_text, FilePart};
use crate::util::encode_path;
#[derive(Debug, Clone)]
pub struct ProgramsApi {
pub(crate) client: Client,
}
impl Client {
pub fn programs(&self) -> ProgramsApi {
ProgramsApi { client: self.clone() }
}
}
impl ProgramsApi {
pub async fn apply_program(&self, program_id: &str, body: &models::ApplyProgramRequest) -> Result<serde_json::Value> {
self.client
.request_json(Request {
method: Method::POST,
path: format!("/api/v1/programs/{}/apply", encode_path(program_id)),
query: NO_QUERY,
body: Some(body),
headers: Vec::new(),
idempotent: true,
})
.await
}
pub async fn create(&self, body: &models::CreateProgramRequest) -> Result<serde_json::Value> {
self.client
.request_json(Request {
method: Method::POST,
path: "/api/v1/programs".to_string(),
query: NO_QUERY,
body: Some(body),
headers: Vec::new(),
idempotent: true,
})
.await
}
pub async fn get(&self, program_id: &str) -> Result<serde_json::Value> {
self.client
.request_json(Request {
method: Method::GET,
path: format!("/api/v1/programs/{}", encode_path(program_id)),
query: NO_QUERY,
body: NO_BODY,
headers: Vec::new(),
idempotent: false,
})
.await
}
pub async fn list(&self) -> Result<models::ListProgramsResponse> {
self.client
.request_json(Request {
method: Method::GET,
path: "/api/v1/programs".to_string(),
query: NO_QUERY,
body: NO_BODY,
headers: Vec::new(),
idempotent: false,
})
.await
}
}