Create a new organization.
(&self, org_id: &str, name: &str, tenant_id: u64)
| 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> { |