fill out monitor client permissions and secret calls

This commit is contained in:
beckerinj
2022-12-11 12:29:48 -05:00
parent daf06a33f8
commit ffeca7658a
2 changed files with 59 additions and 0 deletions

View File

@@ -1 +1,36 @@
use monitor_types::{PermissionLevel, PermissionsTarget};
use serde_json::json;
use crate::MonitorClient;
impl MonitorClient {
pub async fn update_user_permissions_on_target(
&self,
user_id: &str,
permission: PermissionLevel,
target_type: PermissionsTarget,
target_id: &str,
) -> anyhow::Result<String> {
self.post(
"/api/permissions/update",
json!({
"user_id": user_id,
"permission": permission,
"target_type": target_type,
"target_id": target_id
}),
)
.await
}
pub async fn modify_user_enabled(&self, user_id: &str, enabled: bool) -> anyhow::Result<()> {
self.post(
"/api/permissions/update",
json!({
"user_id": user_id,
"enabled": enabled,
}),
)
.await
}
}

View File

@@ -1 +1,25 @@
use serde_json::json;
use crate::MonitorClient;
impl MonitorClient {
pub async fn create_api_secret(
&self,
secret_name: &str,
expires: Option<i64>,
) -> anyhow::Result<String> {
self.post(
"/api/secret/create",
json!({
"name": secret_name,
"expires": expires
}),
)
.await
}
pub async fn delete_api_secret(&self, name: &str) -> anyhow::Result<()> {
self.delete::<(), _>(&format!("/api/secret/delete/{name}"), None)
.await
}
}