连接项目的CRUD API PostConnections 创建新连接 (enhanced with Identity Store validation)
(input *plugin.ApiResourceInput)
| 30 | |
| 31 | // PostConnections 创建新连接 (enhanced with Identity Store validation) |
| 32 | func PostConnections(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { |
| 33 | // 创建连接 |
| 34 | connection := &models.QDevConnection{} |
| 35 | err := api.Decode(input.Body, connection, vld) |
| 36 | if err != nil { |
| 37 | return nil, err |
| 38 | } |
| 39 | |
| 40 | // 验证连接参数 (enhanced validation) |
| 41 | if err := validateConnection(connection); err != nil { |
| 42 | return nil, errors.BadInput.Wrap(err, "connection validation failed") |
| 43 | } |
| 44 | |
| 45 | // 保存到数据库 |
| 46 | err = connectionHelper.Create(connection, input) |
| 47 | if err != nil { |
| 48 | return nil, err |
| 49 | } |
| 50 | return &plugin.ApiResourceOutput{Body: connection.Sanitize(), Status: http.StatusOK}, nil |
| 51 | } |
| 52 | |
| 53 | // PatchConnection 更新现有连接 (enhanced with Identity Store validation) |
| 54 | func PatchConnection(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { |
nothing calls this directly
no test coverage detected