MCPcopy Create free account
hub / github.com/tbphp/gpt-load / UpdateGroup

Method UpdateGroup

internal/handler/group_handler.go:169–218  ·  view source on GitHub ↗

UpdateGroup handles updating an existing group.

(c *gin.Context)

Source from the content-addressed store, hash-verified

167
168// UpdateGroup handles updating an existing group.
169func (s *Server) UpdateGroup(c *gin.Context) {
170 id, err := strconv.Atoi(c.Param("id"))
171 if err != nil {
172 response.ErrorI18nFromAPIError(c, app_errors.ErrBadRequest, "validation.invalid_group_id")
173 return
174 }
175
176 var req GroupUpdateRequest
177 if err := c.ShouldBindJSON(&req); err != nil {
178 response.Error(c, app_errors.NewAPIError(app_errors.ErrInvalidJSON, err.Error()))
179 return
180 }
181
182 params := services.GroupUpdateParams{
183 Name: req.Name,
184 DisplayName: req.DisplayName,
185 Description: req.Description,
186 GroupType: req.GroupType,
187 ChannelType: req.ChannelType,
188 Sort: req.Sort,
189 ValidationEndpoint: req.ValidationEndpoint,
190 ParamOverrides: req.ParamOverrides,
191 ModelRedirectRules: req.ModelRedirectRules,
192 ModelRedirectStrict: req.ModelRedirectStrict,
193 Config: req.Config,
194 ProxyKeys: req.ProxyKeys,
195 }
196
197 if req.Upstreams != nil {
198 params.Upstreams = req.Upstreams
199 params.HasUpstreams = true
200 }
201
202 if req.TestModel != "" {
203 params.TestModel = req.TestModel
204 params.HasTestModel = true
205 }
206
207 if req.HeaderRules != nil {
208 rules := req.HeaderRules
209 params.HeaderRules = &rules
210 }
211
212 group, err := s.GroupService.UpdateGroup(c.Request.Context(), uint(id), params)
213 if s.handleGroupError(c, err) {
214 return
215 }
216
217 response.Success(c, s.newGroupResponse(group))
218}
219
220// ReorderGroups handles batch reorder updates for groups.
221func (s *Server) ReorderGroups(c *gin.Context) {

Callers

nothing calls this directly

Calls 6

handleGroupErrorMethod · 0.95
newGroupResponseMethod · 0.95
ErrorI18nFromAPIErrorFunction · 0.92
ErrorFunction · 0.92
SuccessFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected