1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: tools.ozone.safelink.defs
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8pub mod add_rule;
9pub mod query_events;
10pub mod query_rules;
11pub mod remove_rule;
12pub mod update_rule;
13
14#[derive(Debug, Clone, PartialEq, Eq, Hash)]
15pub enum ActionType<'a> {
16 Block,
17 Warn,
18 Whitelist,
19 Other(jacquard_common::CowStr<'a>),
20}
21
22impl<'a> ActionType<'a> {
23 pub fn as_str(&self) -> &str {
24 match self {
25 Self::Block => "block",
26 Self::Warn => "warn",
27 Self::Whitelist => "whitelist",
28 Self::Other(s) => s.as_ref(),
29 }
30 }
31}
32
33impl<'a> From<&'a str> for ActionType<'a> {
34 fn from(s: &'a str) -> Self {
35 match s {
36 "block" => Self::Block,
37 "warn" => Self::Warn,
38 "whitelist" => Self::Whitelist,
39 _ => Self::Other(jacquard_common::CowStr::from(s)),
40 }
41 }
42}
43
44impl<'a> From<String> for ActionType<'a> {
45 fn from(s: String) -> Self {
46 match s.as_str() {
47 "block" => Self::Block,
48 "warn" => Self::Warn,
49 "whitelist" => Self::Whitelist,
50 _ => Self::Other(jacquard_common::CowStr::from(s)),
51 }
52 }
53}
54
55impl<'a> AsRef<str> for ActionType<'a> {
56 fn as_ref(&self) -> &str {
57 self.as_str()
58 }
59}
60
61impl<'a> serde::Serialize for ActionType<'a> {
62 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
63 where
64 S: serde::Serializer,
65 {
66 serializer.serialize_str(self.as_str())
67 }
68}
69
70impl<'de, 'a> serde::Deserialize<'de> for ActionType<'a>
71where
72 'de: 'a,
73{
74 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
75 where
76 D: serde::Deserializer<'de>,
77 {
78 let s = <&'de str>::deserialize(deserializer)?;
79 Ok(Self::from(s))
80 }
81}
82
83impl jacquard_common::IntoStatic for ActionType<'_> {
84 type Output = ActionType<'static>;
85 fn into_static(self) -> Self::Output {
86 match self {
87 ActionType::Block => ActionType::Block,
88 ActionType::Warn => ActionType::Warn,
89 ActionType::Whitelist => ActionType::Whitelist,
90 ActionType::Other(v) => ActionType::Other(v.into_static()),
91 }
92 }
93}
94
95/// An event for URL safety decisions
96#[jacquard_derive::lexicon]
97#[derive(
98 serde::Serialize,
99 serde::Deserialize,
100 Debug,
101 Clone,
102 PartialEq,
103 Eq,
104 jacquard_derive::IntoStatic,
105 bon::Builder
106)]
107#[serde(rename_all = "camelCase")]
108pub struct Event<'a> {
109 #[serde(borrow)]
110 pub action: crate::tools_ozone::safelink::ActionType<'a>,
111 /// Optional comment about the decision
112 #[serde(skip_serializing_if = "std::option::Option::is_none")]
113 #[builder(into)]
114 #[serde(borrow)]
115 pub comment: Option<jacquard_common::CowStr<'a>>,
116 pub created_at: jacquard_common::types::string::Datetime,
117 /// DID of the user who created this rule
118 #[serde(borrow)]
119 pub created_by: jacquard_common::types::string::Did<'a>,
120 #[serde(borrow)]
121 pub event_type: crate::tools_ozone::safelink::EventType<'a>,
122 /// Auto-incrementing row ID
123 pub id: i64,
124 #[serde(borrow)]
125 pub pattern: crate::tools_ozone::safelink::PatternType<'a>,
126 #[serde(borrow)]
127 pub reason: crate::tools_ozone::safelink::ReasonType<'a>,
128 /// The URL that this rule applies to
129 #[serde(borrow)]
130 #[builder(into)]
131 pub url: jacquard_common::CowStr<'a>,
132}
133
134#[derive(Debug, Clone, PartialEq, Eq, Hash)]
135pub enum EventType<'a> {
136 AddRule,
137 UpdateRule,
138 RemoveRule,
139 Other(jacquard_common::CowStr<'a>),
140}
141
142impl<'a> EventType<'a> {
143 pub fn as_str(&self) -> &str {
144 match self {
145 Self::AddRule => "addRule",
146 Self::UpdateRule => "updateRule",
147 Self::RemoveRule => "removeRule",
148 Self::Other(s) => s.as_ref(),
149 }
150 }
151}
152
153impl<'a> From<&'a str> for EventType<'a> {
154 fn from(s: &'a str) -> Self {
155 match s {
156 "addRule" => Self::AddRule,
157 "updateRule" => Self::UpdateRule,
158 "removeRule" => Self::RemoveRule,
159 _ => Self::Other(jacquard_common::CowStr::from(s)),
160 }
161 }
162}
163
164impl<'a> From<String> for EventType<'a> {
165 fn from(s: String) -> Self {
166 match s.as_str() {
167 "addRule" => Self::AddRule,
168 "updateRule" => Self::UpdateRule,
169 "removeRule" => Self::RemoveRule,
170 _ => Self::Other(jacquard_common::CowStr::from(s)),
171 }
172 }
173}
174
175impl<'a> AsRef<str> for EventType<'a> {
176 fn as_ref(&self) -> &str {
177 self.as_str()
178 }
179}
180
181impl<'a> serde::Serialize for EventType<'a> {
182 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
183 where
184 S: serde::Serializer,
185 {
186 serializer.serialize_str(self.as_str())
187 }
188}
189
190impl<'de, 'a> serde::Deserialize<'de> for EventType<'a>
191where
192 'de: 'a,
193{
194 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
195 where
196 D: serde::Deserializer<'de>,
197 {
198 let s = <&'de str>::deserialize(deserializer)?;
199 Ok(Self::from(s))
200 }
201}
202
203impl jacquard_common::IntoStatic for EventType<'_> {
204 type Output = EventType<'static>;
205 fn into_static(self) -> Self::Output {
206 match self {
207 EventType::AddRule => EventType::AddRule,
208 EventType::UpdateRule => EventType::UpdateRule,
209 EventType::RemoveRule => EventType::RemoveRule,
210 EventType::Other(v) => EventType::Other(v.into_static()),
211 }
212 }
213}
214
215#[derive(Debug, Clone, PartialEq, Eq, Hash)]
216pub enum PatternType<'a> {
217 Domain,
218 Url,
219 Other(jacquard_common::CowStr<'a>),
220}
221
222impl<'a> PatternType<'a> {
223 pub fn as_str(&self) -> &str {
224 match self {
225 Self::Domain => "domain",
226 Self::Url => "url",
227 Self::Other(s) => s.as_ref(),
228 }
229 }
230}
231
232impl<'a> From<&'a str> for PatternType<'a> {
233 fn from(s: &'a str) -> Self {
234 match s {
235 "domain" => Self::Domain,
236 "url" => Self::Url,
237 _ => Self::Other(jacquard_common::CowStr::from(s)),
238 }
239 }
240}
241
242impl<'a> From<String> for PatternType<'a> {
243 fn from(s: String) -> Self {
244 match s.as_str() {
245 "domain" => Self::Domain,
246 "url" => Self::Url,
247 _ => Self::Other(jacquard_common::CowStr::from(s)),
248 }
249 }
250}
251
252impl<'a> AsRef<str> for PatternType<'a> {
253 fn as_ref(&self) -> &str {
254 self.as_str()
255 }
256}
257
258impl<'a> serde::Serialize for PatternType<'a> {
259 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
260 where
261 S: serde::Serializer,
262 {
263 serializer.serialize_str(self.as_str())
264 }
265}
266
267impl<'de, 'a> serde::Deserialize<'de> for PatternType<'a>
268where
269 'de: 'a,
270{
271 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
272 where
273 D: serde::Deserializer<'de>,
274 {
275 let s = <&'de str>::deserialize(deserializer)?;
276 Ok(Self::from(s))
277 }
278}
279
280impl jacquard_common::IntoStatic for PatternType<'_> {
281 type Output = PatternType<'static>;
282 fn into_static(self) -> Self::Output {
283 match self {
284 PatternType::Domain => PatternType::Domain,
285 PatternType::Url => PatternType::Url,
286 PatternType::Other(v) => PatternType::Other(v.into_static()),
287 }
288 }
289}
290
291#[derive(Debug, Clone, PartialEq, Eq, Hash)]
292pub enum ReasonType<'a> {
293 Csam,
294 Spam,
295 Phishing,
296 None,
297 Other(jacquard_common::CowStr<'a>),
298}
299
300impl<'a> ReasonType<'a> {
301 pub fn as_str(&self) -> &str {
302 match self {
303 Self::Csam => "csam",
304 Self::Spam => "spam",
305 Self::Phishing => "phishing",
306 Self::None => "none",
307 Self::Other(s) => s.as_ref(),
308 }
309 }
310}
311
312impl<'a> From<&'a str> for ReasonType<'a> {
313 fn from(s: &'a str) -> Self {
314 match s {
315 "csam" => Self::Csam,
316 "spam" => Self::Spam,
317 "phishing" => Self::Phishing,
318 "none" => Self::None,
319 _ => Self::Other(jacquard_common::CowStr::from(s)),
320 }
321 }
322}
323
324impl<'a> From<String> for ReasonType<'a> {
325 fn from(s: String) -> Self {
326 match s.as_str() {
327 "csam" => Self::Csam,
328 "spam" => Self::Spam,
329 "phishing" => Self::Phishing,
330 "none" => Self::None,
331 _ => Self::Other(jacquard_common::CowStr::from(s)),
332 }
333 }
334}
335
336impl<'a> AsRef<str> for ReasonType<'a> {
337 fn as_ref(&self) -> &str {
338 self.as_str()
339 }
340}
341
342impl<'a> serde::Serialize for ReasonType<'a> {
343 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
344 where
345 S: serde::Serializer,
346 {
347 serializer.serialize_str(self.as_str())
348 }
349}
350
351impl<'de, 'a> serde::Deserialize<'de> for ReasonType<'a>
352where
353 'de: 'a,
354{
355 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
356 where
357 D: serde::Deserializer<'de>,
358 {
359 let s = <&'de str>::deserialize(deserializer)?;
360 Ok(Self::from(s))
361 }
362}
363
364impl jacquard_common::IntoStatic for ReasonType<'_> {
365 type Output = ReasonType<'static>;
366 fn into_static(self) -> Self::Output {
367 match self {
368 ReasonType::Csam => ReasonType::Csam,
369 ReasonType::Spam => ReasonType::Spam,
370 ReasonType::Phishing => ReasonType::Phishing,
371 ReasonType::None => ReasonType::None,
372 ReasonType::Other(v) => ReasonType::Other(v.into_static()),
373 }
374 }
375}
376
377/// Input for creating a URL safety rule
378#[jacquard_derive::lexicon]
379#[derive(
380 serde::Serialize,
381 serde::Deserialize,
382 Debug,
383 Clone,
384 PartialEq,
385 Eq,
386 jacquard_derive::IntoStatic,
387 bon::Builder
388)]
389#[serde(rename_all = "camelCase")]
390pub struct UrlRule<'a> {
391 #[serde(borrow)]
392 pub action: crate::tools_ozone::safelink::ActionType<'a>,
393 /// Optional comment about the decision
394 #[serde(skip_serializing_if = "std::option::Option::is_none")]
395 #[builder(into)]
396 #[serde(borrow)]
397 pub comment: Option<jacquard_common::CowStr<'a>>,
398 /// Timestamp when the rule was created
399 pub created_at: jacquard_common::types::string::Datetime,
400 /// DID of the user added the rule.
401 #[serde(borrow)]
402 pub created_by: jacquard_common::types::string::Did<'a>,
403 #[serde(borrow)]
404 pub pattern: crate::tools_ozone::safelink::PatternType<'a>,
405 #[serde(borrow)]
406 pub reason: crate::tools_ozone::safelink::ReasonType<'a>,
407 /// Timestamp when the rule was last updated
408 pub updated_at: jacquard_common::types::string::Datetime,
409 /// The URL or domain to apply the rule to
410 #[serde(borrow)]
411 #[builder(into)]
412 pub url: jacquard_common::CowStr<'a>,
413}