Skip to main content

nominal_api_conjure/conjure/objects/scout/compute/api/
quota_interval_usage.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    conjure_object::private::DeriveWith
7)]
8#[serde(crate = "conjure_object::serde")]
9#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
10#[conjure_object::private::staged_builder::staged_builder]
11#[builder(crate = conjure_object::private::staged_builder, update, inline)]
12pub struct QuotaIntervalUsage {
13    #[serde(rename = "durationSeconds")]
14    duration_seconds: conjure_object::SafeLong,
15    #[builder(
16        default,
17        custom(
18            type = impl
19            Into<Option<super::QuotaWindow>>,
20            convert = |v|v.into().map(Box::new)
21        )
22    )]
23    #[serde(rename = "currentWindow", skip_serializing_if = "Option::is_none", default)]
24    current_window: Option<Box<super::QuotaWindow>>,
25    #[builder(default, list(item(type = super::QuotaResourceUsage)))]
26    #[serde(rename = "resources", skip_serializing_if = "Vec::is_empty", default)]
27    resources: Vec<super::QuotaResourceUsage>,
28}
29impl QuotaIntervalUsage {
30    /// Constructs a new instance of the type.
31    #[inline]
32    pub fn new(duration_seconds: conjure_object::SafeLong) -> Self {
33        Self::builder().duration_seconds(duration_seconds).build()
34    }
35    /// Length of the quota window in seconds.
36    #[inline]
37    pub fn duration_seconds(&self) -> conjure_object::SafeLong {
38        self.duration_seconds
39    }
40    /// Bounds of the current quota window. Usage counters reset at the window's end.
41    #[inline]
42    pub fn current_window(&self) -> Option<&super::QuotaWindow> {
43        self.current_window.as_ref().map(|o| &**o)
44    }
45    /// Usage per limited resource. Resources without a configured limit are not reported.
46    #[inline]
47    pub fn resources(&self) -> &[super::QuotaResourceUsage] {
48        &*self.resources
49    }
50}