CreateGroup handles the creation of a new group.
(c *gin.Context)
| 67 | |
| 68 | // CreateGroup handles the creation of a new group. |
| 69 | func (s *Server) CreateGroup(c *gin.Context) { |
| 70 | var req GroupCreateRequest |
| 71 | if err := c.ShouldBindJSON(&req); err != nil { |
| 72 | response.Error(c, app_errors.NewAPIError(app_errors.ErrInvalidJSON, err.Error())) |
| 73 | return |
| 74 | } |
| 75 | |
| 76 | params := services.GroupCreateParams{ |
| 77 | Name: req.Name, |
| 78 | DisplayName: req.DisplayName, |
| 79 | Description: req.Description, |
| 80 | GroupType: req.GroupType, |
| 81 | Upstreams: req.Upstreams, |
| 82 | ChannelType: req.ChannelType, |
| 83 | Sort: req.Sort, |
| 84 | TestModel: req.TestModel, |
| 85 | ValidationEndpoint: req.ValidationEndpoint, |
| 86 | ParamOverrides: req.ParamOverrides, |
| 87 | ModelRedirectRules: req.ModelRedirectRules, |
| 88 | ModelRedirectStrict: req.ModelRedirectStrict, |
| 89 | Config: req.Config, |
| 90 | HeaderRules: req.HeaderRules, |
| 91 | ProxyKeys: req.ProxyKeys, |
| 92 | } |
| 93 | |
| 94 | group, err := s.GroupService.CreateGroup(c.Request.Context(), params) |
| 95 | if s.handleGroupError(c, err) { |
| 96 | return |
| 97 | } |
| 98 | |
| 99 | response.Success(c, s.newGroupResponse(group)) |
| 100 | } |
| 101 | |
| 102 | // ListGroups handles listing all groups. |
| 103 | func (s *Server) ListGroups(c *gin.Context) { |
nothing calls this directly
no test coverage detected