UpdateOrganization godoc @Security ApiKey @Summary Update organization @Description update organization @Tags Organization @Accept json @Produce json @Param namespace path string true "namespace" @Param current_user query string false "the op user" @Param
(ctx *gin.Context)
| 172 | // @Failure 500 {object} types.APIInternalServerError "Internal server error" |
| 173 | // @Router /organization/{namespace} [put] |
| 174 | func (h *OrganizationHandler) Update(ctx *gin.Context) { |
| 175 | currentUser := httpbase.GetCurrentUser(ctx) |
| 176 | if currentUser == "" { |
| 177 | httpbase.UnauthorizedError(ctx, errors.New("user not found, please login first")) |
| 178 | return |
| 179 | } |
| 180 | var req types.EditOrgReq |
| 181 | if err := ctx.ShouldBindJSON(&req); err != nil { |
| 182 | slog.Error("Bad request format", "error", err) |
| 183 | httpbase.BadRequest(ctx, err.Error()) |
| 184 | return |
| 185 | } |
| 186 | var err error |
| 187 | _, err = h.sc.CheckRequest(ctx, &req) |
| 188 | if err != nil { |
| 189 | slog.Error("failed to check sensitive request", slog.Any("error", err)) |
| 190 | httpbase.BadRequest(ctx, fmt.Errorf("sensitive check failed: %w", err).Error()) |
| 191 | return |
| 192 | } |
| 193 | req.CurrentUser = currentUser |
| 194 | req.Name = ctx.Param("namespace") |
| 195 | org, err := h.c.Update(ctx, &req) |
| 196 | if err != nil { |
| 197 | slog.Error("Failed to update organizations", slog.Any("error", err)) |
| 198 | httpbase.ServerError(ctx, err) |
| 199 | return |
| 200 | } |
| 201 | |
| 202 | slog.Info("Update organizations succeed", slog.String("org_name", org.Nickname)) |
| 203 | httpbase.OK(ctx, org) |
| 204 | } |
| 205 | |
| 206 | // GetOrganizationModels godoc |
| 207 | // @Security ApiKey |
nothing calls this directly
no test coverage detected