feat(healthchecks): add support for v3 API
This commit is contained in:
parent
a9c34d08c2
commit
796c21800e
|
@ -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"] }
|
||||
|
|
|
@ -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/
|
||||
|
|
|
@ -24,6 +24,7 @@ uuid.workspace = true
|
|||
|
||||
[features]
|
||||
v2 = []
|
||||
v3 = ["v2"]
|
||||
|
||||
[badges]
|
||||
maintenance = { status = "actively-developed" }
|
||||
|
|
|
@ -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<T> = Result<T, HealthchecksApiError>;
|
||||
|
|
|
@ -26,6 +26,9 @@ pub struct Check {
|
|||
#[cfg(feature = "v2")]
|
||||
pub started: bool,
|
||||
|
||||
#[cfg(feature = "v3")]
|
||||
pub slug: Option<String>,
|
||||
|
||||
/// UTC timestamp of the last known ping.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub last_ping: Option<String>,
|
||||
|
|
Loading…
Reference in New Issue