dev_scope/models/v1alpha/
report_location.rs1use crate::models::core::ModelMetadata;
2use crate::models::v1alpha::V1AlphaApiVersion;
3use crate::models::{HelpMetadata, InternalScopeModel, ScopeModel};
4use derive_builder::Builder;
5use schemars::JsonSchema;
6use serde::{Deserialize, Serialize};
7
8#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
10#[serde(rename_all = "camelCase")]
11#[schemars(deny_unknown_fields)]
12pub struct ReportDestinationGithubIssueSpec {
13 pub owner: String,
15
16 pub repo: String,
18
19 #[serde(default)]
20 pub tags: Vec<String>,
22}
23
24#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
26#[serde(rename_all = "camelCase")]
27#[schemars(deny_unknown_fields)]
28pub struct ReportDestinationRustyPasteSpec {
29 pub url: String,
31}
32
33#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
34#[serde(rename_all = "camelCase")]
35#[schemars(deny_unknown_fields)]
36pub enum ReportDestinationSpec {
37 RustyPaste(ReportDestinationRustyPasteSpec),
38 GithubIssue(ReportDestinationGithubIssueSpec),
39}
40
41#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
43#[serde(rename_all = "camelCase")]
44#[schemars(deny_unknown_fields)]
45pub struct ReportLocationSpec {
46 #[serde(with = "serde_yaml::with::singleton_map")]
47 #[schemars(with = "ReportDestinationSpec")]
48 pub destination: ReportDestinationSpec,
50}
51
52#[derive(Serialize, Deserialize, Debug, strum::Display, Clone, PartialEq, JsonSchema)]
53pub enum ReportLocationKind {
54 #[strum(serialize = "ScopeReportLocation")]
55 ScopeReportLocation,
56}
57
58#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Builder, JsonSchema)]
60#[builder(setter(into))]
61#[serde(rename_all = "camelCase")]
62#[schemars(deny_unknown_fields)]
63pub struct V1AlphaReportLocation {
64 pub api_version: V1AlphaApiVersion,
66 pub kind: ReportLocationKind,
68 pub metadata: ModelMetadata,
72 pub spec: ReportLocationSpec,
74}
75
76impl HelpMetadata for V1AlphaReportLocation {
77 fn metadata(&self) -> &ModelMetadata {
78 &self.metadata
79 }
80
81 fn full_name(&self) -> String {
82 format!("{}/{}", self.kind(), self.name())
83 }
84}
85
86impl ScopeModel<ReportLocationSpec> for V1AlphaReportLocation {
87 fn api_version(&self) -> String {
88 V1AlphaReportLocation::int_api_version()
89 }
90
91 fn kind(&self) -> String {
92 V1AlphaReportLocation::int_kind()
93 }
94
95 fn spec(&self) -> &ReportLocationSpec {
96 &self.spec
97 }
98}
99
100impl InternalScopeModel<ReportLocationSpec, V1AlphaReportLocation> for V1AlphaReportLocation {
101 fn int_api_version() -> String {
102 V1AlphaApiVersion::ScopeV1Alpha.to_string()
103 }
104
105 fn int_kind() -> String {
106 ReportLocationKind::ScopeReportLocation.to_string()
107 }
108 #[cfg(test)]
109 fn examples() -> Vec<String> {
110 vec![
111 "v1alpha/ReportLocation.github.yaml".to_string(),
112 "v1alpha/ReportLocation.rustyPaste.yaml".to_string(),
113 ]
114 }
115}