/*
* Hanzo Cloud API
*
* The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
*
* The version of the OpenAPI document: v1
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Policy {
/// CachePaths overrides CacheTTLSec per path PREFIX (key \"/v1/models\" → seconds). The longest matching prefix wins.
#[serde(rename = "cache_paths", skip_serializing_if = "Option::is_none")]
pub cache_paths: Option<std::collections::HashMap<String, i32>>,
/// CacheTTLSec is the org's default edge-cache TTL for its responses, in seconds; 0 means no caching. Unset inherits the platform default.
#[serde(rename = "cache_ttl_sec", skip_serializing_if = "Option::is_none")]
pub cache_ttl_sec: Option<i32>,
/// CORSOrigins is the PLATFORM-scope CORS allowlist EdgeCORS admits: an exact origin, a bare host, or a \"*.host\" wildcard. Writable only by a SuperAdmin — CORS is evaluated before identity, so it has no tenant to scope to.
#[serde(rename = "cors_origins", skip_serializing_if = "Option::is_none")]
pub cors_origins: Option<Vec<String>>,
/// Methods is the allowlist of HTTP methods the edge accepts for this org. Empty means all are accepted.
#[serde(rename = "methods", skip_serializing_if = "Option::is_none")]
pub methods: Option<Vec<String>>,
/// Mode is the abuse gate's posture for THIS scope: \"shadow\" scores traffic and records the verdict without acting on it, \"live\" enforces it. Unset means shadow. It is the one per-org field that does NOT inherit. Every other field here layers a platform default under the org's own value, which is right for a default: a tenant that sets no rate ceiling should get the platform's. Mode is not a default, it is an ARMING DECISION — it is what makes a statistical judgement start refusing real traffic — and inheriting it means arming one scope arms every tenant that never asked for it, without a write to their row and without anything in their config changing. So a tenant is live only if that tenant's OWN row says live, and the platform row's mode governs exactly one scope: the anonymous lane, which has no tenant of its own. It is also not self-service. Writing it requires SuperAdmin (see the /v1/gateway config op): the subject of an abuse control does not get to switch the control off.
#[serde(rename = "mode", skip_serializing_if = "Option::is_none")]
pub mode: Option<String>,
/// OrgRPM is the org's OWN authenticated rate ceiling, requests per minute, as ScopeRateLimit enforces it. Unset inherits the platform default, then the static boot default.
#[serde(rename = "org_rpm", skip_serializing_if = "Option::is_none")]
pub org_rpm: Option<i32>,
/// PerIPRPM is the PLATFORM-scope pre-auth flood cap: requests EdgeRateLimit admits per WindowSec from one client IP. SuperAdmin-only, same reason.
#[serde(rename = "per_ip_rpm", skip_serializing_if = "Option::is_none")]
pub per_ip_rpm: Option<i32>,
/// UpdatedAt is the unix second this policy row was last written. Server-stamped; a client-supplied value is ignored.
#[serde(rename = "updated_at", skip_serializing_if = "Option::is_none")]
pub updated_at: Option<i32>,
/// UpdatedBy is the validated user id that wrote this policy row. Server-stamped; a client-supplied value is ignored.
#[serde(rename = "updated_by", skip_serializing_if = "Option::is_none")]
pub updated_by: Option<String>,
/// WindowSec is the window PerIPRPM is counted over, in seconds. SuperAdmin-only.
#[serde(rename = "window_sec", skip_serializing_if = "Option::is_none")]
pub window_sec: Option<i32>,
}
impl Policy {
pub fn new() -> Policy {
Policy {
cache_paths: None,
cache_ttl_sec: None,
cors_origins: None,
methods: None,
mode: None,
org_rpm: None,
per_ip_rpm: None,
updated_at: None,
updated_by: None,
window_sec: None,
}
}
}