aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/bin/zot/main.rs7
-rw-r--r--src/zotapi.rs12
2 files changed, 19 insertions, 0 deletions
diff --git a/src/bin/zot/main.rs b/src/bin/zot/main.rs
index d09b5d4..7f49eb4 100644
--- a/src/bin/zot/main.rs
+++ b/src/bin/zot/main.rs
@@ -38,6 +38,9 @@ async fn main() -> Result<(), Box<(dyn std::error::Error + 'static)>> {
(@subcommand verify =>
(about: "Verify")
)
+ (@subcommand version =>
+ (about: "Return the version of a server.")
+ )
(@subcommand channel =>
(about: "Fetch the channel stream")
)
@@ -90,6 +93,10 @@ async fn main() -> Result<(), Box<(dyn std::error::Error + 'static)>> {
let channel = z.verify().await;
println!("{:?}", channel);
}
+
+ ("version", Some(_)) => {
+ println!("{}", z.version().await?);
+ }
/*
("channel", Some(m)) => {
let raw = m.is_present("raw");
diff --git a/src/zotapi.rs b/src/zotapi.rs
index 9e13d99..2d50ef3 100644
--- a/src/zotapi.rs
+++ b/src/zotapi.rs
@@ -40,6 +40,9 @@ pub fn new(url: &str, channel: &str, pw: &str) -> ZotApi {
}
impl ZotApi {
+ /**
+ * Returns the channel object of the logged in channel.
+ */
pub async fn verify(&self) -> Result<Channel, Box<dyn std::error::Error>> {
let raw = self.get("verify").send().await?.text().await?;
let mut channel: Channel = serde_json::from_str(&raw)?;
@@ -48,6 +51,15 @@ impl ZotApi {
Ok(channel)
}
+ /**
+ * Returns the version of the server.
+ *
+ * This API can be invoked without authentication.
+ */
+ pub async fn version(&self) -> Result<String, Box<dyn std::error::Error>> {
+ Ok(self.get("version").send().await?.text().await?)
+ }
+
/// Return a RequestBuilder object that's set up with the correct
/// path and headers for performing a zot api request.