diff --git a/Cargo.toml b/Cargo.toml index 818de72..3ec911a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,6 @@ panic = "abort" [workspace.dependencies] clap = { version = "4.3.10", features = ["color", "deprecated", "derive"] } -healthchecks = { path = "healthchecks", version = "^3.1.4" } +healthchecks = { path = "healthchecks", version = "^3.1.4", features = ["v3"] } color-eyre = { version = "0.6.2", default-features = false } uuid = { version = "1.4.0", default-features = false, features = ["v1"] } diff --git a/healthchecks/CHANGELOG.md b/healthchecks/CHANGELOG.md index ab3186c..a8716eb 100644 --- a/healthchecks/CHANGELOG.md +++ b/healthchecks/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Added + +- Support [v3 management API] behind the `v3` feature flag. `v3` automatically selects `v2`. + ## [3.1.4] ### Added @@ -125,3 +129,4 @@ Initial release [#22]: https://github.com/msfjarvis/healthchecks-rs/pull/22 [#27]: https://github.com/msfjarvis/healthchecks-rs/pull/27 [v2 management api]: https://healthchecks.io/docs/api/ +[v3 management api]: https://healthchecks.io/docs/api/ diff --git a/healthchecks/Cargo.toml b/healthchecks/Cargo.toml index 985e728..362dcae 100644 --- a/healthchecks/Cargo.toml +++ b/healthchecks/Cargo.toml @@ -24,6 +24,7 @@ uuid.workspace = true [features] v2 = [] +v3 = ["v2"] [badges] maintenance = { status = "actively-developed" } diff --git a/healthchecks/src/manage.rs b/healthchecks/src/manage.rs index bc95723..b4cc930 100644 --- a/healthchecks/src/manage.rs +++ b/healthchecks/src/manage.rs @@ -6,11 +6,13 @@ use crate::{ use std::result::Result; use ureq::{delete, get, post, Error, Request}; -#[cfg(not(feature = "v2"))] -const HEALTHCHECK_API_URL: &str = "https://healthchecks.io/api/v1/"; - -#[cfg(feature = "v2")] -const HEALTHCHECK_API_URL: &str = "https://healthchecks.io/api/v2/"; +const HEALTHCHECK_API_URL: &str = if cfg!(v3) { + "https://healthchecks.io/api/v3" +} else if cfg!(v2) { + "https://healthchecks.io/api/v2" +} else { + "https://healthchecks.io/api/v1" +}; /// Typealias to prevent some repetitiveness in function definitions pub type ApiResult = Result; diff --git a/healthchecks/src/model.rs b/healthchecks/src/model.rs index a62c36a..ef115fd 100644 --- a/healthchecks/src/model.rs +++ b/healthchecks/src/model.rs @@ -26,6 +26,9 @@ pub struct Check { #[cfg(feature = "v2")] pub started: bool, + #[cfg(feature = "v3")] + pub slug: Option, + /// UTC timestamp of the last known ping. #[serde(skip_serializing_if = "Option::is_none")] pub last_ping: Option,