1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! `Namespaces` resource — namespace-level purge.
//!
//! Mirrors the Python SDK's `client.namespaces.*` surface.
use serde_json::Value;
use crate::error::Result;
use crate::http::HttpClient;
use crate::resources::grains::confirm_error;
/// Namespace operations.
///
/// Access via [`crate::Areev::namespaces`].
pub struct Namespaces<'a> {
http: &'a HttpClient,
memory_id: String,
}
impl<'a> Namespaces<'a> {
/// Internal constructor — use [`crate::Areev::namespaces`].
pub(crate) fn new(http: &'a HttpClient, memory_id: String) -> Self {
Self { http, memory_id }
}
/// Purge every grain in `namespace`
/// (`DELETE FROM grains WHERE ns_hash`).
///
/// **IRREVERSIBLE.** There is no undo — all grains in the namespace
/// are dropped. Emits an audit event. Requires: admin scope.
///
/// Under a HIPAA-bound memory a forced namespace purge is
/// hard-blocked by the policy engine (403, surfaced as
/// [`crate::AreevError::HipaaPolicyViolation`] / [`crate::AreevError::Authorization`]);
/// the SDK never gates this client-side — it issues the request and
/// surfaces the server's verdict.
///
/// **Not auto-retried.**
///
/// # Errors
///
/// Returns [`crate::AreevError::Validation`] (`SDK-E002`) when
/// `confirm` is not `true`.
pub async fn purge(&self, namespace: &str, confirm: bool) -> Result<Value> {
if !confirm {
return Err(confirm_error("namespaces.purge"));
}
let path = format!("/memories/{}/namespaces/{}", self.memory_id, namespace);
self.http._delete_no_retry(&path).await
}
}