mirror of
https://github.com/moghtech/komodo.git
synced 2026-04-27 19:33:08 -05:00
fill out monitor client permissions and secret calls
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user