docker_registry/v2/
referrers.rs1use log::trace;
2use reqwest::{self, Method, StatusCode};
3
4use crate::{
5 errors::Result,
6 v2::{manifest::OciImageIndex, *},
7};
8
9impl Client {
10 pub async fn get_referrers(
19 &self,
20 name: &str,
21 digest: &str,
22 artifact_type: Option<&str>,
23 ) -> Result<OciImageIndex> {
24 let mut ep = format!("{}/v2/{}/referrers/{}", self.base_url, name, digest);
25 if let Some(at) = artifact_type {
26 ep = format!("{ep}?artifactType={at}");
27 }
28 let url = reqwest::Url::parse(&ep)?;
29
30 let resp = self.build_reqwest(Method::GET, url.clone()).send().await?;
31
32 let status = resp.status();
33 trace!("GET '{}' status: {:?}", resp.url(), status);
34
35 match status {
36 StatusCode::OK => Ok(resp.json::<OciImageIndex>().await?),
37 _ => Err(ApiErrors::from(resp).await),
38 }
39 }
40}