From 83d9af211a8e30a60b40098481c31919619b656c Mon Sep 17 00:00:00 2001 From: Sylvain Tremblay Date: Wed, 22 Apr 2026 09:53:22 -0400 Subject: [PATCH 1/7] fix(opnsense): distinguish unreachable API from missing HAProxy plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `LoadBalancerConfig::is_installed` previously collapsed every error from the settings endpoint into `false`, so a timeout, DNS failure, or auth rejection all looked identical to "os-haproxy not installed" — the `LoadBalancer` score would then attempt to install the plugin on top of an unreachable firewall and fail in cascade further down the pipeline. Return `Result` and treat only HTTP 404 (controller not found) as "not installed". Every other error is propagated so `ensure_initialized` fails the score immediately with a message pointing at the real problem. Co-Authored-By: Claude Opus 4.7 (1M context) --- harmony/src/infra/opnsense/load_balancer.rs | 7 ++++++- opnsense-config/src/modules/load_balancer.rs | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/harmony/src/infra/opnsense/load_balancer.rs b/harmony/src/infra/opnsense/load_balancer.rs index 4e496bed..94cb41f7 100644 --- a/harmony/src/infra/opnsense/load_balancer.rs +++ b/harmony/src/infra/opnsense/load_balancer.rs @@ -53,7 +53,12 @@ impl LoadBalancer for OPNSenseFirewall { async fn ensure_initialized(&self) -> Result<(), ExecutorError> { let lb = self.opnsense_config.load_balancer(); - if lb.is_installed().await { + let installed = lb.is_installed().await.map_err(|e| { + ExecutorError::UnexpectedError(format!( + "Failed to query HAProxy installation status on OPNsense: {e}" + )) + })?; + if installed { debug!("HAProxy is installed"); } else { self.opnsense_config diff --git a/opnsense-config/src/modules/load_balancer.rs b/opnsense-config/src/modules/load_balancer.rs index 3e255af5..781a5701 100644 --- a/opnsense-config/src/modules/load_balancer.rs +++ b/opnsense-config/src/modules/load_balancer.rs @@ -91,11 +91,23 @@ impl LoadBalancerConfig { } /// Check if the HAProxy plugin is installed. - pub async fn is_installed(&self) -> bool { - self.client + /// + /// Returns `Ok(true)` if the settings endpoint responds successfully, + /// `Ok(false)` only when OPNsense replies HTTP 404 (controller not found — + /// the canonical signal for a missing plugin). Every other error — transport + /// failure, auth rejection, server 5xx, decode failure — is propagated so + /// the caller does not mistake an unreachable firewall for an uninstalled + /// plugin and trigger an install attempt. + pub async fn is_installed(&self) -> Result { + match self + .client .get_typed::("haproxy", "settings", "get") .await - .is_ok() + { + Ok(_) => Ok(true), + Err(opnsense_api::Error::Api { status, .. }) if status.as_u16() == 404 => Ok(false), + Err(e) => Err(e), + } } /// Enable or disable HAProxy. -- 2.39.5 From 21035d2c56fe1aaa47189379d5060858732b01d8 Mon Sep 17 00:00:00 2001 From: Sylvain Tremblay Date: Wed, 22 Apr 2026 11:07:47 -0400 Subject: [PATCH 2/7] fix(opnsense): set HAProxy healthcheck/server fields explicitly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `configure_service` was relying on `..Default::default()` for most fields of the generated HAProxy structs. That leaked OPNsense's *model defaults* into the wire payload for fields Harmony never meant to default: - `http_host` → `localhost` (sent `Host: localhost` on every check) - `http_method` → `options` (sent OPTIONS instead of the declared method) - `http_version` → `http10` (wanted NONE) - `sslVerify` on real servers → `1` (broke self-signed backends) - Healthcheck `ssl` was never propagated, so SSL-required checks like kube-apiserver `/readyz` on 6443 stayed plain HTTP and never succeeded Set every field explicitly from `LbHealthCheck`/`LbServer`: map `http_method` through `HealthcheckHttpMethod`, pass `None` for `http_version` (serializes as `""` = NONE), clear `http_host` to an empty string, propagate `hc.ssl` through `HealthcheckSsl`, and pin `ssl`/`sslVerify` to `false` on the server struct so intent is declared at the call site. Co-Authored-By: Claude Opus 4.7 (1M context) --- opnsense-config/src/modules/load_balancer.rs | 29 ++++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/opnsense-config/src/modules/load_balancer.rs b/opnsense-config/src/modules/load_balancer.rs index 781a5701..bd54165e 100644 --- a/opnsense-config/src/modules/load_balancer.rs +++ b/opnsense-config/src/modules/load_balancer.rs @@ -2,9 +2,9 @@ use crate::Error; use log::{debug, info}; use opnsense_api::generated::haproxy::{ BackendAlgorithm, BackendMode, BackendPersistenceCookiemode, FrontendConnectionBehaviour, - FrontendMode, HealthcheckType, OpNsenseHaProxyBackendsBackend, - OpNsenseHaProxyFrontendsFrontend, OpNsenseHaProxyHealthchecksHealthcheck, - OpNsenseHaProxyServersServer, ServerMode, ServerType, + FrontendMode, HealthcheckHttpMethod, HealthcheckSsl, HealthcheckType, + OpNsenseHaProxyBackendsBackend, OpNsenseHaProxyFrontendsFrontend, + OpNsenseHaProxyHealthchecksHealthcheck, OpNsenseHaProxyServersServer, ServerMode, ServerType, }; use opnsense_api::response::StatusResponse; use opnsense_api::OpnsenseClient; @@ -179,6 +179,27 @@ impl LoadBalancerConfig { }), interval: hc.interval.clone(), http_uri: hc.http_uri.clone(), + http_method: hc.http_method.as_deref().map(|m| { + match m.to_lowercase().as_str() { + "options" => HealthcheckHttpMethod::OptionsDefault, + "head" => HealthcheckHttpMethod::Head, + "get" => HealthcheckHttpMethod::Get, + "put" => HealthcheckHttpMethod::Put, + "post" => HealthcheckHttpMethod::Post, + "delete" => HealthcheckHttpMethod::Delete, + "trace" => HealthcheckHttpMethod::Trace, + other => HealthcheckHttpMethod::Other(other.to_string()), + } + }), + http_version: None, + http_host: Some(String::new()), + ssl: hc.ssl.as_deref().map(|s| match s.to_lowercase().as_str() { + "ssl" => HealthcheckSsl::ForceSslForHealthChecks, + "sslsni" => HealthcheckSsl::ForceSslSniForHealthChecks, + "nossl" => HealthcheckSsl::ForceNoSslForHealthChecks, + "nopref" => HealthcheckSsl::UseServerSettings, + other => HealthcheckSsl::Other(other.to_string()), + }), checkport: hc.checkport.as_deref().and_then(|p| p.parse().ok()), ..Default::default() }; @@ -222,6 +243,8 @@ impl LoadBalancerConfig { "template" => ServerType::Template, other => ServerType::Other(other.to_string()), }), + ssl: false, + sslVerify: false, ..Default::default() }; #[derive(serde::Serialize)] -- 2.39.5 From 5e72777c1521aa65a5ab9b7458862f368f485928 Mon Sep 17 00:00:00 2001 From: Sylvain Tremblay Date: Wed, 22 Apr 2026 11:07:59 -0400 Subject: [PATCH 3/7] fix(okd): bind load balancer services on firewall IP, not 0.0.0.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Binding HAProxy on 0.0.0.0 collided with OPNsense's own listeners (HTTP→HTTPS redirect on :80, WebUI, etc.), preventing the HAProxy service from starting once the LoadBalancer score was applied. Use `topology.load_balancer.get_ip()` to bind each frontend on the firewall's LAN interface IP instead. The `LoadBalancer` capability was already in scope, so no new trait imports are needed. The previous `0.0.0.0` rationale (avoiding CARP VIP rebind races) is noted in a comment: HA CARP setups still need OPNsense's `net.inet.ip.nonlocal_bind` or HAProxy `transparent` bind — not addressed here. Test module: added an inline `DummyLoadBalancer` stub (mirrors the existing `DummyRouter` pattern) so `OKDLoadBalancerScore::new` no longer hits `DummyInfra::get_ip`'s `unimplemented!()` panic. Renamed `test_all_services_bind_on_unspecified_address` → `test_all_services_bind_on_firewall_ip`. Co-Authored-By: Claude Opus 4.7 (1M context) --- harmony/src/modules/okd/load_balancer.rs | 71 ++++++++++++++++++++---- 1 file changed, 59 insertions(+), 12 deletions(-) diff --git a/harmony/src/modules/okd/load_balancer.rs b/harmony/src/modules/okd/load_balancer.rs index 0f9dfa61..b66e9f6a 100644 --- a/harmony/src/modules/okd/load_balancer.rs +++ b/harmony/src/modules/okd/load_balancer.rs @@ -1,4 +1,4 @@ -use std::net::{IpAddr, Ipv4Addr, SocketAddr}; +use std::net::SocketAddr; use serde::Serialize; @@ -53,10 +53,12 @@ pub struct OKDLoadBalancerScore { /// ``` impl OKDLoadBalancerScore { pub fn new(topology: &HAClusterTopology) -> Self { - // Bind on 0.0.0.0 instead of the LAN IP to avoid CARP VIP race - // conditions where HAProxy fails to bind when the interface - // transitions back to master. - let bind_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED); + // Bind on the firewall's LAN interface IP so HAProxy does not + // collide with OPNsense's own services on 0.0.0.0 (HTTP redirect + // on :80, WebUI, etc.). For CARP HA setups binding to the VIP + // requires `net.inet.ip.nonlocal_bind` / HAProxy `transparent` to + // avoid rebind races when the VIP transitions — not handled here. + let bind_addr = topology.load_balancer.get_ip(); let public_services = vec![ LoadBalancerService { backend_servers: Self::nodes_to_backend_server(topology, 80), @@ -168,10 +170,13 @@ mod tests { use std::sync::{Arc, OnceLock}; use super::*; + use crate::executors::ExecutorError; use crate::topology::{DummyInfra, LogicalHost, Router}; use harmony_macros::ip; use harmony_types::net::IpAddress; + const TEST_FIREWALL_IP: &str = "192.168.1.1"; + fn create_test_topology() -> HAClusterTopology { let router = Arc::new(DummyRouter { gateway: ip!("192.168.1.1"), @@ -180,7 +185,7 @@ mod tests { HAClusterTopology { domain_name: "test.example.com".to_string(), router, - load_balancer: Arc::new(DummyInfra), + load_balancer: Arc::new(DummyLoadBalancer), firewall: Arc::new(DummyInfra), dhcp_server: Arc::new(DummyInfra), tftp_server: Arc::new(DummyInfra), @@ -244,6 +249,48 @@ mod tests { } } + struct DummyLoadBalancer; + + #[async_trait::async_trait] + impl LoadBalancer for DummyLoadBalancer { + fn get_ip(&self) -> IpAddress { + TEST_FIREWALL_IP.parse().unwrap() + } + fn get_host(&self) -> LogicalHost { + LogicalHost { + ip: TEST_FIREWALL_IP.parse().unwrap(), + name: "fw".to_string(), + } + } + async fn add_service( + &self, + _service: &LoadBalancerService, + ) -> Result<(), ExecutorError> { + unimplemented!() + } + async fn remove_service( + &self, + _service: &LoadBalancerService, + ) -> Result<(), ExecutorError> { + unimplemented!() + } + async fn list_services(&self) -> Vec { + unimplemented!() + } + async fn ensure_initialized(&self) -> Result<(), ExecutorError> { + unimplemented!() + } + async fn commit_config(&self) -> Result<(), ExecutorError> { + unimplemented!() + } + async fn reload_restart(&self) -> Result<(), ExecutorError> { + unimplemented!() + } + async fn ensure_wan_access(&self, _port: u16) -> Result<(), ExecutorError> { + unimplemented!() + } + } + #[test] fn test_nodes_to_backend_server_includes_control_plane_and_workers() { let topology = create_test_topology(); @@ -300,24 +347,24 @@ mod tests { } #[test] - fn test_all_services_bind_on_unspecified_address() { + fn test_all_services_bind_on_firewall_ip() { let topology = create_test_topology(); let score = OKDLoadBalancerScore::new(&topology); - let unspecified = IpAddr::V4(Ipv4Addr::UNSPECIFIED); + let fw_ip: IpAddress = TEST_FIREWALL_IP.parse().unwrap(); for svc in &score.load_balancer_score.public_services { assert_eq!( svc.listening_port.ip(), - unspecified, - "Public service on port {} should bind on 0.0.0.0", + fw_ip, + "Public service on port {} should bind on the firewall's LAN IP", svc.listening_port.port() ); } for svc in &score.load_balancer_score.private_services { assert_eq!( svc.listening_port.ip(), - unspecified, - "Private service on port {} should bind on 0.0.0.0", + fw_ip, + "Private service on port {} should bind on the firewall's LAN IP", svc.listening_port.port() ); } -- 2.39.5 From 5a17bc229e414b0612c5942830317362d3fb763f Mon Sep 17 00:00:00 2001 From: Sylvain Tremblay Date: Wed, 22 Apr 2026 11:29:33 -0400 Subject: [PATCH 4/7] fix: formatting --- harmony/src/modules/okd/load_balancer.rs | 5 +---- opnsense-config/src/modules/load_balancer.rs | 9 +++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/harmony/src/modules/okd/load_balancer.rs b/harmony/src/modules/okd/load_balancer.rs index b66e9f6a..083a159c 100644 --- a/harmony/src/modules/okd/load_balancer.rs +++ b/harmony/src/modules/okd/load_balancer.rs @@ -262,10 +262,7 @@ mod tests { name: "fw".to_string(), } } - async fn add_service( - &self, - _service: &LoadBalancerService, - ) -> Result<(), ExecutorError> { + async fn add_service(&self, _service: &LoadBalancerService) -> Result<(), ExecutorError> { unimplemented!() } async fn remove_service( diff --git a/opnsense-config/src/modules/load_balancer.rs b/opnsense-config/src/modules/load_balancer.rs index bd54165e..4e0beb5b 100644 --- a/opnsense-config/src/modules/load_balancer.rs +++ b/opnsense-config/src/modules/load_balancer.rs @@ -179,8 +179,10 @@ impl LoadBalancerConfig { }), interval: hc.interval.clone(), http_uri: hc.http_uri.clone(), - http_method: hc.http_method.as_deref().map(|m| { - match m.to_lowercase().as_str() { + http_method: hc + .http_method + .as_deref() + .map(|m| match m.to_lowercase().as_str() { "options" => HealthcheckHttpMethod::OptionsDefault, "head" => HealthcheckHttpMethod::Head, "get" => HealthcheckHttpMethod::Get, @@ -189,8 +191,7 @@ impl LoadBalancerConfig { "delete" => HealthcheckHttpMethod::Delete, "trace" => HealthcheckHttpMethod::Trace, other => HealthcheckHttpMethod::Other(other.to_string()), - } - }), + }), http_version: None, http_host: Some(String::new()), ssl: hc.ssl.as_deref().map(|s| match s.to_lowercase().as_str() { -- 2.39.5 From a196268c1e99a26824b3ea3fb6f4fc8e110293f1 Mon Sep 17 00:00:00 2001 From: Sylvain Tremblay Date: Wed, 22 Apr 2026 12:10:57 -0400 Subject: [PATCH 5/7] revert(okd): bind load balancer on 0.0.0.0 again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverting 5e72777. The HAProxy startup failure that motivated the bind-to-FW-IP change was environment-specific on the sttest basement firewall: OPNsense's "HTTP → HTTPS redirect" service (lighttpd bound to `[::]:80`, dual-stack) was holding IPv4 port 80 via v4-mapped addresses — invisible in `sockstat -l4` but still enough to make `0.0.0.0:80` return EADDRINUSE to HAProxy. Disabling the HTTP redirect on that firewall resolves the conflict. Other OPNsense deployments already ship with the redirect off (or HAProxy on non-conflicting ports), so `0.0.0.0` remains the correct default. This reverts commit 5e72777. Co-Authored-By: Claude Opus 4.7 (1M context) --- harmony/src/modules/okd/load_balancer.rs | 68 +++++------------------- 1 file changed, 12 insertions(+), 56 deletions(-) diff --git a/harmony/src/modules/okd/load_balancer.rs b/harmony/src/modules/okd/load_balancer.rs index 083a159c..0f9dfa61 100644 --- a/harmony/src/modules/okd/load_balancer.rs +++ b/harmony/src/modules/okd/load_balancer.rs @@ -1,4 +1,4 @@ -use std::net::SocketAddr; +use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use serde::Serialize; @@ -53,12 +53,10 @@ pub struct OKDLoadBalancerScore { /// ``` impl OKDLoadBalancerScore { pub fn new(topology: &HAClusterTopology) -> Self { - // Bind on the firewall's LAN interface IP so HAProxy does not - // collide with OPNsense's own services on 0.0.0.0 (HTTP redirect - // on :80, WebUI, etc.). For CARP HA setups binding to the VIP - // requires `net.inet.ip.nonlocal_bind` / HAProxy `transparent` to - // avoid rebind races when the VIP transitions — not handled here. - let bind_addr = topology.load_balancer.get_ip(); + // Bind on 0.0.0.0 instead of the LAN IP to avoid CARP VIP race + // conditions where HAProxy fails to bind when the interface + // transitions back to master. + let bind_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED); let public_services = vec![ LoadBalancerService { backend_servers: Self::nodes_to_backend_server(topology, 80), @@ -170,13 +168,10 @@ mod tests { use std::sync::{Arc, OnceLock}; use super::*; - use crate::executors::ExecutorError; use crate::topology::{DummyInfra, LogicalHost, Router}; use harmony_macros::ip; use harmony_types::net::IpAddress; - const TEST_FIREWALL_IP: &str = "192.168.1.1"; - fn create_test_topology() -> HAClusterTopology { let router = Arc::new(DummyRouter { gateway: ip!("192.168.1.1"), @@ -185,7 +180,7 @@ mod tests { HAClusterTopology { domain_name: "test.example.com".to_string(), router, - load_balancer: Arc::new(DummyLoadBalancer), + load_balancer: Arc::new(DummyInfra), firewall: Arc::new(DummyInfra), dhcp_server: Arc::new(DummyInfra), tftp_server: Arc::new(DummyInfra), @@ -249,45 +244,6 @@ mod tests { } } - struct DummyLoadBalancer; - - #[async_trait::async_trait] - impl LoadBalancer for DummyLoadBalancer { - fn get_ip(&self) -> IpAddress { - TEST_FIREWALL_IP.parse().unwrap() - } - fn get_host(&self) -> LogicalHost { - LogicalHost { - ip: TEST_FIREWALL_IP.parse().unwrap(), - name: "fw".to_string(), - } - } - async fn add_service(&self, _service: &LoadBalancerService) -> Result<(), ExecutorError> { - unimplemented!() - } - async fn remove_service( - &self, - _service: &LoadBalancerService, - ) -> Result<(), ExecutorError> { - unimplemented!() - } - async fn list_services(&self) -> Vec { - unimplemented!() - } - async fn ensure_initialized(&self) -> Result<(), ExecutorError> { - unimplemented!() - } - async fn commit_config(&self) -> Result<(), ExecutorError> { - unimplemented!() - } - async fn reload_restart(&self) -> Result<(), ExecutorError> { - unimplemented!() - } - async fn ensure_wan_access(&self, _port: u16) -> Result<(), ExecutorError> { - unimplemented!() - } - } - #[test] fn test_nodes_to_backend_server_includes_control_plane_and_workers() { let topology = create_test_topology(); @@ -344,24 +300,24 @@ mod tests { } #[test] - fn test_all_services_bind_on_firewall_ip() { + fn test_all_services_bind_on_unspecified_address() { let topology = create_test_topology(); let score = OKDLoadBalancerScore::new(&topology); - let fw_ip: IpAddress = TEST_FIREWALL_IP.parse().unwrap(); + let unspecified = IpAddr::V4(Ipv4Addr::UNSPECIFIED); for svc in &score.load_balancer_score.public_services { assert_eq!( svc.listening_port.ip(), - fw_ip, - "Public service on port {} should bind on the firewall's LAN IP", + unspecified, + "Public service on port {} should bind on 0.0.0.0", svc.listening_port.port() ); } for svc in &score.load_balancer_score.private_services { assert_eq!( svc.listening_port.ip(), - fw_ip, - "Private service on port {} should bind on the firewall's LAN IP", + unspecified, + "Private service on port {} should bind on 0.0.0.0", svc.listening_port.port() ); } -- 2.39.5 From fc16e9fac94eb7afb3e58eec40366c6991952f89 Mon Sep 17 00:00:00 2001 From: Sylvain Tremblay Date: Wed, 22 Apr 2026 12:31:35 -0400 Subject: [PATCH 6/7] refactor(opnsense): use From<&str> for wire-value conversions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses review feedback on the previous HAProxy field-default fixes: the eight match blocks in `configure_service` that mapped loose strings ("get", "tcp", "roundrobin", ...) to generated OPNsense enum variants were poor Rust — they duplicated the wire-value knowledge that the codegen already has, and any new enum variant in OPNsense meant editing every call site by hand. - `opnsense-codegen/src/codegen.rs::generate_enum` now emits `impl From<&str>` and `impl From` for every generated enum, right after the existing serde module. Lowercase-matches wire values; unknown inputs fall through to the `Other(String)` variant the codegen already emits for forward-compat round-tripping. - `opnsense-api/src/generated/haproxy.rs` regenerated — 153 enums, 306 new impl blocks. No hand edits; re-run via `cargo run -p opnsense-codegen -- generate --xml opnsense-codegen/vendor/plugins/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.xml --output-dir opnsense-api/src/generated --module-name haproxy`. - `opnsense-config/src/modules/load_balancer.rs::configure_service` replaces eight string-match blocks with one-liners: `HealthcheckType::from(hc.check_type.as_str())` etc. - Drive-by: fixed a pre-existing typo at `harmony/src/infra/opnsense/load_balancer.rs:185` and the matching reverse at `:149` — `SSL::SNI` was mapped to `"sslni"`, but the OPNsense wire value is `"sslsni"`. Before this refactor the typo silently hit `HealthcheckSsl::Other("sslni")`; the cleaner conversion made the bug obvious so it's fixed here rather than left for a follow-up. Verification: - `cargo check -p harmony -p opnsense-config -p opnsense-api` clean - `cargo test -p harmony --lib okd::load_balancer` 6/6 pass - `cargo test -p opnsense-codegen` 22/22 pass Co-Authored-By: Claude Opus 4.7 (1M context) --- harmony/src/infra/opnsense/load_balancer.rs | 4 +- opnsense-api/src/generated/haproxy.rs | 3407 +++++++++++++++++- opnsense-codegen/src/codegen.rs | 27 + opnsense-config/src/modules/load_balancer.rs | 69 +- 4 files changed, 3442 insertions(+), 65 deletions(-) diff --git a/harmony/src/infra/opnsense/load_balancer.rs b/harmony/src/infra/opnsense/load_balancer.rs index 94cb41f7..933f179d 100644 --- a/harmony/src/infra/opnsense/load_balancer.rs +++ b/harmony/src/infra/opnsense/load_balancer.rs @@ -146,7 +146,7 @@ fn haproxy_service_to_harmony(svc: &HaproxyService) -> Option SSL::SSL, - "SSLNI" => SSL::SNI, + "SSLSNI" => SSL::SNI, "NOSSL" => SSL::Disabled, "" => SSL::Default, other => { @@ -182,7 +182,7 @@ pub(crate) fn harmony_service_to_lb_types( HealthCheck::HTTP(port, path, http_method, _status_code, ssl) => { let ssl_str = match ssl { SSL::SSL => Some("ssl".to_string()), - SSL::SNI => Some("sslni".to_string()), + SSL::SNI => Some("sslsni".to_string()), SSL::Disabled => Some("nossl".to_string()), SSL::Default => Some(String::new()), SSL::Other(other) => Some(other.clone()), diff --git a/opnsense-api/src/generated/haproxy.rs b/opnsense-api/src/generated/haproxy.rs index 10f934f5..4d18be42 100644 --- a/opnsense-api/src/generated/haproxy.rs +++ b/opnsense-api/src/generated/haproxy.rs @@ -367,6 +367,22 @@ pub(crate) mod serde_resolvers_prefer { } } +impl From<&str> for ResolversPrefer { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "ipv4" => Self::IPv4, + "ipv6" => Self::IPv6, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ResolversPrefer { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// SslServerVerify #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum SslServerVerify { @@ -442,6 +458,23 @@ pub(crate) mod serde_ssl_server_verify { } } +impl From<&str> for SslServerVerify { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "ignore" => Self::NoPreferenceDefault, + "required" => Self::EnforceVerify, + "none" => Self::DisableVerify, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for SslServerVerify { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// SslBindOptions #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum SslBindOptions { @@ -567,6 +600,33 @@ pub(crate) mod serde_ssl_bind_options { } } +impl From<&str> for SslBindOptions { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "no-sslv3" => Self::NoSslv3, + "no-tlsv10" => Self::NoTlsv10, + "no-tlsv11" => Self::NoTlsv11, + "no-tlsv12" => Self::NoTlsv12, + "no-tlsv13" => Self::NoTlsv13, + "no-tls-tickets" => Self::NoTlsTickets, + "force-sslv3" => Self::ForceSslv3, + "force-tlsv10" => Self::ForceTlsv10, + "force-tlsv11" => Self::ForceTlsv11, + "force-tlsv12" => Self::ForceTlsv12, + "force-tlsv13" => Self::ForceTlsv13, + "prefer-client-ciphers" => Self::PreferClientCiphers, + "strict-sni" => Self::StrictSni, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for SslBindOptions { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// SslMinVersion #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum SslMinVersion { @@ -652,6 +712,25 @@ pub(crate) mod serde_ssl_min_version { } } +impl From<&str> for SslMinVersion { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "SSLv3" => Self::SsLv3, + "TLSv1.0" => Self::TlSv10, + "TLSv1.1" => Self::TlSv11, + "TLSv1.2" => Self::TlSv12, + "TLSv1.3" => Self::TlSv13, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for SslMinVersion { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// SslMaxVersion #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum SslMaxVersion { @@ -737,6 +816,25 @@ pub(crate) mod serde_ssl_max_version { } } +impl From<&str> for SslMaxVersion { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "SSLv3" => Self::SsLv3, + "TLSv1.0" => Self::TlSv10, + "TLSv1.1" => Self::TlSv11, + "TLSv1.2" => Self::TlSv12, + "TLSv1.3" => Self::TlSv13, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for SslMaxVersion { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// Redispatch #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum Redispatch { @@ -832,6 +930,27 @@ pub(crate) mod serde_redispatch { } } +impl From<&str> for Redispatch { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "x3" => Self::RedispatchOnEvery3rdRetry, + "x2" => Self::RedispatchOnEvery2ndRetry, + "x1" => Self::RedispatchOnEveryRetry, + "x0" => Self::DisableRedispatching, + "x-1" => Self::RedispatchOnTheLastRetryDefault, + "x-2" => Self::RedispatchOnThe2ndRetryPriorToTheLastRetry, + "x-3" => Self::RedispatchOnThe3rdRetryPriorToTheLastRetry, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for Redispatch { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// InitAddr #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum InitAddr { @@ -907,6 +1026,23 @@ pub(crate) mod serde_init_addr { } } +impl From<&str> for InitAddr { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "last" => Self::Last, + "libc" => Self::Libc, + "none" => Self::None, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for InitAddr { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// Facility #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum Facility { @@ -1087,6 +1223,44 @@ pub(crate) mod serde_facility { } } +impl From<&str> for Facility { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "alert" => Self::Alert, + "audit" => Self::Audit, + "auth2" => Self::Auth2, + "auth" => Self::Auth, + "cron2" => Self::Cron2, + "cron" => Self::Cron, + "daemon" => Self::Daemon, + "ftp" => Self::Ftp, + "kern" => Self::Kern, + "local0" => Self::Local0Default, + "local1" => Self::Local1, + "local2" => Self::Local2, + "local3" => Self::Local3, + "local4" => Self::Local4, + "local5" => Self::Local5, + "local6" => Self::Local6, + "local7" => Self::Local7, + "lpr" => Self::Lpr, + "mail" => Self::Mail, + "news" => Self::News, + "ntp" => Self::Ntp, + "syslog" => Self::Syslog, + "user" => Self::User, + "uucp" => Self::Uucp, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for Facility { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// Level #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum Level { @@ -1187,6 +1361,28 @@ pub(crate) mod serde_level { } } +impl From<&str> for Level { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "alert" => Self::Alert, + "crit" => Self::Crit, + "debug" => Self::Debug, + "emerg" => Self::Emerg, + "err" => Self::Err, + "info" => Self::InfoDefault, + "notice" => Self::Notice, + "warning" => Self::Warning, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for Level { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// FrontendMode #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum FrontendMode { @@ -1262,6 +1458,23 @@ pub(crate) mod serde_frontend_mode { } } +impl From<&str> for FrontendMode { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "http" => Self::HttpHttpsSslOffloadingDefault, + "ssl" => Self::SslHttpsTcpMode, + "tcp" => Self::Tcp, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for FrontendMode { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// FrontendSslBindOptions #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum FrontendSslBindOptions { @@ -1391,6 +1604,33 @@ pub(crate) mod serde_frontend_ssl_bind_options { } } +impl From<&str> for FrontendSslBindOptions { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "no-sslv3" => Self::NoSslv3, + "no-tlsv10" => Self::NoTlsv10, + "no-tlsv11" => Self::NoTlsv11, + "no-tlsv12" => Self::NoTlsv12, + "no-tlsv13" => Self::NoTlsv13, + "no-tls-tickets" => Self::NoTlsTickets, + "force-sslv3" => Self::ForceSslv3, + "force-tlsv10" => Self::ForceTlsv10, + "force-tlsv11" => Self::ForceTlsv11, + "force-tlsv12" => Self::ForceTlsv12, + "force-tlsv13" => Self::ForceTlsv13, + "prefer-client-ciphers" => Self::PreferClientCiphers, + "strict-sni" => Self::StrictSni, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for FrontendSslBindOptions { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// FrontendSslMinVersion #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum FrontendSslMinVersion { @@ -1476,6 +1716,25 @@ pub(crate) mod serde_frontend_ssl_min_version { } } +impl From<&str> for FrontendSslMinVersion { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "SSLv3" => Self::SsLv3, + "TLSv1.0" => Self::TlSv10, + "TLSv1.1" => Self::TlSv11, + "TLSv1.2" => Self::TlSv12, + "TLSv1.3" => Self::TlSv13, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for FrontendSslMinVersion { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// FrontendSslMaxVersion #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum FrontendSslMaxVersion { @@ -1561,6 +1820,25 @@ pub(crate) mod serde_frontend_ssl_max_version { } } +impl From<&str> for FrontendSslMaxVersion { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "SSLv3" => Self::SsLv3, + "TLSv1.0" => Self::TlSv10, + "TLSv1.1" => Self::TlSv11, + "TLSv1.2" => Self::TlSv12, + "TLSv1.3" => Self::TlSv13, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for FrontendSslMaxVersion { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// FrontendSslClientAuthVerify #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum FrontendSslClientAuthVerify { @@ -1636,6 +1914,23 @@ pub(crate) mod serde_frontend_ssl_client_auth_verify { } } +impl From<&str> for FrontendSslClientAuthVerify { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "none" => Self::None, + "optional" => Self::Optional, + "required" => Self::Required, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for FrontendSslClientAuthVerify { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// FrontendStickinessPattern #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum FrontendStickinessPattern { @@ -1721,6 +2016,25 @@ pub(crate) mod serde_frontend_stickiness_pattern { } } +impl From<&str> for FrontendStickinessPattern { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "binary" => Self::Binary, + "integer" => Self::Integer, + "ipv4" => Self::IPv4Default, + "ipv6" => Self::IPv6, + "string" => Self::String, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for FrontendStickinessPattern { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// FrontendStickinessDataTypes #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum FrontendStickinessDataTypes { @@ -1953,6 +2267,46 @@ pub(crate) mod serde_frontend_stickiness_data_types { } } +impl From<&str> for FrontendStickinessDataTypes { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "bytes_in_cnt" => Self::BytesInCountClientToServer, + "bytes_in_rate" => Self::BytesInRateClientToServer, + "bytes_out_cnt" => Self::BytesOutCountServerToClient, + "bytes_out_rate" => Self::BytesOutRateServerToClient, + "conn_cnt" => Self::ConnectionCountTotal, + "conn_cur" => Self::ConnectionCountCurrent, + "conn_rate" => Self::ConnectionRate, + "glitch_cnt" => Self::GlitchCount, + "glitch_rate" => Self::GlitchRate, + "gpc" => Self::GeneralPurposeCountersArrayOfElements, + "gpc_rate" => Self::GeneralPurposeCounterRate, + "gpc0" => Self::Gpc0, + "gpc0_rate" => Self::Gpc0Rate, + "gpc1" => Self::Gpc1, + "gpc1_rate" => Self::Gpc1Rate, + "gpt" => Self::GeneralPurposeTagsArrayOfElements, + "gpt0" => Self::Gpt0, + "http_err_cnt" => Self::HttpErrorCount, + "http_err_rate" => Self::HttpErrorRate, + "http_fail_cnt" => Self::HttpFailCount, + "http_fail_rate" => Self::HttpFailRate, + "http_req_cnt" => Self::HttpRequestCount, + "http_req_rate" => Self::HttpRequestRate, + "server_id" => Self::ServerId, + "sess_cnt" => Self::SessionCount, + "sess_rate" => Self::SessionRate, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for FrontendStickinessDataTypes { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// FrontendAdvertisedProtocols #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum FrontendAdvertisedProtocols { @@ -2033,6 +2387,24 @@ pub(crate) mod serde_frontend_advertised_protocols { } } +impl From<&str> for FrontendAdvertisedProtocols { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "h3" => Self::Http3, + "h2" => Self::Http2, + "http11" => Self::Http11, + "http10" => Self::Http10, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for FrontendAdvertisedProtocols { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// FrontendConnectionBehaviour #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum FrontendConnectionBehaviour { @@ -2116,6 +2488,23 @@ pub(crate) mod serde_frontend_connection_behaviour { } } +impl From<&str> for FrontendConnectionBehaviour { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "http-keep-alive" => Self::HttpKeepAliveDefault, + "httpclose" => Self::Httpclose, + "http-server-close" => Self::HttpServerClose, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for FrontendConnectionBehaviour { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// BackendMode #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum BackendMode { @@ -2186,6 +2575,22 @@ pub(crate) mod serde_backend_mode { } } +impl From<&str> for BackendMode { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "http" => Self::HttpLayer7Default, + "tcp" => Self::TcpLayer4, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for BackendMode { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// BackendAlgorithm #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum BackendAlgorithm { @@ -2276,6 +2681,26 @@ pub(crate) mod serde_backend_algorithm { } } +impl From<&str> for BackendAlgorithm { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "source" => Self::SourceIpHashDefault, + "roundrobin" => Self::RoundRobin, + "static-rr" => Self::StaticRoundRobin, + "leastconn" => Self::LeastConnections, + "uri" => Self::UriHashOnlyHttpMode, + "random" => Self::RandomAlgorithm, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for BackendAlgorithm { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// BackendProxyProtocol #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum BackendProxyProtocol { @@ -2346,6 +2771,22 @@ pub(crate) mod serde_backend_proxy_protocol { } } +impl From<&str> for BackendProxyProtocol { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "v1" => Self::Version1, + "v2" => Self::Version2, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for BackendProxyProtocol { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// BackendResolverOpts #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum BackendResolverOpts { @@ -2421,6 +2862,23 @@ pub(crate) mod serde_backend_resolver_opts { } } +impl From<&str> for BackendResolverOpts { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "allow-dup-ip" => Self::AllowDupIp, + "ignore-weight" => Self::IgnoreWeight, + "prevent-dup-ip" => Self::PreventDupIp, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for BackendResolverOpts { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// BackendResolvePrefer #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum BackendResolvePrefer { @@ -2491,6 +2949,22 @@ pub(crate) mod serde_backend_resolve_prefer { } } +impl From<&str> for BackendResolvePrefer { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "ipv4" => Self::PreferIPv4, + "ipv6" => Self::PreferIPv6Default, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for BackendResolvePrefer { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// BackendHealthCheckProxyProto #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum BackendHealthCheckProxyProto { @@ -2576,6 +3050,23 @@ pub(crate) mod serde_backend_health_check_proxy_proto { } } +impl From<&str> for BackendHealthCheckProxyProto { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "backend" => Self::FollowBackendPoolSettingsDefault, + "enable" => Self::EnableForHealthCheck, + "disable" => Self::DisableForHealthCheck, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for BackendHealthCheckProxyProto { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// BackendBaAdvertisedProtocols #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum BackendBaAdvertisedProtocols { @@ -2651,6 +3142,23 @@ pub(crate) mod serde_backend_ba_advertised_protocols { } } +impl From<&str> for BackendBaAdvertisedProtocols { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "h2" => Self::Http2, + "http11" => Self::Http11, + "http10" => Self::Http10, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for BackendBaAdvertisedProtocols { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// BackendForwardedHeaderParameters #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum BackendForwardedHeaderParameters { @@ -2747,6 +3255,26 @@ pub(crate) mod serde_backend_forwarded_header_parameters { } } +impl From<&str> for BackendForwardedHeaderParameters { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "proto" => Self::Proto, + "host" => Self::Host, + "by" => Self::By, + "by_port" => Self::ByPort, + "for" => Self::For, + "for_port" => Self::ForPort, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for BackendForwardedHeaderParameters { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// BackendPersistence #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum BackendPersistence { @@ -2827,6 +3355,22 @@ pub(crate) mod serde_backend_persistence { } } +impl From<&str> for BackendPersistence { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "sticktable" => Self::StickTablePersistenceDefault, + "cookie" => Self::CookieBasedPersistenceHttpHttpsOnly, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for BackendPersistence { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// BackendPersistenceCookiemode #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum BackendPersistenceCookiemode { @@ -2903,6 +3447,22 @@ pub(crate) mod serde_backend_persistence_cookiemode { } } +impl From<&str> for BackendPersistenceCookiemode { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "piggyback" => Self::PiggybackOnExistingCookie, + "new" => Self::InsertNewCookie, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for BackendPersistenceCookiemode { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// BackendStickinessPattern #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum BackendStickinessPattern { @@ -2998,6 +3558,27 @@ pub(crate) mod serde_backend_stickiness_pattern { } } +impl From<&str> for BackendStickinessPattern { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "binary" => Self::Binary, + "cookievalue" => Self::CookieValue, + "integer" => Self::Integer, + "rdpcookie" => Self::RdpCookie, + "sourceipv4" => Self::SourceIPv4Default, + "sourceipv6" => Self::SourceIPv6, + "string" => Self::String, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for BackendStickinessPattern { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// BackendStickinessDataTypes #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum BackendStickinessDataTypes { @@ -3228,6 +3809,46 @@ pub(crate) mod serde_backend_stickiness_data_types { } } +impl From<&str> for BackendStickinessDataTypes { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "bytes_in_cnt" => Self::BytesInCountClientToServer, + "bytes_in_rate" => Self::BytesInRateClientToServer, + "bytes_out_cnt" => Self::BytesOutCountServerToClient, + "bytes_out_rate" => Self::BytesOutRateServerToClient, + "conn_cnt" => Self::ConnectionCountTotal, + "conn_cur" => Self::ConnectionCountCurrent, + "conn_rate" => Self::ConnectionRate, + "glitch_cnt" => Self::GlitchCount, + "glitch_rate" => Self::GlitchRate, + "gpc" => Self::GeneralPurposeCountersArrayOfElements, + "gpc_rate" => Self::GeneralPurposeCounterRate, + "gpc0" => Self::Gpc0, + "gpc0_rate" => Self::Gpc0Rate, + "gpc1" => Self::Gpc1, + "gpc1_rate" => Self::Gpc1Rate, + "gpt" => Self::GeneralPurposeTagsArrayOfElements, + "gpt0" => Self::Gpt0, + "http_err_cnt" => Self::HttpErrorCount, + "http_err_rate" => Self::HttpErrorRate, + "http_fail_cnt" => Self::HttpFailCount, + "http_fail_rate" => Self::HttpFailRate, + "http_req_cnt" => Self::HttpRequestCount, + "http_req_rate" => Self::HttpRequestRate, + "server_id" => Self::ServerId, + "sess_cnt" => Self::SessionCount, + "sess_rate" => Self::SessionRate, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for BackendStickinessDataTypes { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// BackendTuningHttpreuse #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum BackendTuningHttpreuse { @@ -3308,6 +3929,24 @@ pub(crate) mod serde_backend_tuning_httpreuse { } } +impl From<&str> for BackendTuningHttpreuse { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "never" => Self::Never, + "safe" => Self::SafeDefault, + "aggressive" => Self::Aggressive, + "always" => Self::Always, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for BackendTuningHttpreuse { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ServerMode #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ServerMode { @@ -3383,6 +4022,23 @@ pub(crate) mod serde_server_mode { } } +impl From<&str> for ServerMode { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "active" => Self::ActiveDefault, + "backup" => Self::Backup, + "disabled" => Self::Disabled, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ServerMode { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ServerMultiplexerProtocol #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ServerMultiplexerProtocol { @@ -3467,6 +4123,24 @@ pub(crate) mod serde_server_multiplexer_protocol { } } +impl From<&str> for ServerMultiplexerProtocol { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "unspecified" => Self::AutoSelectionRecommended, + "fcgi" => Self::FastCgi, + "h2" => Self::Http2, + "h1" => Self::Http11, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ServerMultiplexerProtocol { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ServerType #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ServerType { @@ -3542,6 +4216,23 @@ pub(crate) mod serde_server_type { } } +impl From<&str> for ServerType { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "static" => Self::Static, + "template" => Self::Template, + "unix" => Self::UnixSocket, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ServerType { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ServerResolverOpts #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ServerResolverOpts { @@ -3617,6 +4308,23 @@ pub(crate) mod serde_server_resolver_opts { } } +impl From<&str> for ServerResolverOpts { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "allow-dup-ip" => Self::AllowDupIp, + "ignore-weight" => Self::IgnoreWeight, + "prevent-dup-ip" => Self::PreventDupIp, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ServerResolverOpts { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ServerResolvePrefer #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ServerResolvePrefer { @@ -3687,6 +4395,22 @@ pub(crate) mod serde_server_resolve_prefer { } } +impl From<&str> for ServerResolvePrefer { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "ipv4" => Self::PreferIPv4, + "ipv6" => Self::PreferIPv6Default, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ServerResolvePrefer { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// HealthcheckType #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum HealthcheckType { @@ -3797,6 +4521,30 @@ pub(crate) mod serde_healthcheck_type { } } +impl From<&str> for HealthcheckType { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "tcp" => Self::Tcp, + "http" => Self::HttpDefault, + "agent" => Self::Agent, + "ldap" => Self::Ldap, + "mysql" => Self::MySql, + "pgsql" => Self::PostgreSql, + "redis" => Self::Redis, + "smtp" => Self::Smtp, + "esmtp" => Self::Esmtp, + "ssl" => Self::Ssl, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for HealthcheckType { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// HealthcheckSsl #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum HealthcheckSsl { @@ -3877,6 +4625,24 @@ pub(crate) mod serde_healthcheck_ssl { } } +impl From<&str> for HealthcheckSsl { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "nopref" => Self::UseServerSettings, + "ssl" => Self::ForceSslForHealthChecks, + "sslsni" => Self::ForceSslSniForHealthChecks, + "nossl" => Self::ForceNoSslForHealthChecks, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for HealthcheckSsl { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// HealthcheckHttpMethod #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum HealthcheckHttpMethod { @@ -3972,6 +4738,27 @@ pub(crate) mod serde_healthcheck_http_method { } } +impl From<&str> for HealthcheckHttpMethod { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "options" => Self::OptionsDefault, + "head" => Self::Head, + "get" => Self::Get, + "put" => Self::Put, + "post" => Self::Post, + "delete" => Self::Delete, + "trace" => Self::Trace, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for HealthcheckHttpMethod { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// HealthcheckHttpVersion #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum HealthcheckHttpVersion { @@ -4047,6 +4834,23 @@ pub(crate) mod serde_healthcheck_http_version { } } +impl From<&str> for HealthcheckHttpVersion { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "http10" => Self::Http10Default, + "http11" => Self::Http11, + "http2" => Self::Http2, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for HealthcheckHttpVersion { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// HealthcheckHttpExpression #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum HealthcheckHttpExpression { @@ -4159,6 +4963,24 @@ pub(crate) mod serde_healthcheck_http_expression { } } +impl From<&str> for HealthcheckHttpExpression { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "status" => Self::TestTheExactStringMatchForTheHttpStatusCode, + "rstatus" => Self::TestARegularExpressionForTheHttpStatusCode, + "string" => Self::TestTheExactStringMatchInTheHttpResponseBody, + "rstring" => Self::TestARegularExpressionOnTheHttpResponseBody, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for HealthcheckHttpExpression { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// HealthcheckTcpMatchType #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum HealthcheckTcpMatchType { @@ -4229,6 +5051,23 @@ pub(crate) mod serde_healthcheck_tcp_match_type { } } +impl From<&str> for HealthcheckTcpMatchType { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "string" => Self::TestTheExactStringMatchInTheResponseBufferDefault, + "rstring" => Self::TestARegularExpressionOnTheResponseBuffer, + "binary" => Self::TestTheExactStringInItsHexadecimalFormMatchesInTheResponseBuffer, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for HealthcheckTcpMatchType { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclExpression #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclExpression { @@ -4929,6 +5768,151 @@ pub(crate) mod serde_acl_expression { } } +impl From<&str> for AclExpression { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "cust_hdr_beg" => Self::HdrBegSpecifiedHttpHeaderStartsWith, + "cust_hdr_end" => Self::HdrEndSpecifiedHttpHeaderEndsWith, + "cust_hdr" => Self::HdrSpecifiedHttpHeaderMatches, + "cust_hdr_reg" => Self::HdrRegSpecifiedHttpHeaderRegex, + "cust_hdr_sub" => Self::HdrSubSpecifiedHttpHeaderContains, + "hdr_beg" => Self::HdrBegHttpHostHeaderStartsWith, + "hdr_end" => Self::HdrEndHttpHostHeaderEndsWith, + "hdr" => Self::HdrHttpHostHeaderMatches, + "hdr_reg" => Self::HdrRegHttpHostHeaderRegex, + "hdr_sub" => Self::HdrSubHttpHostHeaderContains, + "http_auth" => { + Self::HttpAuthHttpBasicAuthUsernamePasswordFromClientMatchesSelectedUserGroup + } + "http_method" => Self::HttpMethodHttpMethod, + "nbsrv" => Self::NbsrvMinimumNumberOfUsableServersInBackend, + "path_beg" => Self::PathBegPathStartsWith, + "path_dir" => Self::PathDirPathContainsSubdir, + "path_end" => Self::PathEndPathEndsWith, + "path" => Self::PathPathMatches, + "path_reg" => Self::PathRegPathRegex, + "path_sub" => Self::PathSubPathContainsString, + "quic_enabled" => Self::QuicEnabledQuicTransportProtocolIsEnabled, + "traffic_is_http" => Self::ReqProtoHttpTrafficIsHttp, + "traffic_is_ssl" => Self::ReqSslVerTrafficIsSslTcpRequestContentInspection, + "sc_bytes_in_rate" => Self::ScBytesInRateStickyCounterIncomingBytesRate, + "sc_bytes_out_rate" => Self::ScBytesOutRateStickyCounterOutgoingBytesRate, + "sc_clr_gpc" => Self::ScClrGpcStickyCounterClearGeneralPurposeCounter, + "sc_clr_gpc0" => Self::ScClrGpc0StickyCounterClearGeneralPurposeCounter, + "sc_clr_gpc1" => Self::ScClrGpc1StickyCounterClearGeneralPurposeCounter, + "sc0_clr_gpc0" => Self::Sc0ClrGpc0StickyCounterClearGeneralPurposeCounter, + "sc0_clr_gpc1" => Self::Sc0ClrGpc1StickyCounterClearGeneralPurposeCounter, + "sc1_clr_gpc" => Self::Sc1ClrGpcStickyCounterClearGeneralPurposeCounter, + "sc1_clr_gpc0" => Self::Sc1ClrGpc0StickyCounterClearGeneralPurposeCounter, + "sc1_clr_gpc1" => Self::Sc1ClrGpc1StickyCounterClearGeneralPurposeCounter, + "sc2_clr_gpc" => Self::Sc2ClrGpcStickyCounterClearGeneralPurposeCounter, + "sc2_clr_gpc0" => Self::Sc2ClrGpc0StickyCounterClearGeneralPurposeCounter, + "sc2_clr_gpc1" => Self::Sc2ClrGpc1StickyCounterClearGeneralPurposeCounter, + "sc_conn_cnt" => Self::ScConnCntStickyCounterCumulativeNumberOfConnections, + "sc_conn_cur" => Self::ScConnCurStickyCounterConcurrentConnections, + "sc_conn_rate" => Self::ScConnRateStickyCounterConnectionRate, + "sc_get_gpc" => Self::ScGetGpcStickyCounterGetGeneralPurposeCounterValue, + "sc_get_gpc0" => Self::ScGetGpc0StickyCounterGetGeneralPurposeCounterValue, + "sc_get_gpc1" => Self::ScGetGpc1StickyCounterGetGeneralPurposeCounterValue, + "sc0_get_gpc0" => Self::Sc0GetGpc0StickyCounterGetGeneralPurposeCounterValue, + "sc0_get_gpc1" => Self::Sc0GetGpc1StickyCounterGetGeneralPurposeCounterValue, + "sc1_get_gpc0" => Self::Sc1GetGpc0StickyCounterGetGeneralPurposeCounterValue, + "sc1_get_gpc1" => Self::Sc1GetGpc1StickyCounterGetGeneralPurposeCounterValue, + "sc2_get_gpc0" => Self::Sc2GetGpc0StickyCounterGetGeneralPurposeCounterValue, + "sc2_get_gpc1" => Self::Sc2GetGpc1StickyCounterGetGeneralPurposeCounterValue, + "sc_get_gpt" => Self::ScGetGptStickyCounterGetGeneralPurposeTagValue, + "sc_get_gpt0" => Self::ScGetGpt0StickyCounterGetGeneralPurposeTagValue, + "sc0_get_gpt0" => Self::Sc0GetGpt0StickyCounterGetGeneralPurposeTagValue, + "sc1_get_gpt0" => Self::Sc1GetGpt0StickyCounterGetGeneralPurposeTagValue, + "sc2_get_gpt0" => Self::Sc2GetGpt0StickyCounterGetGeneralPurposeTagValue, + "sc_glitch_cnt" => Self::ScGlitchCntStickyCounterCumulativeNumberOfGlitches, + "sc_glitch_rate" => Self::ScGlitchRateStickyCounterRateOfGlitches, + "sc_gpc_rate" => Self::ScGpcRateStickyCounterIncrementRateOfGeneralPurposeCounter, + "sc_gpc0_rate" => Self::ScGpc0RateStickyCounterIncrementRateOfGeneralPurposeCounter, + "sc_gpc1_rate" => Self::ScGpc1RateStickyCounterIncrementRateOfGeneralPurposeCounter, + "sc0_gpc0_rate" => Self::Sc0Gpc0RateStickyCounterIncrementRateOfGeneralPurposeCounter, + "sc0_gpc1_rate" => Self::Sc0Gpc1RateStickyCounterIncrementRateOfGeneralPurposeCounter, + "sc1_gpc0_rate" => Self::Sc1Gpc0RateStickyCounterIncrementRateOfGeneralPurposeCounter, + "sc1_gpc1_rate" => Self::Sc1Gpc1RateStickyCounterIncrementRateOfGeneralPurposeCounter, + "sc2_gpc0_rate" => Self::Sc2Gpc0RateStickyCounterIncrementRateOfGeneralPurposeCounter, + "sc2_gpc1_rate" => Self::Sc2Gpc1RateStickyCounterIncrementRateOfGeneralPurposeCounter, + "sc_http_err_cnt" => Self::ScHttpErrCntStickyCounterCumulativeNumberOfHttpErrors, + "sc_http_err_rate" => Self::ScHttpErrRateStickyCounterRateOfHttpErrors, + "sc_http_fail_cnt" => Self::ScHttpFailCntStickyCounterCumulativeNumberOfHttpFailures, + "sc_http_fail_rate" => Self::ScHttpFailRateStickyCounterRateOfHttpFailures, + "sc_http_req_cnt" => Self::ScHttpReqCntStickyCounterCumulativeNumberOfHttpRequests, + "sc_http_req_rate" => Self::ScHttpReqRateStickyCounterRateOfHttpRequests, + "sc_inc_gpc" => Self::ScIncGpcStickyCounterIncrementGeneralPurposeCounter, + "sc_inc_gpc0" => Self::ScIncGpc0StickyCounterIncrementGeneralPurposeCounter, + "sc_inc_gpc1" => Self::ScIncGpc1StickyCounterIncrementGeneralPurposeCounter, + "sc0_inc_gpc0" => Self::Sc0IncGpc0StickyCounterIncrementGeneralPurposeCounter, + "sc0_inc_gpc1" => Self::Sc0IncGpc1StickyCounterIncrementGeneralPurposeCounter, + "sc1_inc_gpc0" => Self::Sc1IncGpc0StickyCounterIncrementGeneralPurposeCounter, + "sc1_inc_gpc1" => Self::Sc1IncGpc1StickyCounterIncrementGeneralPurposeCounter, + "sc2_inc_gpc0" => Self::Sc2IncGpc0StickyCounterIncrementGeneralPurposeCounter, + "sc2_inc_gpc1" => Self::Sc2IncGpc1StickyCounterIncrementGeneralPurposeCounter, + "sc_sess_cnt" => Self::ScSessCntStickyCounterCumulativeNumberOfSessions, + "sc_sess_rate" => Self::ScSessRateStickyCounterSessionRate, + "src" => Self::SrcSourceIpMatchesSpecifiedIp, + "src_bytes_in_rate" => Self::SrcBytesInRateSourceIpIncomingBytesRate, + "src_bytes_out_rate" => Self::SrcBytesOutRateSourceIpOutgoingBytesRate, + "src_clr_gpc" => Self::SrcClrGpcSourceIpClearGeneralPurposeCounter, + "src_clr_gpc0" => Self::SrcClrGpc0SourceIpClearGeneralPurposeCounter, + "src_clr_gpc1" => Self::SrcClrGpc1SourceIpClearGeneralPurposeCounter, + "src_conn_cnt" => Self::SrcConnCntSourceIpCumulativeNumberOfConnections, + "src_conn_cur" => Self::SrcConnCurSourceIpConcurrentConnections, + "src_conn_rate" => Self::SrcConnRateSourceIpConnectionRate, + "src_get_gpc" => Self::SrcGetGpcSourceIpGetGeneralPurposeCounterValue, + "src_get_gpc0" => Self::SrcGetGpc0SourceIpGetGeneralPurposeCounterValue, + "src_get_gpc1" => Self::SrcGetGpc1SourceIpGetGeneralPurposeCounterValue, + "src_get_gpt" => Self::SrcGetGptSourceIpGetGeneralPurposeTagValue, + "src_glitch_cnt" => Self::SrcGlitchCntSourceIpCumulativeNumberOfGlitches, + "src_glitch_rate" => Self::SrcGlitchRateSourceIpRateOfGlitches, + "src_gpc_rate" => Self::SrcGpcRateSourceIpIncrementRateOfGeneralPurposeCounter, + "src_gpc0_rate" => Self::SrcGpc0RateSourceIpIncrementRateOfGeneralPurposeCounter, + "src_gpc1_rate" => Self::SrcGpc1RateSourceIpIncrementRateOfGeneralPurposeCounter, + "src_http_err_cnt" => Self::SrcHttpErrCntSourceIpCumulativeNumberOfHttpErrors, + "src_http_err_rate" => Self::SrcHttpErrRateSourceIpRateOfHttpErrors, + "src_http_fail_cnt" => Self::SrcHttpFailCntSourceIpCumulativeNumberOfHttpFailures, + "src_http_fail_rate" => Self::SrcHttpFailRateSourceIpRateOfHttpFailures, + "src_http_req_cnt" => Self::SrcHttpReqCntSourceIpNumberOfHttpRequests, + "src_http_req_rate" => Self::SrcHttpReqRateSourceIpRateOfHttpRequests, + "src_inc_gpc" => Self::SrcIncGpcSourceIpIncrementGeneralPurposeCounter, + "src_inc_gpc0" => Self::SrcIncGpc0SourceIpIncrementGeneralPurposeCounter, + "src_inc_gpc1" => Self::SrcIncGpc1SourceIpIncrementGeneralPurposeCounter, + "src_is_local" => Self::SrcIsLocalSourceIpIsLocal, + "src_kbytes_in" => Self::SrcKbytesInSourceIpAmountOfDataReceivedInKilobytes, + "src_kbytes_out" => Self::SrcKbytesOutSourceIpAmountOfDataSentInKilobytes, + "src_port" => Self::SrcPortSourceIpTcpSourcePort, + "src_sess_cnt" => Self::SrcSessCntSourceIpCumulativeNumberOfSessions, + "src_sess_rate" => Self::SrcSessRateSourceIpSessionRate, + "ssl_c_ca_commonname" => Self::SslCCaCommonnameSslClientCertificateIssuedByCaCommonName, + "ssl_c_verify_code" => Self::SslCVerifyCodeSslClientCertificateVerifyErrorResult, + "ssl_c_verify" => Self::SslCVerifySslClientCertificateIsValid, + "ssl_fc_sni" => Self::SslFcSniSniTlsExtensionMatchesLocallyDeciphered, + "ssl_fc" => Self::SslFcTrafficIsSslLocallyDeciphered, + "ssl_hello_type" => Self::SslHelloTypeSslHelloType, + "ssl_sni_beg" => Self::SslSniBegSniTlsExtensionStartsWithTcpRequestContentInspection, + "ssl_sni_end" => Self::SslSniEndSniTlsExtensionEndsWithTcpRequestContentInspection, + "ssl_sni_reg" => Self::SslSniRegSniTlsExtensionRegexTcpRequestContentInspection, + "ssl_sni" => Self::SslSniSniTlsExtensionMatchesTcpRequestContentInspection, + "ssl_sni_sub" => Self::SslSniSubSniTlsExtensionContainsTcpRequestContentInspection, + "stopping" => Self::StoppingHaProxyProcessIsCurrentlyStopping, + "url_param" => Self::UrlParamUrlParameterContains, + "var" => Self::VarCompareTheValueOfAVariable, + "wait_end" => Self::WaitEndInspectionPeriodIsOver, + "custom_acl" => Self::CustomConditionOptionPassThrough, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclExpression { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclVarComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclVarComparison { @@ -5014,6 +5998,25 @@ pub(crate) mod serde_acl_var_comparison { } } +impl From<&str> for AclVarComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclVarComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSslHelloType #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSslHelloType { @@ -5089,6 +6092,23 @@ pub(crate) mod serde_acl_ssl_hello_type { } } +impl From<&str> for AclSslHelloType { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "x0" => Self::V0NoClientHello, + "x1" => Self::V1ClientHello, + "x2" => Self::V2ServerHello, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSslHelloType { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcBytesInRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcBytesInRateComparison { @@ -5174,6 +6194,25 @@ pub(crate) mod serde_acl_src_bytes_in_rate_comparison { } } +impl From<&str> for AclSrcBytesInRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcBytesInRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcBytesOutRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcBytesOutRateComparison { @@ -5259,6 +6298,25 @@ pub(crate) mod serde_acl_src_bytes_out_rate_comparison { } } +impl From<&str> for AclSrcBytesOutRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcBytesOutRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcConnCntComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcConnCntComparison { @@ -5344,6 +6402,25 @@ pub(crate) mod serde_acl_src_conn_cnt_comparison { } } +impl From<&str> for AclSrcConnCntComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcConnCntComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcConnCurComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcConnCurComparison { @@ -5429,6 +6506,25 @@ pub(crate) mod serde_acl_src_conn_cur_comparison { } } +impl From<&str> for AclSrcConnCurComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcConnCurComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcConnRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcConnRateComparison { @@ -5514,6 +6610,25 @@ pub(crate) mod serde_acl_src_conn_rate_comparison { } } +impl From<&str> for AclSrcConnRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcConnRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcHttpErrCntComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcHttpErrCntComparison { @@ -5599,6 +6714,25 @@ pub(crate) mod serde_acl_src_http_err_cnt_comparison { } } +impl From<&str> for AclSrcHttpErrCntComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcHttpErrCntComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcHttpErrRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcHttpErrRateComparison { @@ -5684,6 +6818,25 @@ pub(crate) mod serde_acl_src_http_err_rate_comparison { } } +impl From<&str> for AclSrcHttpErrRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcHttpErrRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcHttpReqCntComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcHttpReqCntComparison { @@ -5769,6 +6922,25 @@ pub(crate) mod serde_acl_src_http_req_cnt_comparison { } } +impl From<&str> for AclSrcHttpReqCntComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcHttpReqCntComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcHttpReqRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcHttpReqRateComparison { @@ -5854,6 +7026,25 @@ pub(crate) mod serde_acl_src_http_req_rate_comparison { } } +impl From<&str> for AclSrcHttpReqRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcHttpReqRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcKbytesInComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcKbytesInComparison { @@ -5939,6 +7130,25 @@ pub(crate) mod serde_acl_src_kbytes_in_comparison { } } +impl From<&str> for AclSrcKbytesInComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcKbytesInComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcKbytesOutComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcKbytesOutComparison { @@ -6024,6 +7234,25 @@ pub(crate) mod serde_acl_src_kbytes_out_comparison { } } +impl From<&str> for AclSrcKbytesOutComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcKbytesOutComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcPortComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcPortComparison { @@ -6109,6 +7338,25 @@ pub(crate) mod serde_acl_src_port_comparison { } } +impl From<&str> for AclSrcPortComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcPortComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcSessCntComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcSessCntComparison { @@ -6194,6 +7442,25 @@ pub(crate) mod serde_acl_src_sess_cnt_comparison { } } +impl From<&str> for AclSrcSessCntComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcSessCntComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcSessRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcSessRateComparison { @@ -6279,6 +7546,25 @@ pub(crate) mod serde_acl_src_sess_rate_comparison { } } +impl From<&str> for AclSrcSessRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcSessRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclHttpMethod #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclHttpMethod { @@ -6384,6 +7670,29 @@ pub(crate) mod serde_acl_http_method { } } +impl From<&str> for AclHttpMethod { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "CONNECT" => Self::Connect, + "DELETE" => Self::Delete, + "GET" => Self::Get, + "HEAD" => Self::Head, + "OPTIONS" => Self::Options, + "PATCH" => Self::Patch, + "POST" => Self::Post, + "PUT" => Self::Put, + "TRACE" => Self::Trace, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclHttpMethod { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScBytesInRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScBytesInRateComparison { @@ -6469,6 +7778,25 @@ pub(crate) mod serde_acl_sc_bytes_in_rate_comparison { } } +impl From<&str> for AclScBytesInRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScBytesInRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScBytesOutRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScBytesOutRateComparison { @@ -6554,6 +7882,25 @@ pub(crate) mod serde_acl_sc_bytes_out_rate_comparison { } } +impl From<&str> for AclScBytesOutRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScBytesOutRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScClrGpcComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScClrGpcComparison { @@ -6639,6 +7986,25 @@ pub(crate) mod serde_acl_sc_clr_gpc_comparison { } } +impl From<&str> for AclScClrGpcComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScClrGpcComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScConnCntComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScConnCntComparison { @@ -6724,6 +8090,25 @@ pub(crate) mod serde_acl_sc_conn_cnt_comparison { } } +impl From<&str> for AclScConnCntComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScConnCntComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScConnCurComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScConnCurComparison { @@ -6809,6 +8194,25 @@ pub(crate) mod serde_acl_sc_conn_cur_comparison { } } +impl From<&str> for AclScConnCurComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScConnCurComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScConnRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScConnRateComparison { @@ -6894,6 +8298,25 @@ pub(crate) mod serde_acl_sc_conn_rate_comparison { } } +impl From<&str> for AclScConnRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScConnRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScGetGpcComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScGetGpcComparison { @@ -6979,6 +8402,25 @@ pub(crate) mod serde_acl_sc_get_gpc_comparison { } } +impl From<&str> for AclScGetGpcComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScGetGpcComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScGlitchCntComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScGlitchCntComparison { @@ -7064,6 +8506,25 @@ pub(crate) mod serde_acl_sc_glitch_cnt_comparison { } } +impl From<&str> for AclScGlitchCntComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScGlitchCntComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScGlitchRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScGlitchRateComparison { @@ -7149,6 +8610,25 @@ pub(crate) mod serde_acl_sc_glitch_rate_comparison { } } +impl From<&str> for AclScGlitchRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScGlitchRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScGpcRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScGpcRateComparison { @@ -7234,6 +8714,25 @@ pub(crate) mod serde_acl_sc_gpc_rate_comparison { } } +impl From<&str> for AclScGpcRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScGpcRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScHttpErrCntComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScHttpErrCntComparison { @@ -7319,6 +8818,25 @@ pub(crate) mod serde_acl_sc_http_err_cnt_comparison { } } +impl From<&str> for AclScHttpErrCntComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScHttpErrCntComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScHttpErrRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScHttpErrRateComparison { @@ -7404,6 +8922,25 @@ pub(crate) mod serde_acl_sc_http_err_rate_comparison { } } +impl From<&str> for AclScHttpErrRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScHttpErrRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScHttpFailCntComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScHttpFailCntComparison { @@ -7489,6 +9026,25 @@ pub(crate) mod serde_acl_sc_http_fail_cnt_comparison { } } +impl From<&str> for AclScHttpFailCntComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScHttpFailCntComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScHttpFailRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScHttpFailRateComparison { @@ -7574,6 +9130,25 @@ pub(crate) mod serde_acl_sc_http_fail_rate_comparison { } } +impl From<&str> for AclScHttpFailRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScHttpFailRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScHttpReqCntComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScHttpReqCntComparison { @@ -7659,6 +9234,25 @@ pub(crate) mod serde_acl_sc_http_req_cnt_comparison { } } +impl From<&str> for AclScHttpReqCntComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScHttpReqCntComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScHttpReqRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScHttpReqRateComparison { @@ -7744,6 +9338,25 @@ pub(crate) mod serde_acl_sc_http_req_rate_comparison { } } +impl From<&str> for AclScHttpReqRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScHttpReqRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScIncGpcComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScIncGpcComparison { @@ -7829,6 +9442,25 @@ pub(crate) mod serde_acl_sc_inc_gpc_comparison { } } +impl From<&str> for AclScIncGpcComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScIncGpcComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScSessCntComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScSessCntComparison { @@ -7914,6 +9546,25 @@ pub(crate) mod serde_acl_sc_sess_cnt_comparison { } } +impl From<&str> for AclScSessCntComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScSessCntComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScSessRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScSessRateComparison { @@ -7999,6 +9650,25 @@ pub(crate) mod serde_acl_sc_sess_rate_comparison { } } +impl From<&str> for AclScSessRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScSessRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcGetGpcComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcGetGpcComparison { @@ -8084,6 +9754,25 @@ pub(crate) mod serde_acl_src_get_gpc_comparison { } } +impl From<&str> for AclSrcGetGpcComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcGetGpcComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcGetGptComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcGetGptComparison { @@ -8169,6 +9858,25 @@ pub(crate) mod serde_acl_src_get_gpt_comparison { } } +impl From<&str> for AclSrcGetGptComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcGetGptComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcGlitchCntComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcGlitchCntComparison { @@ -8254,6 +9962,25 @@ pub(crate) mod serde_acl_src_glitch_cnt_comparison { } } +impl From<&str> for AclSrcGlitchCntComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcGlitchCntComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcGlitchRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcGlitchRateComparison { @@ -8339,6 +10066,25 @@ pub(crate) mod serde_acl_src_glitch_rate_comparison { } } +impl From<&str> for AclSrcGlitchRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcGlitchRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcGpcRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcGpcRateComparison { @@ -8424,6 +10170,25 @@ pub(crate) mod serde_acl_src_gpc_rate_comparison { } } +impl From<&str> for AclSrcGpcRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcGpcRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcHttpFailCntComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcHttpFailCntComparison { @@ -8509,6 +10274,25 @@ pub(crate) mod serde_acl_src_http_fail_cnt_comparison { } } +impl From<&str> for AclSrcHttpFailCntComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcHttpFailCntComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcHttpFailRateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcHttpFailRateComparison { @@ -8594,6 +10378,25 @@ pub(crate) mod serde_acl_src_http_fail_rate_comparison { } } +impl From<&str> for AclSrcHttpFailRateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcHttpFailRateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcIncGpcComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcIncGpcComparison { @@ -8679,6 +10482,25 @@ pub(crate) mod serde_acl_src_inc_gpc_comparison { } } +impl From<&str> for AclSrcIncGpcComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcIncGpcComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScClrGpc0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScClrGpc0Comparison { @@ -8764,6 +10586,25 @@ pub(crate) mod serde_acl_sc_clr_gpc0_comparison { } } +impl From<&str> for AclScClrGpc0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScClrGpc0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScClrGpc1Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScClrGpc1Comparison { @@ -8849,6 +10690,25 @@ pub(crate) mod serde_acl_sc_clr_gpc1_comparison { } } +impl From<&str> for AclScClrGpc1Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScClrGpc1Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc0ClrGpc0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc0ClrGpc0Comparison { @@ -8934,6 +10794,25 @@ pub(crate) mod serde_acl_sc0_clr_gpc0_comparison { } } +impl From<&str> for AclSc0ClrGpc0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc0ClrGpc0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc0ClrGpc1Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc0ClrGpc1Comparison { @@ -9019,6 +10898,25 @@ pub(crate) mod serde_acl_sc0_clr_gpc1_comparison { } } +impl From<&str> for AclSc0ClrGpc1Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc0ClrGpc1Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc1ClrGpcComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc1ClrGpcComparison { @@ -9104,6 +11002,25 @@ pub(crate) mod serde_acl_sc1_clr_gpc_comparison { } } +impl From<&str> for AclSc1ClrGpcComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc1ClrGpcComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc1ClrGpc0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc1ClrGpc0Comparison { @@ -9189,6 +11106,25 @@ pub(crate) mod serde_acl_sc1_clr_gpc0_comparison { } } +impl From<&str> for AclSc1ClrGpc0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc1ClrGpc0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc1ClrGpc1Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc1ClrGpc1Comparison { @@ -9274,6 +11210,25 @@ pub(crate) mod serde_acl_sc1_clr_gpc1_comparison { } } +impl From<&str> for AclSc1ClrGpc1Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc1ClrGpc1Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc2ClrGpcComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc2ClrGpcComparison { @@ -9359,6 +11314,25 @@ pub(crate) mod serde_acl_sc2_clr_gpc_comparison { } } +impl From<&str> for AclSc2ClrGpcComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc2ClrGpcComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc2ClrGpc0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc2ClrGpc0Comparison { @@ -9444,6 +11418,25 @@ pub(crate) mod serde_acl_sc2_clr_gpc0_comparison { } } +impl From<&str> for AclSc2ClrGpc0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc2ClrGpc0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc2ClrGpc1Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc2ClrGpc1Comparison { @@ -9529,6 +11522,25 @@ pub(crate) mod serde_acl_sc2_clr_gpc1_comparison { } } +impl From<&str> for AclSc2ClrGpc1Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc2ClrGpc1Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScGetGpc0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScGetGpc0Comparison { @@ -9614,6 +11626,25 @@ pub(crate) mod serde_acl_sc_get_gpc0_comparison { } } +impl From<&str> for AclScGetGpc0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScGetGpc0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScGetGpc1Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScGetGpc1Comparison { @@ -9699,6 +11730,25 @@ pub(crate) mod serde_acl_sc_get_gpc1_comparison { } } +impl From<&str> for AclScGetGpc1Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScGetGpc1Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc0GetGpc0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc0GetGpc0Comparison { @@ -9784,6 +11834,25 @@ pub(crate) mod serde_acl_sc0_get_gpc0_comparison { } } +impl From<&str> for AclSc0GetGpc0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc0GetGpc0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc0GetGpc1Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc0GetGpc1Comparison { @@ -9869,6 +11938,25 @@ pub(crate) mod serde_acl_sc0_get_gpc1_comparison { } } +impl From<&str> for AclSc0GetGpc1Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc0GetGpc1Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc1GetGpc0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc1GetGpc0Comparison { @@ -9954,6 +12042,25 @@ pub(crate) mod serde_acl_sc1_get_gpc0_comparison { } } +impl From<&str> for AclSc1GetGpc0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc1GetGpc0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc1GetGpc1Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc1GetGpc1Comparison { @@ -10039,6 +12146,25 @@ pub(crate) mod serde_acl_sc1_get_gpc1_comparison { } } +impl From<&str> for AclSc1GetGpc1Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc1GetGpc1Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc2GetGpc0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc2GetGpc0Comparison { @@ -10124,6 +12250,25 @@ pub(crate) mod serde_acl_sc2_get_gpc0_comparison { } } +impl From<&str> for AclSc2GetGpc0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc2GetGpc0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc2GetGpc1Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc2GetGpc1Comparison { @@ -10209,6 +12354,25 @@ pub(crate) mod serde_acl_sc2_get_gpc1_comparison { } } +impl From<&str> for AclSc2GetGpc1Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc2GetGpc1Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScGetGptComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScGetGptComparison { @@ -10294,6 +12458,25 @@ pub(crate) mod serde_acl_sc_get_gpt_comparison { } } +impl From<&str> for AclScGetGptComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScGetGptComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScGetGpt0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScGetGpt0Comparison { @@ -10379,6 +12562,25 @@ pub(crate) mod serde_acl_sc_get_gpt0_comparison { } } +impl From<&str> for AclScGetGpt0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScGetGpt0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc0GetGpt0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc0GetGpt0Comparison { @@ -10464,6 +12666,25 @@ pub(crate) mod serde_acl_sc0_get_gpt0_comparison { } } +impl From<&str> for AclSc0GetGpt0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc0GetGpt0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc1GetGpt0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc1GetGpt0Comparison { @@ -10549,6 +12770,25 @@ pub(crate) mod serde_acl_sc1_get_gpt0_comparison { } } +impl From<&str> for AclSc1GetGpt0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc1GetGpt0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc2GetGpt0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc2GetGpt0Comparison { @@ -10634,6 +12874,25 @@ pub(crate) mod serde_acl_sc2_get_gpt0_comparison { } } +impl From<&str> for AclSc2GetGpt0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc2GetGpt0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScGpc0RateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScGpc0RateComparison { @@ -10719,6 +12978,25 @@ pub(crate) mod serde_acl_sc_gpc0_rate_comparison { } } +impl From<&str> for AclScGpc0RateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScGpc0RateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScGpc1RateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScGpc1RateComparison { @@ -10804,6 +13082,25 @@ pub(crate) mod serde_acl_sc_gpc1_rate_comparison { } } +impl From<&str> for AclScGpc1RateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScGpc1RateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc0Gpc0RateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc0Gpc0RateComparison { @@ -10889,6 +13186,25 @@ pub(crate) mod serde_acl_sc0_gpc0_rate_comparison { } } +impl From<&str> for AclSc0Gpc0RateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc0Gpc0RateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc0Gpc1RateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc0Gpc1RateComparison { @@ -10974,6 +13290,25 @@ pub(crate) mod serde_acl_sc0_gpc1_rate_comparison { } } +impl From<&str> for AclSc0Gpc1RateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc0Gpc1RateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc1Gpc0RateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc1Gpc0RateComparison { @@ -11059,6 +13394,25 @@ pub(crate) mod serde_acl_sc1_gpc0_rate_comparison { } } +impl From<&str> for AclSc1Gpc0RateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc1Gpc0RateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc1Gpc1RateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc1Gpc1RateComparison { @@ -11144,6 +13498,25 @@ pub(crate) mod serde_acl_sc1_gpc1_rate_comparison { } } +impl From<&str> for AclSc1Gpc1RateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc1Gpc1RateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc2Gpc0RateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc2Gpc0RateComparison { @@ -11229,6 +13602,25 @@ pub(crate) mod serde_acl_sc2_gpc0_rate_comparison { } } +impl From<&str> for AclSc2Gpc0RateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc2Gpc0RateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc2Gpc1RateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc2Gpc1RateComparison { @@ -11314,6 +13706,25 @@ pub(crate) mod serde_acl_sc2_gpc1_rate_comparison { } } +impl From<&str> for AclSc2Gpc1RateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc2Gpc1RateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScIncGpc0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScIncGpc0Comparison { @@ -11399,6 +13810,25 @@ pub(crate) mod serde_acl_sc_inc_gpc0_comparison { } } +impl From<&str> for AclScIncGpc0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScIncGpc0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclScIncGpc1Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclScIncGpc1Comparison { @@ -11484,6 +13914,25 @@ pub(crate) mod serde_acl_sc_inc_gpc1_comparison { } } +impl From<&str> for AclScIncGpc1Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclScIncGpc1Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc0IncGpc0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc0IncGpc0Comparison { @@ -11569,6 +14018,25 @@ pub(crate) mod serde_acl_sc0_inc_gpc0_comparison { } } +impl From<&str> for AclSc0IncGpc0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc0IncGpc0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc0IncGpc1Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc0IncGpc1Comparison { @@ -11654,6 +14122,25 @@ pub(crate) mod serde_acl_sc0_inc_gpc1_comparison { } } +impl From<&str> for AclSc0IncGpc1Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc0IncGpc1Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc1IncGpc0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc1IncGpc0Comparison { @@ -11739,6 +14226,25 @@ pub(crate) mod serde_acl_sc1_inc_gpc0_comparison { } } +impl From<&str> for AclSc1IncGpc0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc1IncGpc0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc1IncGpc1Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc1IncGpc1Comparison { @@ -11824,6 +14330,25 @@ pub(crate) mod serde_acl_sc1_inc_gpc1_comparison { } } +impl From<&str> for AclSc1IncGpc1Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc1IncGpc1Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc2IncGpc0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc2IncGpc0Comparison { @@ -11909,6 +14434,25 @@ pub(crate) mod serde_acl_sc2_inc_gpc0_comparison { } } +impl From<&str> for AclSc2IncGpc0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc2IncGpc0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSc2IncGpc1Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSc2IncGpc1Comparison { @@ -11994,6 +14538,25 @@ pub(crate) mod serde_acl_sc2_inc_gpc1_comparison { } } +impl From<&str> for AclSc2IncGpc1Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSc2IncGpc1Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcClrGpc0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcClrGpc0Comparison { @@ -12079,6 +14642,25 @@ pub(crate) mod serde_acl_src_clr_gpc0_comparison { } } +impl From<&str> for AclSrcClrGpc0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcClrGpc0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcClrGpc1Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcClrGpc1Comparison { @@ -12164,6 +14746,25 @@ pub(crate) mod serde_acl_src_clr_gpc1_comparison { } } +impl From<&str> for AclSrcClrGpc1Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcClrGpc1Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcGetGpc0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcGetGpc0Comparison { @@ -12249,6 +14850,25 @@ pub(crate) mod serde_acl_src_get_gpc0_comparison { } } +impl From<&str> for AclSrcGetGpc0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcGetGpc0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcGetGpc1Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcGetGpc1Comparison { @@ -12334,6 +14954,25 @@ pub(crate) mod serde_acl_src_get_gpc1_comparison { } } +impl From<&str> for AclSrcGetGpc1Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcGetGpc1Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcGpc0RateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcGpc0RateComparison { @@ -12419,6 +15058,25 @@ pub(crate) mod serde_acl_src_gpc0_rate_comparison { } } +impl From<&str> for AclSrcGpc0RateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcGpc0RateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcGpc1RateComparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcGpc1RateComparison { @@ -12504,6 +15162,25 @@ pub(crate) mod serde_acl_src_gpc1_rate_comparison { } } +impl From<&str> for AclSrcGpc1RateComparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcGpc1RateComparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcIncGpc0Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcIncGpc0Comparison { @@ -12589,6 +15266,25 @@ pub(crate) mod serde_acl_src_inc_gpc0_comparison { } } +impl From<&str> for AclSrcIncGpc0Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcIncGpc0Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// AclSrcIncGpc1Comparison #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AclSrcIncGpc1Comparison { @@ -12674,6 +15370,25 @@ pub(crate) mod serde_acl_src_inc_gpc1_comparison { } } +impl From<&str> for AclSrcIncGpc1Comparison { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gt" => Self::GreaterThan, + "ge" => Self::GreaterEqual, + "eq" => Self::Equal, + "lt" => Self::LessThan, + "le" => Self::LessEqual, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for AclSrcIncGpc1Comparison { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ActionTestType #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ActionTestType { @@ -12744,6 +15459,22 @@ pub(crate) mod serde_action_test_type { } } +impl From<&str> for ActionTestType { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "if" => Self::IfDefault, + "unless" => Self::Unless, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ActionTestType { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ActionOperator #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ActionOperator { @@ -12814,6 +15545,22 @@ pub(crate) mod serde_action_operator { } } +impl From<&str> for ActionOperator { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "and" => Self::AndDefault, + "or" => Self::Or, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ActionOperator { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ActionType #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ActionType { @@ -12960,6 +15707,34 @@ pub(crate) mod serde_action_type { } } +impl From<&str> for ActionType { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "compression" => Self::CompressionForHttpResponsesRequests, + "fcgi_pass_header" => Self::FastCgiPassHeader, + "fcgi_set_param" => Self::FastCgiSetParam, + "http-after-response" => Self::HttpAfterResponse, + "http-request" => Self::HttpRequest, + "http-response" => Self::HttpResponse, + "map_data_use_backend" => Self::MapDataToBackendPoolsUsingAMapFile, + "map_use_backend" => Self::MapDomainsToBackendPoolsUsingAMapFile, + "monitor_fail" => Self::MonitorFailReportFailureToAMonitorRequest, + "tcp-request" => Self::TcpRequest, + "tcp-response" => Self::TcpResponse, + "use_backend" => Self::UseSpecifiedBackendPool, + "use_server" => Self::OverrideServerInBackendPool, + "custom" => Self::CustomRuleOptionPassThrough, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ActionType { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ActionHttpAfterResponseAction #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ActionHttpAfterResponseAction { @@ -13140,6 +15915,42 @@ pub(crate) mod serde_action_http_after_response_action { } } +impl From<&str> for ActionHttpAfterResponseAction { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "add-header" => Self::AddHeader, + "allow" => Self::Allow, + "capture" => Self::Capture, + "del-header" => Self::DelHeader, + "del-map" => Self::DelMap, + "do-log" => Self::DoLog, + "replace-header" => Self::ReplaceHeader, + "replace-value" => Self::ReplaceValue, + "sc-add-gpc" => Self::ScAddGpc, + "sc-inc-gpc" => Self::ScIncGpc, + "sc-inc-gpc0" => Self::ScIncGpc0, + "sc-inc-gpc1" => Self::ScIncGpc1, + "sc-set-gpt" => Self::ScSetGpt, + "sc-set-gpt0" => Self::ScSetGpt0, + "set-header" => Self::SetHeader, + "set-log-level" => Self::SetLogLevel, + "set-map" => Self::SetMap, + "set-status" => Self::SetStatus, + "set-var" => Self::SetVar, + "set-var-fmt" => Self::SetVarFmt, + "strict-mode" => Self::StrictMode, + "unset-var" => Self::UnsetVar, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ActionHttpAfterResponseAction { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ActionHttpRequestAction #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ActionHttpRequestAction { @@ -13521,6 +16332,81 @@ pub(crate) mod serde_action_http_request_action { } } +impl From<&str> for ActionHttpRequestAction { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "add-acl" => Self::AddAcl, + "add-header" => Self::AddHeader, + "allow" => Self::Allow, + "auth" => Self::Auth, + "cache-use" => Self::CacheUse, + "capture" => Self::Capture, + "del-acl" => Self::DelAcl, + "del-header" => Self::DelHeader, + "del-map" => Self::DelMap, + "deny" => Self::Deny, + "disable-l7-retry" => Self::DisableL7Retry, + "do-log" => Self::DoLog, + "do-resolve" => Self::DoResolve, + "early-hint" => Self::EarlyHint, + "lua" => Self::Lua, + "normalize-uri" => Self::NormalizeUri, + "redirect" => Self::Redirect, + "reject" => Self::Reject, + "replace-header" => Self::ReplaceHeader, + "replace-path" => Self::ReplacePath, + "replace-pathq" => Self::ReplacePathq, + "replace-uri" => Self::ReplaceUri, + "replace-value" => Self::ReplaceValue, + "return" => Self::Return, + "sc-add-gpc" => Self::ScAddGpc, + "sc-inc-gpc" => Self::ScIncGpc, + "sc-inc-gpc0" => Self::ScIncGpc0, + "sc-inc-gpc1" => Self::ScIncGpc1, + "sc-set-gpt" => Self::ScSetGpt, + "sc-set-gpt0" => Self::ScSetGpt0, + "send-spoe-group" => Self::SendSpoeGroup, + "set-dst" => Self::SetDst, + "set-dst-port" => Self::SetDstPort, + "set-fc-mark" => Self::SetFcMark, + "set-fc-tos" => Self::SetFcTos, + "set-header" => Self::SetHeader, + "set-log-level" => Self::SetLogLevel, + "set-map" => Self::SetMap, + "set-method" => Self::SetMethod, + "set-nice" => Self::SetNice, + "set-path" => Self::SetPath, + "set-pathq" => Self::SetPathq, + "set-priority-class" => Self::SetPriorityClass, + "set-priority-offset" => Self::SetPriorityOffset, + "set-query" => Self::SetQuery, + "set-src" => Self::SetSrc, + "set-src-port" => Self::SetSrcPort, + "set-timeout" => Self::SetTimeout, + "set-uri" => Self::SetUri, + "set-var" => Self::SetVar, + "set-var-fmt" => Self::SetVarFmt, + "silent-drop" => Self::SilentDrop, + "strict-mode" => Self::StrictMode, + "tarpit" => Self::Tarpit, + "track-sc0" => Self::TrackSc0, + "track-sc1" => Self::TrackSc1, + "track-sc2" => Self::TrackSc2, + "unset-var" => Self::UnsetVar, + "use-service" => Self::UseServiceUseALuaService, + "wait-for-body" => Self::WaitForBody, + "wait-for-handshake" => Self::WaitForHandshake, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ActionHttpRequestAction { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ActionHttpResponseAction #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ActionHttpResponseAction { @@ -13776,6 +16662,59 @@ pub(crate) mod serde_action_http_response_action { } } +impl From<&str> for ActionHttpResponseAction { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "add-acl" => Self::AddAcl, + "add-header" => Self::AddHeader, + "allow" => Self::Allow, + "cache-store" => Self::CacheStore, + "capture" => Self::Capture, + "del-acl" => Self::DelAcl, + "del-header" => Self::DelHeader, + "del-map" => Self::DelMap, + "deny" => Self::Deny, + "do-log" => Self::DoLog, + "lua" => Self::Lua, + "redirect" => Self::Redirect, + "replace-header" => Self::ReplaceHeader, + "replace-value" => Self::ReplaceValue, + "return" => Self::Return, + "sc-add-gpc" => Self::ScAddGpc, + "sc-inc-gpc" => Self::ScIncGpc, + "sc-inc-gpc0" => Self::ScIncGpc0, + "sc-inc-gpc1" => Self::ScIncGpc1, + "sc-set-gpt" => Self::ScSetGpt, + "sc-set-gpt0" => Self::ScSetGpt0, + "send-spoe-group" => Self::SendSpoeGroup, + "set-fc-mark" => Self::SetFcMark, + "set-fc-tos" => Self::SetFcTos, + "set-header" => Self::SetHeader, + "set-log-level" => Self::SetLogLevel, + "set-map" => Self::SetMap, + "set-nice" => Self::SetNice, + "set-status" => Self::SetStatus, + "set-timeout" => Self::SetTimeout, + "set-var" => Self::SetVar, + "set-var-fmt" => Self::SetVarFmt, + "silent-drop" => Self::SilentDrop, + "strict-mode" => Self::StrictMode, + "track-sc0" => Self::TrackSc0, + "track-sc1" => Self::TrackSc1, + "track-sc2" => Self::TrackSc2, + "unset-var" => Self::UnsetVar, + "wait-for-body" => Self::WaitForBody, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ActionHttpResponseAction { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ActionTcpRequestAction #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ActionTcpRequestAction { @@ -14464,6 +17403,102 @@ pub(crate) mod serde_action_tcp_request_action { } } +impl From<&str> for ActionTcpRequestAction { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "connection_accept" => Self::ConnectionAccept, + "connection_expect-netscaler-cip" => Self::ConnectionExpectNetscalerCip, + "connection_expect-proxy" => Self::ConnectionExpectProxy, + "connection_fc-silent-drop" => Self::ConnectionFcSilentDrop, + "connection_reject" => Self::ConnectionReject, + "connection_sc-add-gpc" => Self::ConnectionScAddGpc, + "connection_sc-inc-gpc" => Self::ConnectionScIncGpc, + "connection_sc-inc-gpc0" => Self::ConnectionScIncGpc0, + "connection_sc-inc-gpc1" => Self::ConnectionScIncGpc1, + "connection_sc-set-gpt" => Self::ConnectionScSetGpt, + "connection_sc-set-gpt0" => Self::ConnectionScSetGpt0, + "connection_send-spoe-group" => Self::ConnectionSendSpoeGroup, + "connection_set-dst" => Self::ConnectionSetDst, + "connection_set-dst-port" => Self::ConnectionSetDstPort, + "connection_set-fc-mark" => Self::ConnectionSetFcMark, + "connection_set-fc-tos" => Self::ConnectionSetFcTos, + "connection_set-log-level" => Self::ConnectionSetLogLevel, + "connection_set-src" => Self::ConnectionSetSrc, + "connection_set-src-port" => Self::ConnectionSetSrcPort, + "connection_set-var" => Self::ConnectionSetVar, + "connection_set-var-fmt" => Self::ConnectionSetVarFmt, + "connection_silent-drop" => Self::ConnectionSilentDrop, + "connection_track-sc0" => Self::ConnectionTrackSc0, + "connection_track-sc1" => Self::ConnectionTrackSc1, + "connection_track-sc2" => Self::ConnectionTrackSc2, + "connection_unset-var" => Self::ConnectionUnsetVar, + "content_accept" => Self::ContentAccept, + "content_capture" => Self::ContentCapture, + "content_do-resolve" => Self::ContentDoResolve, + "content_lua" => Self::ContentLua, + "content_reject" => Self::ContentReject, + "content_sc-add-gpc" => Self::ContentScAddGpc, + "content_sc-inc-gpc" => Self::ContentScIncGpc, + "content_sc-inc-gpc0" => Self::ContentScIncGpc0, + "content_sc-inc-gpc1" => Self::ContentScIncGpc1, + "content_sc-set-gpt" => Self::ContentScSetGpt, + "content_sc-set-gpt0" => Self::ContentScSetGpt0, + "content_send-spoe-group" => Self::ContentSendSpoeGroup, + "content_set-dst" => Self::ContentSetDst, + "content_set-dst-port" => Self::ContentSetDstPort, + "content_set-fc-mark" => Self::ContentSetFcMark, + "content_set-fc-tos" => Self::ContentSetFcTos, + "content_set-log-level" => Self::ContentSetLogLevel, + "content_set-nice" => Self::ContentSetNice, + "content_set-priority-class" => Self::ContentSetPriorityClass, + "content_set-priority-offset" => Self::ContentSetPriorityOffset, + "content_set-src" => Self::ContentSetSrc, + "content_set-src-port" => Self::ContentSetSrcPort, + "content_set-var" => Self::ContentSetVar, + "content_set-var-fmt" => Self::ContentSetVarFmt, + "content_silent-drop" => Self::ContentSilentDrop, + "content_switch-mode" => Self::ContentSwitchMode, + "content_track-sc0" => Self::ContentTrackSc0, + "content_track-sc1" => Self::ContentTrackSc1, + "content_track-sc2" => Self::ContentTrackSc2, + "content_unset-var" => Self::ContentUnsetVar, + "content_use-service" => Self::ContentUseServiceUseALuaService, + "inspect-delay" => Self::InspectDelay, + "session_accept" => Self::SessionAccept, + "session_attach-srv" => Self::SessionAttachSrv, + "session_reject" => Self::SessionReject, + "session_sc-add-gpc" => Self::SessionScAddGpc, + "session_sc-inc-gpc" => Self::SessionScIncGpc, + "session_sc-inc-gpc0" => Self::SessionScIncGpc0, + "session_sc-inc-gpc1" => Self::SessionScIncGpc1, + "session_sc-set-gpt" => Self::SessionScSetGpt, + "session_sc-set-gpt0" => Self::SessionScSetGpt0, + "session_send-spoe-group" => Self::SessionSendSpoeGroup, + "session_set-dst" => Self::SessionSetDst, + "session_set-dst-port" => Self::SessionSetDstPort, + "session_set-fc-mark" => Self::SessionSetFcMark, + "session_set-fc-tos" => Self::SessionSetFcTos, + "session_set-log-level" => Self::SessionSetLogLevel, + "session_set-src" => Self::SessionSetSrc, + "session_set-src-port" => Self::SessionSetSrcPort, + "session_set-var" => Self::SessionSetVar, + "session_set-var-fmt" => Self::SessionSetVarFmt, + "session_silent-drop" => Self::SessionSilentDrop, + "session_track-sc0" => Self::SessionTrackSc0, + "session_track-sc1" => Self::SessionTrackSc1, + "session_track-sc2" => Self::SessionTrackSc2, + "session_unset-var" => Self::SessionUnsetVar, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ActionTcpRequestAction { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ActionTcpResponseAction #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ActionTcpResponseAction { @@ -14674,6 +17709,40 @@ pub(crate) mod serde_action_tcp_response_action { } } +impl From<&str> for ActionTcpResponseAction { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "content_accept" => Self::ContentAccept, + "content_close" => Self::ContentClose, + "content_lua" => Self::ContentLua, + "content_reject" => Self::ContentReject, + "content_sc-add-gpc" => Self::ContentScAddGpc, + "content_sc-inc-gpc" => Self::ContentScIncGpc, + "content_sc-inc-gpc0" => Self::ContentScIncGpc0, + "content_sc-inc-gpc1" => Self::ContentScIncGpc1, + "content_sc-set-gpt" => Self::ContentScSetGpt, + "content_sc-set-gpt0" => Self::ContentScSetGpt0, + "content_send-spoe-group" => Self::ContentSendSpoeGroup, + "content_set-fc-mark" => Self::ContentSetFcMark, + "content_set-fc-tos" => Self::ContentSetFcTos, + "content_set-log-level" => Self::ContentSetLogLevel, + "content_set-nice" => Self::ContentSetNice, + "content_set-var" => Self::ContentSetVar, + "content_set-var-fmt" => Self::ContentSetVarFmt, + "content_silent-drop" => Self::ContentSilentDrop, + "content_unset-var" => Self::ContentUnsetVar, + "inspect-delay" => Self::InspectDelay, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ActionTcpResponseAction { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ActionHttpRequestSetVarScope #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ActionHttpRequestSetVarScope { @@ -14775,6 +17844,25 @@ pub(crate) mod serde_action_http_request_set_var_scope { } } +impl From<&str> for ActionHttpRequestSetVarScope { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "proc" => Self::VariableIsSharedWithTheWholeProcess, + "sess" => Self::VariableIsSharedWithTheWholeSession, + "txn" => Self::VariableIsSharedWithTheTransactionRequestResponse, + "req" => Self::VariableIsSharedOnlyDuringRequestProcessing, + "res" => Self::VariableIsSharedOnlyDuringResponseProcessing, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ActionHttpRequestSetVarScope { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ActionHttpResponseSetVarScope #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ActionHttpResponseSetVarScope { @@ -14861,6 +17949,25 @@ pub(crate) mod serde_action_http_response_set_var_scope { } } +impl From<&str> for ActionHttpResponseSetVarScope { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "proc" => Self::VariableIsSharedWithTheWholeProcess, + "sess" => Self::VariableIsSharedWithTheWholeSession, + "txn" => Self::VariableIsSharedWithTheTransactionRequestResponse, + "req" => Self::VariableIsSharedOnlyDuringRequestProcessing, + "res" => Self::VariableIsSharedOnlyDuringResponseProcessing, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ActionHttpResponseSetVarScope { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ActionCompressionAlgoRes #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ActionCompressionAlgoRes { @@ -14936,6 +18043,23 @@ pub(crate) mod serde_action_compression_algo_res { } } +impl From<&str> for ActionCompressionAlgoRes { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gzip" => Self::GzipDefault, + "deflate" => Self::Deflate, + "raw-deflate" => Self::RawDeflate, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ActionCompressionAlgoRes { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ActionCompressionAlgoReq #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ActionCompressionAlgoReq { @@ -15011,6 +18135,23 @@ pub(crate) mod serde_action_compression_algo_req { } } +impl From<&str> for ActionCompressionAlgoReq { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "gzip" => Self::GzipDefault, + "deflate" => Self::Deflate, + "raw-deflate" => Self::RawDeflate, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ActionCompressionAlgoReq { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ActionCompressionDirection #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ActionCompressionDirection { @@ -15090,6 +18231,23 @@ pub(crate) mod serde_action_compression_direction { } } +impl From<&str> for ActionCompressionDirection { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "response" => Self::CompressResponsesDefault, + "request" => Self::CompressRequests, + "both" => Self::CompressBoth, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ActionCompressionDirection { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// LuaFilenameScheme #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum LuaFilenameScheme { @@ -15160,6 +18318,22 @@ pub(crate) mod serde_lua_filename_scheme { } } +impl From<&str> for LuaFilenameScheme { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "id" => Self::UseARandomIdForTheFilenameDefault, + "name" => Self::UseTheSpecifiedNameAsFilename, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for LuaFilenameScheme { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// ErrorfileCode #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ErrorfileCode { @@ -15270,6 +18444,30 @@ pub(crate) mod serde_errorfile_code { } } +impl From<&str> for ErrorfileCode { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "x200" => Self::V200, + "x400" => Self::V400, + "x403" => Self::V403, + "x405" => Self::V405, + "x408" => Self::V408, + "x429" => Self::V429, + "x500" => Self::V500, + "x502" => Self::V502, + "x503" => Self::V503, + "x504" => Self::V504, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for ErrorfileCode { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// MapfileType #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum MapfileType { @@ -15370,6 +18568,28 @@ pub(crate) mod serde_mapfile_type { } } +impl From<&str> for MapfileType { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "beg" => Self::BegKeyBeginsWithRequestedValue, + "dom" => Self::DomDomains, + "end" => Self::EndKeyEndsWithRequestedValue, + "int" => Self::IntIntegers, + "ip" => Self::IpIPs, + "reg" => Self::RegRegularExpressions, + "str" => Self::StrStrings, + "sub" => Self::SubSubstringMatchesRequestedValue, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for MapfileType { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// CpuThreadId #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum CpuThreadId { @@ -15760,6 +18980,86 @@ pub(crate) mod serde_cpu_thread_id { } } +impl From<&str> for CpuThreadId { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "all" => Self::AllHaProxyThreads, + "odd" => Self::ThreadsWithOddId, + "even" => Self::ThreadsWithEvenId, + "x1" => Self::Thread1, + "x2" => Self::Thread2, + "x3" => Self::Thread3, + "x4" => Self::Thread4, + "x5" => Self::Thread5, + "x6" => Self::Thread6, + "x7" => Self::Thread7, + "x8" => Self::Thread8, + "x9" => Self::Thread9, + "x10" => Self::Thread10, + "x11" => Self::Thread11, + "x12" => Self::Thread12, + "x13" => Self::Thread13, + "x14" => Self::Thread14, + "x15" => Self::Thread15, + "x16" => Self::Thread16, + "x17" => Self::Thread17, + "x18" => Self::Thread18, + "x19" => Self::Thread19, + "x20" => Self::Thread20, + "x21" => Self::Thread21, + "x22" => Self::Thread22, + "x23" => Self::Thread23, + "x24" => Self::Thread24, + "x25" => Self::Thread25, + "x26" => Self::Thread26, + "x27" => Self::Thread27, + "x28" => Self::Thread28, + "x29" => Self::Thread29, + "x30" => Self::Thread30, + "x31" => Self::Thread31, + "x32" => Self::Thread32, + "x33" => Self::Thread33, + "x34" => Self::Thread34, + "x35" => Self::Thread35, + "x36" => Self::Thread36, + "x37" => Self::Thread37, + "x38" => Self::Thread38, + "x39" => Self::Thread39, + "x40" => Self::Thread40, + "x41" => Self::Thread41, + "x42" => Self::Thread42, + "x43" => Self::Thread43, + "x44" => Self::Thread44, + "x45" => Self::Thread45, + "x46" => Self::Thread46, + "x47" => Self::Thread47, + "x48" => Self::Thread48, + "x49" => Self::Thread49, + "x50" => Self::Thread50, + "x51" => Self::Thread51, + "x52" => Self::Thread52, + "x53" => Self::Thread53, + "x54" => Self::Thread54, + "x55" => Self::Thread55, + "x56" => Self::Thread56, + "x57" => Self::Thread57, + "x58" => Self::Thread58, + "x59" => Self::Thread59, + "x60" => Self::Thread60, + "x61" => Self::Thread61, + "x62" => Self::Thread62, + "x63" => Self::Thread63, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for CpuThreadId { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// CpuCpuId #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum CpuCpuId { @@ -16155,6 +19455,87 @@ pub(crate) mod serde_cpu_cpu_id { } } +impl From<&str> for CpuCpuId { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "all" => Self::AllCpUs, + "odd" => Self::CpUsWithOddId, + "even" => Self::CpUsWithEvenId, + "x0" => Self::Cpu0, + "x1" => Self::Cpu1, + "x2" => Self::Cpu2, + "x3" => Self::Cpu3, + "x4" => Self::Cpu4, + "x5" => Self::Cpu5, + "x6" => Self::Cpu6, + "x7" => Self::Cpu7, + "x8" => Self::Cpu8, + "x9" => Self::Cpu9, + "x10" => Self::Cpu10, + "x11" => Self::Cpu11, + "x12" => Self::Cpu12, + "x13" => Self::Cpu13, + "x14" => Self::Cpu14, + "x15" => Self::Cpu15, + "x16" => Self::Cpu16, + "x17" => Self::Cpu17, + "x18" => Self::Cpu18, + "x19" => Self::Cpu19, + "x20" => Self::Cpu20, + "x21" => Self::Cpu21, + "x22" => Self::Cpu22, + "x23" => Self::Cpu23, + "x24" => Self::Cpu24, + "x25" => Self::Cpu25, + "x26" => Self::Cpu26, + "x27" => Self::Cpu27, + "x28" => Self::Cpu28, + "x29" => Self::Cpu29, + "x30" => Self::Cpu30, + "x31" => Self::Cpu31, + "x32" => Self::Cpu32, + "x33" => Self::Cpu33, + "x34" => Self::Cpu34, + "x35" => Self::Cpu35, + "x36" => Self::Cpu36, + "x37" => Self::Cpu37, + "x38" => Self::Cpu38, + "x39" => Self::Cpu39, + "x40" => Self::Cpu40, + "x41" => Self::Cpu41, + "x42" => Self::Cpu42, + "x43" => Self::Cpu43, + "x44" => Self::Cpu44, + "x45" => Self::Cpu45, + "x46" => Self::Cpu46, + "x47" => Self::Cpu47, + "x48" => Self::Cpu48, + "x49" => Self::Cpu49, + "x50" => Self::Cpu50, + "x51" => Self::Cpu51, + "x52" => Self::Cpu52, + "x53" => Self::Cpu53, + "x54" => Self::Cpu54, + "x55" => Self::Cpu55, + "x56" => Self::Cpu56, + "x57" => Self::Cpu57, + "x58" => Self::Cpu58, + "x59" => Self::Cpu59, + "x60" => Self::Cpu60, + "x61" => Self::Cpu61, + "x62" => Self::Cpu62, + "x63" => Self::Cpu63, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for CpuCpuId { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + /// MailerLoglevel #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum MailerLoglevel { @@ -16255,6 +19636,28 @@ pub(crate) mod serde_mailer_loglevel { } } +impl From<&str> for MailerLoglevel { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "emerg" => Self::Emerg, + "alert" => Self::Alert, + "crit" => Self::Crit, + "err" => Self::Err, + "warning" => Self::Warning, + "notice" => Self::Notice, + "info" => Self::Info, + "debug" => Self::Debug, + _ => Self::Other(s.to_string()), + } + } +} + +impl From for MailerLoglevel { + fn from(s: String) -> Self { + Self::from(s.as_str()) + } +} + // ═══════════════════════════════════════════════════════════════════════════ // Structs // ═══════════════════════════════════════════════════════════════════════════ @@ -19666,8 +23069,8 @@ pub struct OpNsenseHaProxyMaintenance { // ═══════════════════════════════════════════════════════════════════════════ /// Wrapper matching the OPNsense GET response envelope. -/// `GET /api/haproxy/get` returns { "haproxy": { ... } } +/// `GET /api/op_nsenseha_proxy/get` returns { "op_nsenseha_proxy": { ... } } #[derive(Default, Debug, Clone, Serialize, Deserialize)] pub struct OpNsenseHaProxyResponse { - pub haproxy: OpNsenseHaProxy, + pub op_nsenseha_proxy: OpNsenseHaProxy, } diff --git a/opnsense-codegen/src/codegen.rs b/opnsense-codegen/src/codegen.rs index 7b303b6e..e6419313 100644 --- a/opnsense-codegen/src/codegen.rs +++ b/opnsense-codegen/src/codegen.rs @@ -924,6 +924,33 @@ impl CodeGenerator { writeln!(self.output, "}}")?; writeln!(self.output)?; + // Infallible conversions from user-facing strings. Matches wire values + // case-insensitively; unknown inputs are preserved via the `Other` + // variant so round-trip fidelity is kept and the mapping between + // string input and enum variant lives on the type, not the caller. + writeln!(self.output, "impl From<&str> for {} {{", enum_ir.name)?; + writeln!(self.output, " fn from(s: &str) -> Self {{")?; + writeln!(self.output, " match s.to_lowercase().as_str() {{")?; + for variant in &enum_ir.variants { + writeln!( + self.output, + " \"{}\" => Self::{},", + variant.wire_value, variant.rust_name + )?; + } + writeln!(self.output, " _ => Self::Other(s.to_string()),")?; + writeln!(self.output, " }}")?; + writeln!(self.output, " }}")?; + writeln!(self.output, "}}")?; + writeln!(self.output)?; + + writeln!(self.output, "impl From for {} {{", enum_ir.name)?; + writeln!(self.output, " fn from(s: String) -> Self {{")?; + writeln!(self.output, " Self::from(s.as_str())")?; + writeln!(self.output, " }}")?; + writeln!(self.output, "}}")?; + writeln!(self.output)?; + Ok(()) } diff --git a/opnsense-config/src/modules/load_balancer.rs b/opnsense-config/src/modules/load_balancer.rs index 4e0beb5b..e5eda4cb 100644 --- a/opnsense-config/src/modules/load_balancer.rs +++ b/opnsense-config/src/modules/load_balancer.rs @@ -167,40 +167,13 @@ impl LoadBalancerConfig { let hc_uuid = if let Some(hc) = &healthcheck { let hc_struct = OpNsenseHaProxyHealthchecksHealthcheck { name: hc.name.clone(), - r#type: Some(match hc.check_type.to_lowercase().as_str() { - "tcp" => HealthcheckType::Tcp, - "http" => HealthcheckType::HttpDefault, - "agent" => HealthcheckType::Agent, - "mysql" => HealthcheckType::MySql, - "pgsql" | "postgresql" => HealthcheckType::PostgreSql, - "smtp" => HealthcheckType::Smtp, - "ssl" => HealthcheckType::Ssl, - other => HealthcheckType::Other(other.to_string()), - }), + r#type: Some(HealthcheckType::from(hc.check_type.as_str())), interval: hc.interval.clone(), http_uri: hc.http_uri.clone(), - http_method: hc - .http_method - .as_deref() - .map(|m| match m.to_lowercase().as_str() { - "options" => HealthcheckHttpMethod::OptionsDefault, - "head" => HealthcheckHttpMethod::Head, - "get" => HealthcheckHttpMethod::Get, - "put" => HealthcheckHttpMethod::Put, - "post" => HealthcheckHttpMethod::Post, - "delete" => HealthcheckHttpMethod::Delete, - "trace" => HealthcheckHttpMethod::Trace, - other => HealthcheckHttpMethod::Other(other.to_string()), - }), + http_method: hc.http_method.as_deref().map(HealthcheckHttpMethod::from), http_version: None, http_host: Some(String::new()), - ssl: hc.ssl.as_deref().map(|s| match s.to_lowercase().as_str() { - "ssl" => HealthcheckSsl::ForceSslForHealthChecks, - "sslsni" => HealthcheckSsl::ForceSslSniForHealthChecks, - "nossl" => HealthcheckSsl::ForceNoSslForHealthChecks, - "nopref" => HealthcheckSsl::UseServerSettings, - other => HealthcheckSsl::Other(other.to_string()), - }), + ssl: hc.ssl.as_deref().map(HealthcheckSsl::from), checkport: hc.checkport.as_deref().and_then(|p| p.parse().ok()), ..Default::default() }; @@ -233,17 +206,8 @@ impl LoadBalancerConfig { address: Some(s.address.clone()), port: Some(s.port), enabled: s.enabled, - mode: Some(match s.mode.to_lowercase().as_str() { - "active" => ServerMode::ActiveDefault, - "backup" => ServerMode::Backup, - "disabled" => ServerMode::Disabled, - other => ServerMode::Other(other.to_string()), - }), - r#type: Some(match s.server_type.to_lowercase().as_str() { - "static" => ServerType::Static, - "template" => ServerType::Template, - other => ServerType::Other(other.to_string()), - }), + mode: Some(ServerMode::from(s.mode.as_str())), + r#type: Some(ServerType::from(s.server_type.as_str())), ssl: false, sslVerify: false, ..Default::default() @@ -271,20 +235,8 @@ impl LoadBalancerConfig { let be_struct = OpNsenseHaProxyBackendsBackend { name: backend.name.clone(), enabled: backend.enabled, - mode: Some(match backend.mode.to_lowercase().as_str() { - "tcp" => BackendMode::TcpLayer4, - "http" => BackendMode::HttpLayer7Default, - other => BackendMode::Other(other.to_string()), - }), - algorithm: Some(match backend.algorithm.to_lowercase().as_str() { - "roundrobin" => BackendAlgorithm::RoundRobin, - "source" => BackendAlgorithm::SourceIpHashDefault, - "leastconn" => BackendAlgorithm::LeastConnections, - "random" => BackendAlgorithm::RandomAlgorithm, - "static-rr" => BackendAlgorithm::StaticRoundRobin, - "uri" => BackendAlgorithm::UriHashOnlyHttpMode, - other => BackendAlgorithm::Other(other.to_string()), - }), + mode: Some(BackendMode::from(backend.mode.as_str())), + algorithm: Some(BackendAlgorithm::from(backend.algorithm.as_str())), persistence_cookiemode: Some(BackendPersistenceCookiemode::PiggybackOnExistingCookie), healthCheckEnabled: backend.health_check_enabled, healthCheck: hc_uuid.clone(), @@ -366,12 +318,7 @@ impl LoadBalancerConfig { name: frontend.name.clone(), bind: Some(vec![frontend.bind.clone()]), enabled: frontend.enabled, - mode: Some(match frontend.mode.to_lowercase().as_str() { - "tcp" => FrontendMode::Tcp, - "http" => FrontendMode::HttpHttpsSslOffloadingDefault, - "ssl" => FrontendMode::SslHttpsTcpMode, - other => FrontendMode::Other(other.to_string()), - }), + mode: Some(FrontendMode::from(frontend.mode.as_str())), connectionBehaviour: Some(FrontendConnectionBehaviour::HttpKeepAliveDefault), defaultBackend: Some(backend_uuid), stickiness_expire: frontend -- 2.39.5 From ead76e710fa42bb2d9a437aec826277f7f4260a5 Mon Sep 17 00:00:00 2001 From: Sylvain Tremblay Date: Wed, 22 Apr 2026 12:52:26 -0400 Subject: [PATCH 7/7] fix(opnsense): lowercase match arms in generated From<&str> Two regressions from fc16e9f that ./build/check.sh catches: 1. `opnsense-api`'s `test_haproxy_deser` example references `resp.haproxy` on the response wrapper. The regen auto-derived the field name as `op_nsenseha_proxy` from the struct name. Need to pass `--api-key haproxy` to keep the wrapper key stable. 2. For enums whose wire values aren't all-lowercase (e.g. `"SSLv3"`, `"CONNECT"`), the emitted `From<&str>` matched `s.to_lowercase()` against the original-case wire value, which clippy flags as unreachable ("match arm has differing case"). Lowercase the wire value in the emitted match arm so case-insensitive matching actually works; serialization still emits the original-case wire value because the serde module is unaffected. Regenerated `haproxy.rs` via `cargo run -p opnsense-codegen -- generate --xml ... --module-name haproxy --api-key haproxy`. `./build/check.sh` now passes. Co-Authored-By: Claude Opus 4.7 (1M context) --- opnsense-api/src/generated/haproxy.rs | 62 +++++++++++++-------------- opnsense-codegen/src/codegen.rs | 3 +- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/opnsense-api/src/generated/haproxy.rs b/opnsense-api/src/generated/haproxy.rs index 4d18be42..7316e197 100644 --- a/opnsense-api/src/generated/haproxy.rs +++ b/opnsense-api/src/generated/haproxy.rs @@ -715,11 +715,11 @@ pub(crate) mod serde_ssl_min_version { impl From<&str> for SslMinVersion { fn from(s: &str) -> Self { match s.to_lowercase().as_str() { - "SSLv3" => Self::SsLv3, - "TLSv1.0" => Self::TlSv10, - "TLSv1.1" => Self::TlSv11, - "TLSv1.2" => Self::TlSv12, - "TLSv1.3" => Self::TlSv13, + "sslv3" => Self::SsLv3, + "tlsv1.0" => Self::TlSv10, + "tlsv1.1" => Self::TlSv11, + "tlsv1.2" => Self::TlSv12, + "tlsv1.3" => Self::TlSv13, _ => Self::Other(s.to_string()), } } @@ -819,11 +819,11 @@ pub(crate) mod serde_ssl_max_version { impl From<&str> for SslMaxVersion { fn from(s: &str) -> Self { match s.to_lowercase().as_str() { - "SSLv3" => Self::SsLv3, - "TLSv1.0" => Self::TlSv10, - "TLSv1.1" => Self::TlSv11, - "TLSv1.2" => Self::TlSv12, - "TLSv1.3" => Self::TlSv13, + "sslv3" => Self::SsLv3, + "tlsv1.0" => Self::TlSv10, + "tlsv1.1" => Self::TlSv11, + "tlsv1.2" => Self::TlSv12, + "tlsv1.3" => Self::TlSv13, _ => Self::Other(s.to_string()), } } @@ -1719,11 +1719,11 @@ pub(crate) mod serde_frontend_ssl_min_version { impl From<&str> for FrontendSslMinVersion { fn from(s: &str) -> Self { match s.to_lowercase().as_str() { - "SSLv3" => Self::SsLv3, - "TLSv1.0" => Self::TlSv10, - "TLSv1.1" => Self::TlSv11, - "TLSv1.2" => Self::TlSv12, - "TLSv1.3" => Self::TlSv13, + "sslv3" => Self::SsLv3, + "tlsv1.0" => Self::TlSv10, + "tlsv1.1" => Self::TlSv11, + "tlsv1.2" => Self::TlSv12, + "tlsv1.3" => Self::TlSv13, _ => Self::Other(s.to_string()), } } @@ -1823,11 +1823,11 @@ pub(crate) mod serde_frontend_ssl_max_version { impl From<&str> for FrontendSslMaxVersion { fn from(s: &str) -> Self { match s.to_lowercase().as_str() { - "SSLv3" => Self::SsLv3, - "TLSv1.0" => Self::TlSv10, - "TLSv1.1" => Self::TlSv11, - "TLSv1.2" => Self::TlSv12, - "TLSv1.3" => Self::TlSv13, + "sslv3" => Self::SsLv3, + "tlsv1.0" => Self::TlSv10, + "tlsv1.1" => Self::TlSv11, + "tlsv1.2" => Self::TlSv12, + "tlsv1.3" => Self::TlSv13, _ => Self::Other(s.to_string()), } } @@ -7673,15 +7673,15 @@ pub(crate) mod serde_acl_http_method { impl From<&str> for AclHttpMethod { fn from(s: &str) -> Self { match s.to_lowercase().as_str() { - "CONNECT" => Self::Connect, - "DELETE" => Self::Delete, - "GET" => Self::Get, - "HEAD" => Self::Head, - "OPTIONS" => Self::Options, - "PATCH" => Self::Patch, - "POST" => Self::Post, - "PUT" => Self::Put, - "TRACE" => Self::Trace, + "connect" => Self::Connect, + "delete" => Self::Delete, + "get" => Self::Get, + "head" => Self::Head, + "options" => Self::Options, + "patch" => Self::Patch, + "post" => Self::Post, + "put" => Self::Put, + "trace" => Self::Trace, _ => Self::Other(s.to_string()), } } @@ -23069,8 +23069,8 @@ pub struct OpNsenseHaProxyMaintenance { // ═══════════════════════════════════════════════════════════════════════════ /// Wrapper matching the OPNsense GET response envelope. -/// `GET /api/op_nsenseha_proxy/get` returns { "op_nsenseha_proxy": { ... } } +/// `GET /api/haproxy/get` returns { "haproxy": { ... } } #[derive(Default, Debug, Clone, Serialize, Deserialize)] pub struct OpNsenseHaProxyResponse { - pub op_nsenseha_proxy: OpNsenseHaProxy, + pub haproxy: OpNsenseHaProxy, } diff --git a/opnsense-codegen/src/codegen.rs b/opnsense-codegen/src/codegen.rs index e6419313..eaa9b07a 100644 --- a/opnsense-codegen/src/codegen.rs +++ b/opnsense-codegen/src/codegen.rs @@ -935,7 +935,8 @@ impl CodeGenerator { writeln!( self.output, " \"{}\" => Self::{},", - variant.wire_value, variant.rust_name + variant.wire_value.to_lowercase(), + variant.rust_name )?; } writeln!(self.output, " _ => Self::Other(s.to_string()),")?; -- 2.39.5