use super::*;
impl ApiClient {
pub async fn set_maintenance(
&self,
service_environment_id: &str,
enabled: bool,
message: Option<&str>,
) -> Result<Answer<EdgeAccessPage>> {
let mut body = serde_json::Map::new();
body.insert("enabled".into(), enabled.into());
if let Some(message) = message {
body.insert("message".into(), message.into());
}
self.answer(
Method::PUT,
&format!("/api/infra/services/{service_environment_id}/maintenance"),
Some(&serde_json::Value::Object(body)),
)
.await
}
pub async fn protect_service(
&self,
service_environment_id: &str,
username: &str,
password: &str,
) -> Result<Answer<EdgeAccessPage>> {
self.answer(
Method::PUT,
&format!("/api/infra/services/{service_environment_id}/protection"),
Some(&serde_json::json!({ "username": username, "password": password })),
)
.await
}
pub async fn unprotect_service(
&self,
service_environment_id: &str,
) -> Result<Answer<EdgeAccessPage>> {
self.answer(
Method::DELETE,
&format!("/api/infra/services/{service_environment_id}/protection"),
None::<&()>,
)
.await
}
pub async fn edge_access(
&self,
service_environment_id: &str,
) -> Result<Answer<EdgeAccessPage>> {
self.answer(
Method::GET,
&format!("/api/infra/services/{service_environment_id}/edge"),
None::<&()>,
)
.await
}
pub async fn set_allowlist(
&self,
service_environment_id: &str,
entries: &[String],
) -> Result<Answer<EdgeAccessPage>> {
self.answer(
Method::PUT,
&format!("/api/infra/services/{service_environment_id}/allowlist"),
Some(&serde_json::json!({ "entries": entries })),
)
.await
}
pub async fn clear_allowlist(
&self,
service_environment_id: &str,
) -> Result<Answer<EdgeAccessPage>> {
self.answer(
Method::DELETE,
&format!("/api/infra/services/{service_environment_id}/allowlist"),
None::<&()>,
)
.await
}
pub async fn set_rate_limit(
&self,
service_environment_id: &str,
per_minute: u32,
) -> Result<Answer<EdgeAccessPage>> {
self.answer(
Method::PUT,
&format!("/api/infra/services/{service_environment_id}/rate-limit"),
Some(&serde_json::json!({ "perMinute": per_minute })),
)
.await
}
pub async fn clear_rate_limit(
&self,
service_environment_id: &str,
) -> Result<Answer<EdgeAccessPage>> {
self.answer(
Method::DELETE,
&format!("/api/infra/services/{service_environment_id}/rate-limit"),
None::<&()>,
)
.await
}
}