1010use chrono:: { DateTime , Utc } ;
1111use omicron_common:: api:: external:: Error ;
1212use omicron_uuid_kinds:: SledUuid ;
13+ use serde:: { Deserialize , Serialize } ;
1314use std:: collections:: HashMap ;
1415use std:: collections:: HashSet ;
1516
1617/// A set of filters for fetching ereports.
17- #[ derive( Clone , Debug , Default , Eq , PartialEq ) ]
18+ #[ derive( Clone , Debug , Default , Eq , PartialEq , Serialize , Deserialize ) ]
1819pub struct EreportFilters {
1920 /// If present, include only ereports that were collected at the specified
2021 /// timestamp or later.
@@ -52,7 +53,7 @@ impl EreportFilters {
5253}
5354
5455/// Describes the category of support bundle data.
55- #[ derive( Debug , Clone , Copy , Hash , Eq , PartialEq ) ]
56+ #[ derive( Debug , Clone , Copy , Hash , Eq , PartialEq , Serialize , Deserialize ) ]
5657pub enum BundleDataCategory {
5758 /// Collects reconfigurator state (some of the latest blueprints,
5859 /// information about the target blueprint).
@@ -74,7 +75,7 @@ pub enum BundleDataCategory {
7475/// For categories without additional parameters, the variant is a unit variant.
7576/// For categories that can be filtered or configured, the variant contains
7677/// that configuration data.
77- #[ derive( Debug , Clone , Eq , PartialEq ) ]
78+ #[ derive( Debug , Clone , Eq , PartialEq , Serialize , Deserialize ) ]
7879pub enum BundleData {
7980 Reconfigurator ,
8081 HostInfo ( HashSet < SledSelection > ) ,
@@ -100,7 +101,7 @@ impl BundleData {
100101/// This wrapper ensures that categories and data always match - you can't
101102/// insert (BundleDataCategory::Reconfigurator, BundleData::SpDumps)
102103/// because each BundleData determines its own category.
103- #[ derive( Debug , Clone , Eq , PartialEq ) ]
104+ #[ derive( Debug , Clone , Eq , PartialEq , Serialize , Deserialize ) ]
104105pub struct BundleDataSelection {
105106 data : HashMap < BundleDataCategory , BundleData > ,
106107}
@@ -131,6 +132,11 @@ impl BundleDataSelection {
131132 pub fn get ( & self , category : BundleDataCategory ) -> Option < & BundleData > {
132133 self . data . get ( & category)
133134 }
135+
136+ /// Iterate over all data entries in this selection.
137+ pub fn iter ( & self ) -> impl Iterator < Item = & BundleData > {
138+ self . data . values ( )
139+ }
134140}
135141
136142impl FromIterator < BundleData > for BundleDataSelection {
@@ -167,7 +173,7 @@ impl Default for BundleDataSelection {
167173///
168174/// Multiple values of this enum are joined together into a HashSet.
169175/// Therefore "SledSelection::All" overrides specific sleds.
170- #[ derive( Debug , Clone , Hash , Eq , PartialEq ) ]
176+ #[ derive( Debug , Clone , Hash , Eq , PartialEq , Serialize , Deserialize ) ]
171177pub enum SledSelection {
172178 All ,
173179 Specific ( SledUuid ) ,
0 commit comments