1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
mod downstream;
mod kafka;
mod knative;
mod process;
pub use downstream::*;
pub use kafka::*;
pub use knative::*;
pub use process::*;
use std::time::Duration;
use crate::{
dialect,
meta::v1::{CommonMetadata, CommonMetadataMut, NonScopedMetadata},
serde::{is_default, Base64Standard},
translator, Section, Translator,
};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use serde_json::{Map, Value};
#[derive(Clone, Default, Debug, Deserialize, Serialize, Eq, PartialEq)]
pub struct Application {
pub metadata: NonScopedMetadata,
#[serde(default)]
#[serde(skip_serializing_if = "Map::is_empty")]
pub spec: Map<String, Value>,
#[serde(default)]
#[serde(skip_serializing_if = "Map::is_empty")]
pub status: Map<String, Value>,
}
translator!(Application);
impl AsRef<dyn CommonMetadata> for Application {
fn as_ref(&self) -> &(dyn CommonMetadata + 'static) {
&self.metadata
}
}
impl AsMut<dyn CommonMetadataMut> for Application {
fn as_mut(&mut self) -> &mut (dyn CommonMetadataMut + 'static) {
&mut self.metadata
}
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, Eq, PartialEq)]
pub struct ApplicationSpecTrustAnchors {
#[serde(skip_serializing_if = "Vec::is_empty")]
pub anchors: Vec<ApplicationSpecTrustAnchorEntry>,
}
dialect!(ApplicationSpecTrustAnchors [Section::Spec => "trustAnchors"]);
#[derive(Clone, Debug, Default, Deserialize, Serialize, Eq, PartialEq)]
pub struct ApplicationSpecTrustAnchorEntry {
#[serde(with = "Base64Standard")]
pub certificate: Vec<u8>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, Eq, PartialEq)]
pub struct ApplicationStatusTrustAnchors {
pub anchors: Vec<ApplicationStatusTrustAnchorEntry>,
}
dialect!(ApplicationStatusTrustAnchors [Section::Status => "trustAnchors"]);
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "camelCase")]
pub enum ApplicationStatusTrustAnchorEntry {
#[serde(rename_all = "camelCase")]
Valid {
subject: String,
#[serde(with = "Base64Standard")]
certificate: Vec<u8>,
not_before: DateTime<Utc>,
not_after: DateTime<Utc>,
},
Invalid {
error: String,
message: String,
},
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExternalEndpoint {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub method: Option<String>,
pub url: String,
#[serde(default)]
pub tls: Option<TlsOptions>,
#[serde(default)]
pub auth: Authentication,
#[serde(default)]
pub headers: Vec<Header>,
#[serde(default)]
#[serde(with = "humantime_serde")]
pub timeout: Option<Duration>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Header {
pub name: String,
pub value: String,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)]
#[serde(rename_all = "camelCase")]
pub struct TlsOptions {
#[serde(default)]
pub insecure: bool,
#[serde(default, skip_serializing_if = "is_default")]
pub certificate: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum Authentication {
None,
Basic {
username: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
password: Option<String>,
},
Bearer {
token: String,
},
}
impl Default for Authentication {
fn default() -> Self {
Self::None
}
}