use reqwest; use serde::Deserialize; use url::Url; pub struct Registry<'a> { pub url: &'a str, } #[allow(dead_code)] #[derive(Debug, Deserialize)] pub struct RepositoryList { pub repositories: Vec, } #[allow(dead_code)] #[derive(Debug, Deserialize)] pub struct RepositoryTags { name: String, tags: Option>, } impl<'a> Registry<'a> { pub async fn get_repositories(&self) -> Result> { let registry_url = Url::parse(self.url).unwrap(); let api_url = registry_url.join("/v2/_catalog").unwrap(); let resp = reqwest::get(api_url) .await? .json::() .await?; Ok(resp) } pub async fn get_repository_tags( &self, repo: &str, ) -> Result> { let registry_url = Url::parse(self.url).unwrap(); let api_url = registry_url .join(format!("/v2/{}/tags/list", repo).as_str()) .unwrap(); let resp = reqwest::get(api_url).await?; println!("{:?}", resp.headers()); let data = resp.json::().await?; Ok(data) } }