mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-23 13:42:04 +00:00
pbs-api-types: split out type RateLimitConfig
This commit is contained in:
parent
f2a761f9b1
commit
9815d90136
@ -30,13 +30,6 @@ pub const TRAFFIC_CONTROL_BURST_SCHEMA: Schema = IntegerSchema::new(
|
|||||||
|
|
||||||
#[api(
|
#[api(
|
||||||
properties: {
|
properties: {
|
||||||
name: {
|
|
||||||
schema: TRAFFIC_CONTROL_ID_SCHEMA,
|
|
||||||
},
|
|
||||||
comment: {
|
|
||||||
optional: true,
|
|
||||||
schema: SINGLE_LINE_COMMENT_SCHEMA,
|
|
||||||
},
|
|
||||||
"rate-in": {
|
"rate-in": {
|
||||||
type: HumanByte,
|
type: HumanByte,
|
||||||
optional: true,
|
optional: true,
|
||||||
@ -53,6 +46,45 @@ pub const TRAFFIC_CONTROL_BURST_SCHEMA: Schema = IntegerSchema::new(
|
|||||||
type: HumanByte,
|
type: HumanByte,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
)]
|
||||||
|
#[derive(Serialize,Deserialize,Default,Clone,Updater)]
|
||||||
|
#[serde(rename_all = "kebab-case")]
|
||||||
|
/// Rate Limit Configuration
|
||||||
|
pub struct RateLimitConfig {
|
||||||
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
|
pub rate_in: Option<HumanByte>,
|
||||||
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
|
pub burst_in: Option<HumanByte>,
|
||||||
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
|
pub rate_out: Option<HumanByte>,
|
||||||
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
|
pub burst_out: Option<HumanByte>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RateLimitConfig {
|
||||||
|
pub fn with_same_inout(rate: Option<HumanByte>, burst: Option<HumanByte>) -> Self {
|
||||||
|
Self {
|
||||||
|
rate_in: rate,
|
||||||
|
burst_in: burst,
|
||||||
|
rate_out: rate,
|
||||||
|
burst_out: burst,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[api(
|
||||||
|
properties: {
|
||||||
|
name: {
|
||||||
|
schema: TRAFFIC_CONTROL_ID_SCHEMA,
|
||||||
|
},
|
||||||
|
comment: {
|
||||||
|
optional: true,
|
||||||
|
schema: SINGLE_LINE_COMMENT_SCHEMA,
|
||||||
|
},
|
||||||
|
limit: {
|
||||||
|
type: RateLimitConfig,
|
||||||
|
},
|
||||||
network: {
|
network: {
|
||||||
type: Array,
|
type: Array,
|
||||||
items: {
|
items: {
|
||||||
@ -78,14 +110,8 @@ pub struct TrafficControlRule {
|
|||||||
pub comment: Option<String>,
|
pub comment: Option<String>,
|
||||||
/// Rule applies to Source IPs within this networks
|
/// Rule applies to Source IPs within this networks
|
||||||
pub network: Vec<String>,
|
pub network: Vec<String>,
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(flatten)]
|
||||||
pub rate_in: Option<HumanByte>,
|
pub limit: RateLimitConfig,
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
|
||||||
pub burst_in: Option<HumanByte>,
|
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
|
||||||
pub rate_out: Option<HumanByte>,
|
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
|
||||||
pub burst_out: Option<HumanByte>,
|
|
||||||
// fixme: expose this?
|
// fixme: expose this?
|
||||||
// /// Bandwidth is shared accross all connections
|
// /// Bandwidth is shared accross all connections
|
||||||
// #[serde(skip_serializing_if="Option::is_none")]
|
// #[serde(skip_serializing_if="Option::is_none")]
|
||||||
|
Loading…
Reference in New Issue
Block a user