feat: get_policies: Way to obtain policy files and content (#267)

closes #254

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2024-06-19 03:01:55 -04:00
committed by GitHub
parent ee898e112e
commit 46e28b36f8
12 changed files with 194 additions and 5 deletions

View File

@@ -184,10 +184,18 @@ impl Engine {
/// Get the list of packages defined by loaded policies.
///
pub fn get_packages(&mut self) -> Result<Vec<String>> {
pub fn get_packages(&self) -> Result<Vec<String>> {
self.engine.get_packages()
}
/// Get the list of policies.
///
pub fn get_policies(&self) -> Result<String> {
Ok(serde_json::to_string_pretty(
&self.engine.get_policies_as_json()?,
)?)
}
/// Add policy data.
///
/// * `data`: Rego value. A Rego value is a number, bool, string, None