Skip to main content

ic_query/ic/model/requests/
dashboard.rs

1//! Explicit endpoint and caller-clock scope for official Dashboard requests.
2
3///
4/// IcDashboardRequest
5///
6/// Shared endpoint and collection clock; each operation selects its own API endpoint.
7///
8
9#[derive(Clone, Debug, Eq, PartialEq)]
10pub struct IcDashboardRequest {
11    /// Explicit Dashboard API base endpoint.
12    pub source_endpoint: String,
13    /// Caller-supplied collection time as Unix seconds.
14    pub now_unix_secs: u64,
15}
16
17impl IcDashboardRequest {
18    /// Construct collection scope without selecting an endpoint implicitly.
19    #[must_use]
20    pub fn new(source_endpoint: impl Into<String>, now_unix_secs: u64) -> Self {
21        Self {
22            source_endpoint: source_endpoint.into(),
23            now_unix_secs,
24        }
25    }
26
27    /// Derive live collection provenance from this request's endpoint and clock.
28    #[cfg(feature = "dashboard-host")]
29    #[must_use]
30    pub fn source_request(&self) -> crate::ic::IcSourceRequest {
31        crate::ic::IcSourceRequest::new(
32            &self.source_endpoint,
33            crate::subnet_catalog::format_utc_timestamp_secs(self.now_unix_secs),
34            "ic-query",
35        )
36    }
37}