ic_query/ic/model/requests/canisters.rs
1//! Module: ic::model::requests::canisters
2//!
3//! Responsibility: official Dashboard canister detail, count, and page request contracts.
4//! Does not own: network metrics, network resources, transport, or reports.
5//! Boundary: keeps shared filters and explicit bounded cursor-page intent together.
6
7use super::IcDashboardRequest;
8
9use serde::Serialize;
10
11///
12/// IcCanisterRequest
13///
14/// Request accepted by the official Dashboard canister report builder.
15///
16
17#[derive(Clone, Debug, Eq, PartialEq)]
18pub struct IcCanisterRequest {
19 /// Explicit Dashboard endpoint and caller collection clock.
20 pub dashboard: IcDashboardRequest,
21 /// Canister principal to inspect.
22 pub canister_id: String,
23}
24
25impl IcCanisterRequest {
26 /// Construct a live Dashboard canister request.
27 #[must_use]
28 pub fn new(dashboard: IcDashboardRequest, canister_id: impl Into<String>) -> Self {
29 Self {
30 dashboard,
31 canister_id: canister_id.into(),
32 }
33 }
34}
35
36///
37/// IcCanisterFilters
38///
39/// Official Dashboard filters shared by canister count and page requests.
40///
41
42#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize)]
43pub struct IcCanisterFilters {
44 /// Select canisters according to whether the Dashboard records a name.
45 pub has_name: Option<bool>,
46 /// Select canisters assigned to this Subnet principal.
47 pub subnet_id: Option<String>,
48 /// Select canisters controlled by this principal.
49 pub controller_id: Option<String>,
50 /// Raw Dashboard language labels to include.
51 pub languages: Vec<String>,
52 /// Raw Dashboard canister classifications to include.
53 pub canister_types: Vec<String>,
54 /// Raw Dashboard text search, between two and one hundred characters.
55 pub query: Option<String>,
56}
57
58///
59/// IcCanisterCountRequest
60///
61/// Request for one bounded official Dashboard canister-count lookup.
62///
63
64#[derive(Clone, Debug, Eq, PartialEq)]
65pub struct IcCanisterCountRequest {
66 /// Explicit Dashboard endpoint and caller collection clock.
67 pub dashboard: IcDashboardRequest,
68 /// Filters applied by the Dashboard.
69 pub filters: IcCanisterFilters,
70}
71
72impl IcCanisterCountRequest {
73 /// Construct a live Dashboard canister-count request without filters.
74 #[must_use]
75 pub fn new(dashboard: IcDashboardRequest) -> Self {
76 Self {
77 dashboard,
78 filters: IcCanisterFilters::default(),
79 }
80 }
81}
82
83///
84/// IcCanisterPageRequest
85///
86/// Request for one bounded official Dashboard canister page.
87///
88
89#[derive(Clone, Debug, Eq, PartialEq)]
90pub struct IcCanisterPageRequest {
91 /// Explicit Dashboard endpoint and caller collection clock.
92 pub dashboard: IcDashboardRequest,
93 /// Filters applied by the Dashboard.
94 pub filters: IcCanisterFilters,
95 /// Maximum rows requested from the API.
96 pub limit: u16,
97 /// Exclusive forward cursor returned by an earlier page.
98 pub after: Option<String>,
99 /// Exclusive backward cursor returned by an earlier page.
100 pub before: Option<String>,
101}
102
103impl IcCanisterPageRequest {
104 /// Construct a live Dashboard page request with the default bounded limit.
105 #[must_use]
106 pub fn new(dashboard: IcDashboardRequest) -> Self {
107 Self {
108 dashboard,
109 filters: IcCanisterFilters::default(),
110 limit: crate::ic::DEFAULT_IC_CANISTER_PAGE_LIMIT,
111 after: None,
112 before: None,
113 }
114 }
115}