MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / put_policy_revision

Method put_policy_revision

crates/openshell-server/src/persistence/postgres.rs:431–472  ·  view source on GitHub ↗
(
        &self,
        id: &str,
        sandbox_id: &str,
        version: i64,
        payload: &[u8],
        hash: &str,
    )

Source from the content-addressed store, hash-verified

429 }
430
431 pub async fn put_policy_revision(
432 &self,
433 id: &str,
434 sandbox_id: &str,
435 version: i64,
436 payload: &[u8],
437 hash: &str,
438 ) -> PersistenceResult<()> {
439 let now_ms = current_time_ms();
440 let record = PolicyRecord {
441 id: id.to_string(),
442 sandbox_id: sandbox_id.to_string(),
443 version,
444 policy_payload: payload.to_vec(),
445 policy_hash: hash.to_string(),
446 status: "pending".to_string(),
447 load_error: None,
448 created_at_ms: now_ms,
449 loaded_at_ms: None,
450 };
451 let wrapped_payload = policy_payload_from_record(&record)?;
452
453 sqlx::query(
454 r"
455INSERT INTO objects (
456 object_type, id, scope, version, status, payload, created_at_ms, updated_at_ms
457)
458VALUES ($1, $2, $3, $4, $5, $6, $7, $7)
459",
460 )
461 .bind(POLICY_OBJECT_TYPE)
462 .bind(id)
463 .bind(sandbox_id)
464 .bind(version)
465 .bind("pending")
466 .bind(wrapped_payload)
467 .bind(now_ms)
468 .execute(&self.pool)
469 .await
470 .map_err(|e| map_db_error(&e))?;
471 Ok(())
472 }
473
474 pub async fn get_latest_policy(
475 &self,

Callers

nothing calls this directly

Calls 3

map_db_errorFunction · 0.85
current_time_msFunction · 0.70

Tested by

no test coverage detected