--- Status ---
(c *gin.Context)
| 1192 | if orgID == "" { |
| 1193 | c.JSON(http.StatusBadRequest, gin.H{"error": "org_id is required"}) |
| 1194 | return |
| 1195 | } |
| 1196 | if req.TeamID <= 0 { |
| 1197 | c.JSON(http.StatusBadRequest, gin.H{"error": "team_id is required (a positive PostHog team id)"}) |
| 1198 | return |
| 1199 | } |
| 1200 | if err := configstore.ValidateOrgTeamSchemaName(req.SchemaName); err != nil { |
| 1201 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) |
| 1202 | return |
| 1203 | } |
| 1204 | backfill := req.BackfillEnabled == nil || *req.BackfillEnabled |
| 1205 | team := configstore.OrgTeam{ |
| 1206 | OrgID: orgID, |
| 1207 | TeamID: req.TeamID, |
| 1208 | SchemaName: req.SchemaName, |
| 1209 | Enabled: req.Enabled == nil || *req.Enabled, |
| 1210 | BackfillEnabled: &backfill, |
| 1211 | } |
| 1212 | // POST /teams has no :id param, so the audit org column is blank — record |
| 1213 | // the target org here (mirrors POST /users). |
| 1214 | setAuditDetail(c, fmt.Sprintf("created team %d (schema %s) in org %s", req.TeamID, req.SchemaName, orgID)) |
| 1215 | if err := h.store.CreateOrgTeam(orgID, &team); err != nil { |
| 1216 | switch { |
| 1217 | case errors.Is(err, gorm.ErrRecordNotFound): |
| 1218 | c.JSON(http.StatusNotFound, gin.H{"error": "org not found"}) |
| 1219 | case errors.Is(err, errOrgTeamExists), errors.Is(err, configstore.ErrOrgTeamSchemaConflict): |
| 1220 | c.JSON(http.StatusConflict, gin.H{"error": err.Error()}) |
| 1221 | default: |
| 1222 | c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) |
nothing calls this directly
no test coverage detected