MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / create_org

Method create_org

nodedb/src/control/security/org/store.rs:138–160  ·  view source on GitHub ↗

Create a new organization.

(&self, org_id: &str, name: &str, tenant_id: u64)

Source from the content-addressed store, hash-verified

136
137 /// Create a new organization.
138 pub fn create_org(&self, org_id: &str, name: &str, tenant_id: u64) -> crate::Result<()> {
139 let now = now_secs();
140 let record = OrgRecord {
141 org_id: org_id.into(),
142 name: name.into(),
143 tenant_id,
144 status: "active".into(),
145 created_at: now,
146 metadata: HashMap::new(),
147 rate_limit_qps: 0,
148 quota_max_storage: 0,
149 quota_max_members: 0,
150 };
151
152 if let Some(ref catalog) = self.catalog {
153 catalog.put_org(&record.to_stored())?;
154 }
155
156 let mut orgs = self.orgs.write().unwrap_or_else(|p| p.into_inner());
157 orgs.insert(org_id.into(), record);
158 info!(org_id = %org_id, name = %name, "org created");
159 Ok(())
160 }
161
162 /// Get an organization by ID.
163 pub fn get(&self, org_id: &str) -> Option<OrgRecord> {

Callers 5

ensure_orgMethod · 0.80
create_and_get_orgFunction · 0.80
set_org_statusFunction · 0.80
membershipFunction · 0.80
create_orgFunction · 0.80

Calls 5

put_orgMethod · 0.80
now_secsFunction · 0.50
to_storedMethod · 0.45
writeMethod · 0.45
insertMethod · 0.45

Tested by 3

create_and_get_orgFunction · 0.64
set_org_statusFunction · 0.64
membershipFunction · 0.64