rmq_rs_admin/modules/
vhost.rs1use serde::Deserialize;
2use std::{collections::HashMap, error::Error};
3
4use super::client::Client;
5
6#[derive(Deserialize, Debug)]
7pub struct MetaData {
8 pub description: String,
9 pub tags: Vec<String>,
10}
11
12#[derive(Deserialize, Debug)]
13pub struct Vhost {
14 pub name: String,
15 pub cluster_state: HashMap<String, String>,
16 pub default_queue_type: String,
17 pub description: String,
18 pub metadata: MetaData,
19 pub tags: Vec<String>,
20 pub tracing: bool,
21}
22
23pub struct VhostManager {
24 client: Box<Client>,
25}
26
27impl VhostManager {
28 pub fn new(client: Box<Client>) -> Self {
29 Self { client }
30 }
31
32 pub async fn get(&self) -> Result<Vec<Vhost>, Box<dyn Error>> {
33 let uri = "api/vhosts".to_string();
34 let vhosts = self
35 .client
36 .get(uri, None)
37 .await?
38 .json::<Vec<Vhost>>()
39 .await?;
40 Ok(vhosts)
41 }
42}