keon94 commented on code in PR #5153:
URL:
https://github.com/apache/incubator-devlake/pull/5153#discussion_r1191251040
##########
backend/helpers/pluginhelper/api/scope_helper.go:
##########
@@ -245,9 +310,95 @@ func (c *ScopeApiHelper[Conn, Scope, Tr]) GetScope(input
*plugin.ApiResourceInpu
return nil, errors.NotFound.New("transformationRule not
found")
}
}
- scopeRes := &ScopeRes[Scope]{scope,
reflect.ValueOf(rule).FieldByName("Name").String()}
+ scopeRes := &ScopeRes[Scope]{
+ Scope: scope,
+ TransformationRuleName:
reflect.ValueOf(rule).FieldByName("Name").String(),
+ }
return &plugin.ApiResourceOutput{Body: scopeRes, Status:
http.StatusOK}, nil
}
+func (c *ScopeApiHelper[Conn, Scope, Tr]) DeleteScope(input
*plugin.ApiResourceInput, scopeIdFieldName string, rawScopeParamName string,
+ getScopeParamValue func(db dal.Dal, scopeId string) (string,
errors.Error)) (*plugin.ApiResourceOutput, errors.Error) {
+ params := c.extractFromDeleteReqParam(input)
+ if params == nil || params.connectionId == 0 {
+ return nil, errors.BadInput.New("invalid path params:
\"connectionId\" not set")
+ }
+ if len(params.scopeId) == 0 || params.scopeId == "0" {
+ return nil, errors.BadInput.New("invalid path params:
\"scopeId\" not set/invalid")
+ }
+ err := c.VerifyConnection(params.connectionId)
+ if err != nil {
+ return nil, errors.Default.Wrap(err, fmt.Sprintf("error
verifying connection for connection ID %d", params.connectionId))
+ }
+ db := c.db
+ blueprintsMap, err := c.bpManager.GetBlueprintsByScopes(params.scopeId)
+ if err != nil {
+ return nil, errors.Default.Wrap(err, fmt.Sprintf("error
retrieving scope with scope ID %s", params.scopeId))
+ }
+ blueprints := blueprintsMap[params.scopeId]
+ // find all tables for this plugin
+ tables, err := getPluginTables(params.plugin)
+ if err != nil {
+ return nil, errors.Default.Wrap(err, fmt.Sprintf("error getting
database tables managed by plugin %s", params.plugin))
+ }
+ // delete all the plugin records referencing this scope
+ if rawScopeParamName != "" {
Review Comment:
I don't think webhook even uses this API. It probably needs a separate
solution
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]