#[non_exhaustive]pub struct PackagePolicy {
pub id: String,
pub name: String,
pub namespace: String,
pub description: Option<String>,
pub enabled: Option<bool>,
pub revision: u64,
pub package: PackageRef,
pub policy_ids: Vec<String>,
pub inputs: Value,
pub vars: Option<Value>,
pub version: Option<String>,
pub extra: Map<String, Value>,
}Expand description
A package policy as Kibana returns it. Reads use Fleet’s full format; creation and simplified replacement responses use the simplified format.
Debug output omits inputs, variables and other fields, which can hold credentials.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: String§name: String§namespace: String§description: Option<String>§enabled: Option<bool>§revision: u64Configuration revision, distinct from the opaque concurrency version.
package: PackageRef§policy_ids: Vec<String>§inputs: ValueFull-format inputs are an array; simplified inputs are an object keyed by input name.
vars: Option<Value>Package-level variables.
version: Option<String>Opaque concurrency token, sent back by PackagePolicy::edit.
extra: Map<String, Value>Implementations§
Source§impl PackagePolicy
impl PackagePolicy
Sourcepub fn edit(&self) -> PackagePolicyEdit
pub fn edit(&self) -> PackagePolicyEdit
A replacement for this policy in the full format. It keeps the current
inputs, variables and assignments until changed, and is bound to the
policy’s ID and concurrency token.
If the response has simplified inputs, fetch the full policy with
Fleet::get_package_policy before editing it. Sending an edit requires
full inputs and a nonempty concurrency token; construction does not check
them. Response-only compiled_input fields are removed from the inputs.
use security_client_rs::fleet::PackagePolicy;
use serde_json::{from_value, json, to_value};
let policy: PackagePolicy = from_value(json!({
"id": "integration-a", "name": "system-1", "namespace": "default",
"revision": 2, "version": "opaque-token", "policy_ids": ["policy-a"],
"package": {"name": "system", "version": "2.24.0"},
"inputs": [{"type": "logfile", "enabled": true, "streams": [],
"compiled_input": {"type": "logfile"}}]
}))?;
let body = to_value(policy.edit().name("SOC system"))?;
assert_eq!(body["version"], "opaque-token");
assert_eq!(body["policy_ids"], json!(["policy-a"]));
assert_eq!(body["inputs"][0]["enabled"], true);
assert!(body["inputs"][0].get("compiled_input").is_none());
assert!(body.get("id").is_none()); // The edit binds the URL's ID instead.