dev_scope/models/v1alpha/
doctor_group.rs1use crate::models::core::ModelMetadata;
2
3use crate::models::v1alpha::V1AlphaApiVersion;
4use crate::models::{HelpMetadata, InternalScopeModel, ScopeModel};
5use derive_builder::Builder;
6use schemars::JsonSchema;
7use serde::{Deserialize, Serialize};
8
9#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
12#[serde(rename_all = "camelCase")]
13#[schemars(deny_unknown_fields)]
14pub struct DoctorCheckSpec {
15 #[serde(default)]
16 pub paths: Option<Vec<String>>,
19
20 #[serde(default)]
21 pub commands: Option<Vec<String>>,
23}
24
25#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
27#[serde(rename_all = "camelCase")]
28#[schemars(deny_unknown_fields)]
29pub struct DoctorFixSpec {
30 #[serde(default)]
31 pub commands: Vec<String>,
33
34 #[serde(default)]
35 pub help_text: Option<String>,
37
38 #[serde(default)]
39 pub help_url: Option<String>,
41}
42
43#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
46#[serde(rename_all = "camelCase")]
47#[schemars(deny_unknown_fields)]
48pub struct DoctorGroupActionSpec {
49 pub name: Option<String>,
52
53 pub description: Option<String>,
55
56 pub check: DoctorCheckSpec,
60
61 pub fix: Option<DoctorFixSpec>,
64
65 #[serde(default = "doctor_group_action_required_default")]
66 pub required: bool,
69}
70
71fn doctor_group_action_required_default() -> bool {
72 true
73}
74
75#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
78#[serde(rename_all = "camelCase")]
79#[schemars(deny_unknown_fields)]
80pub struct DoctorGroupSpec {
81 #[serde(default)]
82 pub needs: Vec<String>,
85
86 pub actions: Vec<DoctorGroupActionSpec>,
88}
89
90#[derive(Serialize, Deserialize, Debug, strum::Display, Clone, PartialEq, JsonSchema)]
91pub enum DoctorGroupKind {
92 #[strum(serialize = "ScopeDoctorGroup")]
93 ScopeDoctorGroup,
94}
95
96#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Builder, JsonSchema)]
98#[builder(setter(into))]
99#[serde(rename_all = "camelCase")]
100#[schemars(deny_unknown_fields)]
101pub struct V1AlphaDoctorGroup {
102 pub api_version: V1AlphaApiVersion,
104 pub kind: DoctorGroupKind,
106 pub metadata: ModelMetadata,
110 pub spec: DoctorGroupSpec,
112}
113
114impl HelpMetadata for V1AlphaDoctorGroup {
115 fn metadata(&self) -> &ModelMetadata {
116 &self.metadata
117 }
118
119 fn full_name(&self) -> String {
120 format!("{}/{}", self.kind(), self.name())
121 }
122}
123
124impl ScopeModel<DoctorGroupSpec> for V1AlphaDoctorGroup {
125 fn api_version(&self) -> String {
126 Self::int_api_version()
127 }
128
129 fn kind(&self) -> String {
130 Self::int_kind()
131 }
132
133 fn spec(&self) -> &DoctorGroupSpec {
134 &self.spec
135 }
136}
137
138impl InternalScopeModel<DoctorGroupSpec, V1AlphaDoctorGroup> for V1AlphaDoctorGroup {
139 fn int_api_version() -> String {
140 V1AlphaApiVersion::ScopeV1Alpha.to_string()
141 }
142
143 fn int_kind() -> String {
144 DoctorGroupKind::ScopeDoctorGroup.to_string()
145 }
146
147 #[cfg(test)]
148 fn examples() -> Vec<String> {
149 vec!["v1alpha/DoctorGroup.yaml".to_string()]
150 }
151}