MCPcopy Index your code
hub / github.com/apache/devlake / deleteConnection

Function deleteConnection

backend/plugins/webhook/api/connection.go:153–181  ·  view source on GitHub ↗
(e error, connectionId uint64)

Source from the content-addressed store, hash-verified

151}
152
153func deleteConnection(e error, connectionId uint64) (*plugin.ApiResourceOutput, errors.Error) {
154 if e != nil {
155 return nil, errors.BadInput.WrapRaw(e)
156 }
157 var connection models.WebhookConnection
158 tx := basicRes.GetDal().Begin()
159 err := tx.Delete(&connection, dal.Where("id = ?", connectionId))
160 if err != nil {
161 if err := tx.Rollback(); err != nil {
162 logger.Error(err, "transaction Rollback")
163 }
164 logger.Error(err, "delete connection: %d", connectionId)
165 return nil, err
166 }
167 extra := fmt.Sprintf("connectionId:%d", connectionId)
168 err = apiKeyHelper.DeleteForPlugin(tx, pluginName, extra)
169 if err != nil {
170 if err := tx.Rollback(); err != nil {
171 logger.Error(err, "transaction Rollback")
172 }
173 logger.Error(err, "delete connection extra: %d, name: %s", extra, pluginName)
174 return nil, err
175 }
176 if err := tx.Commit(); err != nil {
177 logger.Info("transaction commit: %s", err)
178 }
179
180 return &plugin.ApiResourceOutput{Status: http.StatusOK}, nil
181}
182
183type WebhookConnectionResponse struct {
184 models.WebhookConnection

Callers 2

DeleteConnectionFunction · 0.85
DeleteConnectionByNameFunction · 0.85

Calls 9

WrapRawMethod · 0.80
DeleteForPluginMethod · 0.80
BeginMethod · 0.65
GetDalMethod · 0.65
DeleteMethod · 0.65
RollbackMethod · 0.65
ErrorMethod · 0.65
CommitMethod · 0.65
InfoMethod · 0.65

Tested by

no test coverage detected