wasmer_deploy_schema/schema/
ip_blacklist.rs

1use std::net::IpAddr;
2
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6use super::entity::EntityDescriptorConst;
7
8#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Eq, Clone, Debug)]
9pub enum BanScope {
10    /// Prevent all traffic on a network level.
11    #[serde(rename = "all_network_traffic")]
12    AllNetworkTraffic,
13}
14
15#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Eq, Clone, Debug)]
16pub struct IpBlacklistEntrySpec {
17    pub ips: Vec<IpAddr>,
18    pub scope: BanScope,
19    #[serde(
20        deserialize_with = "time::serde::timestamp::option::deserialize",
21        serialize_with = "time::serde::timestamp::option::serialize"
22    )]
23    #[schemars(with = "Option<u64>")]
24    pub valid_until: Option<time::OffsetDateTime>,
25}
26
27impl EntityDescriptorConst for IpBlacklistEntrySpec {
28    const NAMESPACE: &'static str = "edge.io";
29    const NAME: &'static str = "IpBlacklistEntry";
30    const VERSION: &'static str = "1";
31    const KIND: &'static str = "edge.io/IpBlacklistEntry.v1";
32
33    type Spec = Self;
34    type State = ();
35}
36
37pub type IpBlacklistEntry = super::entity::Entity<IpBlacklistEntrySpec>;