use crate::ScalewayApi;
use crate::ScalewayError;
use crate::data::ssh_key::ScalewaySSHKey;
pub struct ScalewayGetSSHKeyBuilder {
api: ScalewayApi,
ssh_key_id: String,
}
impl ScalewayGetSSHKeyBuilder {
pub fn new(api: ScalewayApi, ssh_key_id: &str) -> Self {
ScalewayGetSSHKeyBuilder {
api,
ssh_key_id: ssh_key_id.to_string(),
}
}
#[cfg(feature = "blocking")]
pub fn run(self) -> Result<ScalewaySSHKey, ScalewayError> {
Ok(self
.api
.get(
&format!(
"https://api.scaleway.com/iam/v1alpha1/ssh-keys/{ssh_key_id}",
ssh_key_id = self.ssh_key_id
),
vec![],
)?
.json::<ScalewaySSHKey>()?)
}
pub async fn run_async(self) -> Result<ScalewaySSHKey, ScalewayError> {
Ok(self
.api
.get_async(
&format!(
"https://api.scaleway.com/iam/v1alpha1/ssh-keys/{ssh_key_id}",
ssh_key_id = self.ssh_key_id
),
vec![],
)
.await?
.json::<ScalewaySSHKey>()
.await?)
}
}