cat_gateway/service/common/objects/config/
frontend_config.rs

1//! Frontend configuration objects.
2
3use derive_more::{From, Into};
4use poem_openapi::{types::Example, NewType, Object};
5
6use super::{environment::ConfigEnvironment, version::SemVer};
7use crate::service::common;
8
9/// Frontend JSON schema.
10#[derive(Object, Default)]
11#[oai(example = true)]
12pub(crate) struct FrontendConfig {
13    /// Sentry properties.
14    sentry: Option<ConfiguredSentry>,
15}
16
17impl Example for FrontendConfig {
18    fn example() -> Self {
19        Self {
20            sentry: Some(Example::example()),
21        }
22    }
23}
24
25/// Configured sentry using in `FrontendConfig`.
26#[derive(NewType, From, Into)]
27#[oai(
28    from_multipart = false,
29    from_parameter = false,
30    to_header = false,
31    example = true
32)]
33pub(crate) struct ConfiguredSentry(Sentry);
34
35impl Example for ConfiguredSentry {
36    fn example() -> Self {
37        Self(Example::example())
38    }
39}
40
41/// Frontend configuration for Sentry.
42#[derive(Object)]
43#[oai(example = true)]
44pub(crate) struct Sentry {
45    /// The Data Source Name (DSN) for Sentry.
46    dsn: common::types::generic::url::Url,
47    /// A version of the code deployed to an environment.
48    release: Option<SemVer>,
49    /// The environment in which the application is running, e.g., 'dev', 'qa'.
50    environment: Option<SentryConfiguredProfile>,
51}
52
53impl Example for Sentry {
54    fn example() -> Self {
55        Self {
56            dsn: Example::example(),
57            release: Some(Example::example()),
58            environment: Some(Example::example()),
59        }
60    }
61}
62
63/// Configured sentry profile.
64#[derive(NewType, From, Into)]
65#[oai(
66    from_multipart = false,
67    from_parameter = false,
68    to_header = false,
69    example = true
70)]
71pub(crate) struct SentryConfiguredProfile(ConfigEnvironment);
72
73impl Example for SentryConfiguredProfile {
74    fn example() -> Self {
75        Self(Example::example())
76    }
77}