| 181 | // break-glass); it returns the row as it was BEFORE the update alongside |
| 182 | // the stored result so the handler can audit old → new per field. A |
| 183 | // schema_name change that collides with another team in the org returns |
| 184 | // configstore.ErrOrgTeamSchemaConflict. Per-org list and delete are |
| 185 | // served by the provisioning API's routes on the same router group |
| 186 | // (identical rules — configstore.DeleteOrgTeamTx). |
| 187 | ListAllOrgTeams() ([]configstore.OrgTeam, error) |
| 188 | CreateOrgTeam(orgID string, team *configstore.OrgTeam) error |
| 189 | UpdateOrgTeam(orgID string, teamID int64, upd orgTeamUpdate) (prev, stored *configstore.OrgTeam, err error) |
| 190 | |
| 191 | ListUsers() ([]configstore.OrgUser, error) |
| 192 | CreateUser(user *configstore.OrgUser) error |
| 193 | GetUser(orgID, username string) (*configstore.OrgUser, error) |
| 194 | UpdateUser(orgID, username, passwordHash string, passthrough *bool, maxVCPUs *int) (*configstore.OrgUser, bool, error) |
| 195 | DeleteUser(orgID, username string) (bool, error) |
| 196 | // UpsertProjectLogin creates or rotates one team-scoped login. accessMode |
| 197 | // selects the capability (configstore.OrgUserAccessModeProjectReader or |
| 198 | // …ProjectUser); the row is otherwise identical, and a per-mode partial |
| 199 | // unique index keeps at most one of each per team. Returns |
| 200 | // configstore.ErrProjectTeamUnavailable when the team is missing/disabled. |
| 201 | UpsertProjectLogin(orgID string, teamID int64, username, password, accessMode string) (*configstore.OrgUser, error) |
| 202 | |
| 203 | // ListServiceGrants returns every service-grant row for the org (all |
| 204 | // statuses); gorm.ErrRecordNotFound for a ghost org. RevokeServiceGrant |
| 205 | // terminally revokes one grant (sets revoked_at, blanks the hash); |
| 206 | // gorm.ErrRecordNotFound for a ghost org, |
| 207 | // configstore.ErrServiceCredentialNotFound for an unknown credential_id, |
| 208 | // idempotent on an already-revoked grant. |
| 209 | ListServiceGrants(orgID string) ([]configstore.ServiceGrant, error) |
| 210 | RevokeServiceGrant(orgID, credentialID string) error |
| 211 | |
| 212 | GetManagedWarehouse(orgID string) (*configstore.ManagedWarehouse, error) |
| 213 | UpsertManagedWarehouse(orgID string, warehouse *configstore.ManagedWarehouse) (*configstore.ManagedWarehouse, bool, error) |
| 214 | // MutateManagedWarehouse loads the existing warehouse (or a zero value if |
| 215 | // none), calls mutate to apply changes, and persists the result — all |
| 216 | // inside a single transaction with a row-level lock on the warehouse row. |
| 217 | // Closes the read-modify-write race that plain Get+Upsert is exposed to |
| 218 | // when concurrent PUTs target the same org. Returns (nil, false, nil) if |
| 219 | // the org doesn't exist. |
| 220 | MutateManagedWarehouse(orgID string, mutate func(*configstore.ManagedWarehouse) error) (*configstore.ManagedWarehouse, bool, error) |
| 221 | |
| 222 | // ReloadSnapshot forces this replica's in-memory config snapshot to reload |
| 223 | // from the config-store DB immediately, bypassing the poll interval. Used |
| 224 | // by createUser/updateUser/deleteUser so a write is authable on this |
| 225 | // replica the instant the request returns — see notifyPeersOfChange. |
| 226 | ReloadSnapshot() error |
| 227 | } |
| 228 | |
| 229 | type gormAPIStore struct { |