use reqwest::Url;
use siera_agent::error::{Error, Result};
#[derive(Debug)]
pub struct CloudAgentPython {
pub endpoint: String,
pub api_key: Option<String>,
pub auth_token: Option<String>,
pub version: CloudAgentPythonVersion,
}
#[derive(Debug)]
pub enum CloudAgentPythonVersion {
ZeroSevenThree,
}
impl CloudAgentPython {
#[must_use]
pub const fn new(
endpoint: String,
version: CloudAgentPythonVersion,
api_key: Option<String>,
auth_token: Option<String>,
) -> Self {
Self {
endpoint,
api_key,
auth_token,
version,
}
}
pub fn create_url(&self, paths: &[&str]) -> Result<Url> {
let mut url = Url::parse(&self.endpoint)
.map_err(|_| Box::new(Error::UnreachableUrl) as Box<dyn std::error::Error>)?;
url.set_path(&paths.join("/"));
Ok(url)
}
}