Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a function for GET /api/overview #31

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,12 @@ where
Ok(response)
}

pub async fn overview(&self) -> Result<responses::Overview> {
let response = self.http_get("overview", None, None).await?;
let response = response.json().await?;
Ok(response)
}

//
// Implementation
//
Expand Down
6 changes: 6 additions & 0 deletions src/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,12 @@ where
Ok(response)
}

pub fn overview(&self) -> Result<responses::Overview> {
let response = self.http_get("overview", None, None)?;
let response = response.json()?;
Ok(response)
}

//
// Implementation
//
Expand Down
11 changes: 11 additions & 0 deletions src/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,17 @@ impl fmt::Display for MessageProperties {
}
}

#[derive(Debug, Deserialize, Clone, Eq, PartialEq)]
pub struct Overview {
pub cluster_name: String,
pub erlang_full_version: String,
pub erlang_version: String,
pub management_version: String,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will never be different from rabbitmq_version, I don't think we need it (neither do we need it in the API response but it will take a deprecation period before it can be removed).

pub node: String,
pub rabbitmq_version: String,
pub statistics_db_event_queue: u64,
}

fn undefined() -> String {
"?".to_string()
}
Expand Down
13 changes: 13 additions & 0 deletions tests/overview_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use rabbitmq_http_client::blocking::Client;

mod common;
use crate::common::{endpoint, PASSWORD, USERNAME};

#[test]
fn test_overview() {
let endpoint = endpoint();
let rc = Client::new(&endpoint, USERNAME, PASSWORD);

let result1 = rc.overview();
assert!(result1.is_ok(), "overview returned {:?}", result1);
}
Loading