use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum MonitoringDataFormat {
Structured,
Prometheus,
}
impl MonitoringDataFormat {
pub fn as_str(&self) -> &'static str {
match self {
Self::Structured => "structured",
Self::Prometheus => "prometheus",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum MonitoringPeriod {
#[serde(rename = "last5m")]
Last5m,
#[serde(rename = "last1h")]
Last1h,
#[serde(rename = "last24h")]
Last24h,
#[serde(rename = "last7d")]
Last7d,
#[serde(rename = "subscription")]
Subscription,
}
impl MonitoringPeriod {
pub fn as_str(&self) -> &'static str {
match self {
Self::Last5m => "last5m",
Self::Last1h => "last1h",
Self::Last24h => "last24h",
Self::Last7d => "last7d",
Self::Subscription => "subscription",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum MonitoringAggregation {
Account,
Project,
Target,
}
impl MonitoringAggregation {
pub fn as_str(&self) -> &'static str {
match self {
Self::Account => "account",
Self::Project => "project",
Self::Target => "target",
}
}
}
#[derive(Debug, Clone, Default)]
pub struct MonitoringMetricsOptions {
pub format: Option<MonitoringDataFormat>,
pub period: Option<MonitoringPeriod>,
pub aggregation: Option<Vec<MonitoringAggregation>>,
pub include_webhook: bool,
}
#[derive(Debug, Clone)]
pub struct MonitoringTargetMetricsOptions {
pub domain: String,
pub group_subdomain: bool,
pub period: Option<MonitoringPeriod>,
pub start: Option<String>,
pub end: Option<String>,
pub include_webhook: bool,
}
impl MonitoringTargetMetricsOptions {
pub fn for_domain(domain: impl Into<String>) -> Self {
Self {
domain: domain.into(),
group_subdomain: false,
period: None,
start: None,
end: None,
include_webhook: false,
}
}
}
#[derive(Debug, Clone, Default)]
pub struct CloudBrowserMonitoringOptions {
pub period: Option<MonitoringPeriod>,
pub proxy_pool: Option<String>,
pub start: Option<String>,
pub end: Option<String>,
}