siera_cloudagent_python/
agent.rs1use reqwest::Url;
2use siera_agent::error::{Error, Result};
3
4#[derive(Debug)]
6pub struct CloudAgentPython {
7 pub endpoint: String,
9
10 pub api_key: Option<String>,
12
13 pub auth_token: Option<String>,
15
16 pub version: CloudAgentPythonVersion,
18}
19
20#[derive(Debug)]
23pub enum CloudAgentPythonVersion {
24 ZeroSevenThree,
26}
27
28impl CloudAgentPython {
29 #[must_use]
31 pub const fn new(
32 endpoint: String,
33 version: CloudAgentPythonVersion,
34 api_key: Option<String>,
35 auth_token: Option<String>,
36 ) -> Self {
37 Self {
38 endpoint,
39 api_key,
40 auth_token,
41 version,
42 }
43 }
44
45 pub fn create_url(&self, paths: &[&str]) -> Result<Url> {
51 let mut url = Url::parse(&self.endpoint)
52 .map_err(|_| Box::new(Error::UnreachableUrl) as Box<dyn std::error::Error>)?;
53 url.set_path(&paths.join("/"));
54 Ok(url)
55 }
56}