You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by kl...@apache.org on 2023/11/28 10:00:02 UTC

(incubator-devlake) 01/01: refactor: move api_client interface to plugin package

This is an automated email from the ASF dual-hosted git repository.

klesh pushed a commit to branch kw-5519-dshelper
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 568fbf45bef2ec75306479fc6704d9bf42e1612d
Author: Klesh Wong <zh...@merico.dev>
AuthorDate: Tue Nov 28 17:59:50 2023 +0800

    refactor: move api_client interface to plugin package
---
 backend/core/plugin/api_client.go                 | 34 +++++++++++++++++++++++
 backend/core/plugin/plugin_datasource.go          |  8 ++++--
 backend/go.mod                                    |  4 ---
 backend/go.sum                                    | 12 +-------
 backend/helpers/pluginhelper/api/api_client.go    |  8 ++++--
 backend/plugins/bamboo/models/connection.go       |  3 +-
 backend/plugins/bitbucket/tasks/repo_convertor.go |  3 +-
 backend/plugins/feishu/models/connection.go       |  4 +--
 backend/plugins/github/api/blueprint_v200.go      |  5 ++--
 backend/plugins/github/models/connection.go       |  6 ++--
 backend/plugins/gitlab/api/blueprint_v200.go      |  3 +-
 backend/plugins/gitlab/models/connection.go       |  3 +-
 backend/plugins/jenkins/api/jobs.go               | 10 +++----
 backend/plugins/jenkins/api/jobs_test.go          |  6 ++--
 backend/plugins/jira/api/scope.go                 |  3 +-
 backend/plugins/sonarqube/api/blueprint_v200.go   |  3 +-
 backend/plugins/tapd/api/remote.go                |  3 +-
 backend/plugins/zentao/api/proxy.go               |  3 --
 backend/plugins/zentao/models/connection.go       |  4 +--
 19 files changed, 70 insertions(+), 55 deletions(-)

diff --git a/backend/core/plugin/api_client.go b/backend/core/plugin/api_client.go
new file mode 100644
index 000000000..d66b1432b
--- /dev/null
+++ b/backend/core/plugin/api_client.go
@@ -0,0 +1,34 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package plugin
+
+import (
+	"net/http"
+	"net/url"
+
+	"github.com/apache/incubator-devlake/core/errors"
+)
+
+// ApiClientAbstract defines the functionalities needed by all plugins for Synchronized API Request
+type ApiClient interface {
+	SetData(name string, data interface{})
+	GetData(name string) interface{}
+	SetHeaders(headers map[string]string)
+	Get(path string, query url.Values, headers http.Header) (*http.Response, errors.Error)
+	Post(path string, query url.Values, body interface{}, headers http.Header) (*http.Response, errors.Error)
+}
diff --git a/backend/core/plugin/plugin_datasource.go b/backend/core/plugin/plugin_datasource.go
index fa0cb8768..550aec913 100644
--- a/backend/core/plugin/plugin_datasource.go
+++ b/backend/core/plugin/plugin_datasource.go
@@ -26,7 +26,6 @@ import (
 	"github.com/apache/incubator-devlake/core/dal"
 
 	"github.com/apache/incubator-devlake/core/errors"
-	"github.com/apache/incubator-devlake/helpers/pluginhelper/api/apihelperabstract"
 	"github.com/go-playground/validator/v10"
 )
 
@@ -58,7 +57,7 @@ type ConnectionValidator interface {
 // PrepareApiClient is to be implemented by the concrete Connection which requires
 // preparation for the ApiClient created by NewApiClientFromConnection, i.e. fetch token for future requests
 type PrepareApiClient interface {
-	PrepareApiClient(apiClient apihelperabstract.ApiClientAbstract) errors.Error
+	PrepareApiClient(apiClient ApiClient) errors.Error
 }
 
 // MultiAuth
@@ -111,6 +110,11 @@ type ToolLayerConnection interface {
 	ConnectionId() uint64
 }
 
+type ToolLayerApiConnection interface {
+	ApiConnection
+	ToolLayerConnection
+}
+
 type ToolLayerScope interface {
 	dal.Tabler
 	Scope
diff --git a/backend/go.mod b/backend/go.mod
index a61d3ff2c..b336da9ba 100644
--- a/backend/go.mod
+++ b/backend/go.mod
@@ -85,9 +85,7 @@ require (
 	github.com/kr/text v0.2.0 // indirect
 	github.com/leodido/go-urn v1.2.4 // indirect
 	github.com/mailru/easyjson v0.7.7 // indirect
-	github.com/mattn/go-colorable v0.1.11 // indirect
 	github.com/mattn/go-isatty v0.0.19 // indirect
-	github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
 	github.com/modern-go/reflect2 v1.0.2 // indirect
 	github.com/pelletier/go-toml v1.9.3 // indirect
@@ -110,7 +108,6 @@ require (
 	golang.org/x/arch v0.3.0 // indirect
 	golang.org/x/net v0.16.0 // indirect
 	golang.org/x/sys v0.13.0 // indirect
-	golang.org/x/term v0.13.0 // indirect
 	golang.org/x/text v0.13.0 // indirect
 	golang.org/x/tools v0.13.0 // indirect
 	google.golang.org/appengine v1.6.7 // indirect
@@ -124,7 +121,6 @@ require (
 require (
 	github.com/go-sql-driver/mysql v1.7.1
 	github.com/golang-jwt/jwt/v5 v5.0.0-rc.1
-	github.com/x-cray/logrus-prefixed-formatter v0.5.2
 	golang.org/x/mod v0.13.0
 )
 
diff --git a/backend/go.sum b/backend/go.sum
index 9739816ad..06e41338c 100644
--- a/backend/go.sum
+++ b/backend/go.sum
@@ -138,6 +138,7 @@ github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod
 github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
 github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
 github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nIgbVgp3rreNmTged+9HrbNTIQf1PsaIiTA=
+github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
 github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
 github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
 github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
@@ -467,7 +468,6 @@ github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcncea
 github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
 github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
 github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
-github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs=
 github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
 github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
 github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
@@ -486,8 +486,6 @@ github.com/mediocregopher/radix/v3 v3.3.0/go.mod h1:EmfVyvspXz1uZEyPBMyGK+kjWiKQ
 github.com/mediocregopher/radix/v3 v3.4.2/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8=
 github.com/merico-dev/graphql v0.0.0-20221027131946-77460a1fd4cd h1:hGQXd4a72JSFIZE+ZVkH5ivE925PGogjob6stgc2too=
 github.com/merico-dev/graphql v0.0.0-20221027131946-77460a1fd4cd/go.mod h1:dcDqG8HXVtfEhTCipFMa0Q+RTKTtDKIO2vJt+JVzHEQ=
-github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
-github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
 github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc=
 github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
 github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
@@ -516,12 +514,10 @@ github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7
 github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
 github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
-github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
 github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
 github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
 github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
-github.com/onsi/ginkgo v1.13.0 h1:M76yO2HkZASFjXL0HSoZJ1AYEmQxNJmY41Jx1zNUq1Y=
 github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0=
 github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
 github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
@@ -590,8 +586,6 @@ github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY=
 github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
 github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
 github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
-github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA=
-github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
 github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA=
 github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48=
 github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
@@ -655,8 +649,6 @@ github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+
 github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
 github.com/viant/afs v1.16.0 h1:yb9TQ1gjVVLji9lcXLWaarklqmGWeXTZOwc2fwJevCI=
 github.com/viant/afs v1.16.0/go.mod h1:wdiEDffZKJwj1ZSFasy7hHoxLQdSpFZkd3XOWNt1aN0=
-github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg=
-github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=
 github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
 github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
 github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
@@ -919,7 +911,6 @@ golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
 golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
 golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
 golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
-golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -1131,7 +1122,6 @@ gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
 gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU=
 gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
 gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
-gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
 gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
 gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
diff --git a/backend/helpers/pluginhelper/api/api_client.go b/backend/helpers/pluginhelper/api/api_client.go
index 255af5dee..4607ffa0b 100644
--- a/backend/helpers/pluginhelper/api/api_client.go
+++ b/backend/helpers/pluginhelper/api/api_client.go
@@ -34,6 +34,7 @@ import (
 	"unicode/utf8"
 
 	aha "github.com/apache/incubator-devlake/core/plugin"
+	plugin "github.com/apache/incubator-devlake/core/plugin"
 
 	"github.com/apache/incubator-devlake/core/context"
 	"github.com/apache/incubator-devlake/core/errors"
@@ -44,8 +45,9 @@ import (
 
 // ErrIgnoreAndContinue is a error which should be ignored
 var (
-	ErrIgnoreAndContinue = errors.Default.New("ignore and continue")
-	ErrEmptyResponse     = errors.Default.New("empty response")
+	ErrIgnoreAndContinue                  = errors.Default.New("ignore and continue")
+	ErrEmptyResponse                      = errors.Default.New("empty response")
+	_                    plugin.ApiClient = (*ApiClient)(nil)
 )
 
 // ApiClient is designed for simple api requests
@@ -69,7 +71,7 @@ func NewApiClientFromConnection(
 	connection aha.ApiConnection,
 ) (*ApiClient, errors.Error) {
 	if reflect.ValueOf(connection).Kind() != reflect.Ptr {
-		return nil, errors.Default.New("connection is not a pointer")
+		panic(fmt.Errorf("connection is not a pointer"))
 	}
 	apiClient, err := NewApiClient(ctx, connection.GetEndpoint(), nil, 0, connection.GetProxy(), br)
 	if err != nil {
diff --git a/backend/plugins/bamboo/models/connection.go b/backend/plugins/bamboo/models/connection.go
index 1feeb5cc1..26447b6ba 100644
--- a/backend/plugins/bamboo/models/connection.go
+++ b/backend/plugins/bamboo/models/connection.go
@@ -26,7 +26,6 @@ import (
 
 	"github.com/apache/incubator-devlake/core/errors"
 	"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
-	"github.com/apache/incubator-devlake/helpers/pluginhelper/api/apihelperabstract"
 )
 
 var _ plugin.ApiConnection = (*BambooConnection)(nil)
@@ -55,7 +54,7 @@ func (conn *BambooConn) Sanitize() BambooConn {
 }
 
 // PrepareApiClient test api and set the IsPrivateToken,version,UserId and so on.
-func (conn *BambooConn) PrepareApiClient(apiClient apihelperabstract.ApiClientAbstract) errors.Error {
+func (conn *BambooConn) PrepareApiClient(apiClient plugin.ApiClient) errors.Error {
 	header := http.Header{}
 	header.Set("Authorization", fmt.Sprintf("Basic %v", conn.GetEncodedToken()))
 
diff --git a/backend/plugins/bitbucket/tasks/repo_convertor.go b/backend/plugins/bitbucket/tasks/repo_convertor.go
index 40aaf908c..4961462c3 100644
--- a/backend/plugins/bitbucket/tasks/repo_convertor.go
+++ b/backend/plugins/bitbucket/tasks/repo_convertor.go
@@ -34,7 +34,6 @@ import (
 	"github.com/apache/incubator-devlake/core/models/domainlayer/ticket"
 	plugin "github.com/apache/incubator-devlake/core/plugin"
 	"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
-	aha "github.com/apache/incubator-devlake/helpers/pluginhelper/api/apihelperabstract"
 	"github.com/apache/incubator-devlake/plugins/bitbucket/models"
 )
 
@@ -52,7 +51,7 @@ type ApiRepoResponse models.BitbucketApiRepo
 
 func GetApiRepo(
 	op *BitbucketOptions,
-	apiClient aha.ApiClientAbstract,
+	apiClient plugin.ApiClient,
 ) (*models.BitbucketApiRepo, errors.Error) {
 	res, err := apiClient.Get(path.Join("repositories", op.FullName), nil, nil)
 	if err != nil {
diff --git a/backend/plugins/feishu/models/connection.go b/backend/plugins/feishu/models/connection.go
index 9e0b26644..c9646db61 100644
--- a/backend/plugins/feishu/models/connection.go
+++ b/backend/plugins/feishu/models/connection.go
@@ -22,8 +22,8 @@ import (
 	"net/http"
 
 	"github.com/apache/incubator-devlake/core/errors"
+	"github.com/apache/incubator-devlake/core/plugin"
 	helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
-	"github.com/apache/incubator-devlake/helpers/pluginhelper/api/apihelperabstract"
 	"github.com/apache/incubator-devlake/plugins/feishu/apimodels"
 )
 
@@ -38,7 +38,7 @@ func (conn *FeishuConn) Sanitize() FeishuConn {
 	return *conn
 }
 
-func (conn *FeishuConn) PrepareApiClient(apiClient apihelperabstract.ApiClientAbstract) errors.Error {
+func (conn *FeishuConn) PrepareApiClient(apiClient plugin.ApiClient) errors.Error {
 	// request for access token
 	tokenReqBody := &apimodels.ApiAccessTokenRequest{
 		AppId:     conn.AppId,
diff --git a/backend/plugins/github/api/blueprint_v200.go b/backend/plugins/github/api/blueprint_v200.go
index ee2a977b0..aaf85b147 100644
--- a/backend/plugins/github/api/blueprint_v200.go
+++ b/backend/plugins/github/api/blueprint_v200.go
@@ -36,7 +36,6 @@ import (
 	"github.com/apache/incubator-devlake/core/plugin"
 	"github.com/apache/incubator-devlake/core/utils"
 	helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
-	aha "github.com/apache/incubator-devlake/helpers/pluginhelper/api/apihelperabstract"
 	"github.com/apache/incubator-devlake/helpers/srvhelper"
 	"github.com/apache/incubator-devlake/plugins/github/models"
 	"github.com/apache/incubator-devlake/plugins/github/tasks"
@@ -235,7 +234,7 @@ func addGithub(
 
 func getApiRepo(
 	op *tasks.GithubOptions,
-	apiClient aha.ApiClientAbstract,
+	apiClient plugin.ApiClient,
 ) (*tasks.GithubApiRepo, errors.Error) {
 	repoRes := &tasks.GithubApiRepo{}
 	res, err := apiClient.Get(fmt.Sprintf("repos/%s", op.Name), nil, nil)
@@ -259,7 +258,7 @@ func getApiRepo(
 
 func MemorizedGetApiRepo(
 	repo *tasks.GithubApiRepo,
-	op *tasks.GithubOptions, apiClient aha.ApiClientAbstract,
+	op *tasks.GithubOptions, apiClient plugin.ApiClient,
 ) (*tasks.GithubApiRepo, errors.Error) {
 	if repo == nil {
 		var err errors.Error
diff --git a/backend/plugins/github/models/connection.go b/backend/plugins/github/models/connection.go
index 4b06a8788..2333e124b 100644
--- a/backend/plugins/github/models/connection.go
+++ b/backend/plugins/github/models/connection.go
@@ -26,8 +26,8 @@ import (
 	"time"
 
 	"github.com/apache/incubator-devlake/core/errors"
+	"github.com/apache/incubator-devlake/core/plugin"
 	helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
-	"github.com/apache/incubator-devlake/helpers/pluginhelper/api/apihelperabstract"
 	"github.com/golang-jwt/jwt/v5"
 )
 
@@ -52,7 +52,7 @@ type GithubConn struct {
 }
 
 // PrepareApiClient splits Token to tokens for SetupAuthentication to utilize
-func (conn *GithubConn) PrepareApiClient(apiClient apihelperabstract.ApiClientAbstract) errors.Error {
+func (conn *GithubConn) PrepareApiClient(apiClient plugin.ApiClient) errors.Error {
 
 	if conn.AuthMethod == "AccessToken" {
 		conn.tokens = strings.Split(conn.Token, ",")
@@ -153,7 +153,7 @@ func (gak *GithubAppKey) CreateJwt() (string, errors.Error) {
 }
 
 func (gak *GithubAppKey) getInstallationAccessToken(
-	apiClient apihelperabstract.ApiClientAbstract,
+	apiClient plugin.ApiClient,
 ) (*InstallationToken, errors.Error) {
 
 	jwt, err := gak.CreateJwt()
diff --git a/backend/plugins/gitlab/api/blueprint_v200.go b/backend/plugins/gitlab/api/blueprint_v200.go
index 31f283a40..02bac1eff 100644
--- a/backend/plugins/gitlab/api/blueprint_v200.go
+++ b/backend/plugins/gitlab/api/blueprint_v200.go
@@ -36,7 +36,6 @@ import (
 	"github.com/apache/incubator-devlake/core/models/domainlayer/ticket"
 	plugin "github.com/apache/incubator-devlake/core/plugin"
 	helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
-	aha "github.com/apache/incubator-devlake/helpers/pluginhelper/api/apihelperabstract"
 	"github.com/apache/incubator-devlake/helpers/srvhelper"
 	"github.com/apache/incubator-devlake/plugins/gitlab/models"
 )
@@ -169,7 +168,7 @@ func makePipelinePlanV200(
 
 func GetApiProject(
 	op *tasks.GitlabOptions,
-	apiClient aha.ApiClientAbstract,
+	apiClient plugin.ApiClient,
 ) (*models.GitlabApiProject, errors.Error) {
 	repoRes := &models.GitlabApiProject{}
 	res, err := apiClient.Get(fmt.Sprintf("projects/%d", op.ProjectId), nil, nil)
diff --git a/backend/plugins/gitlab/models/connection.go b/backend/plugins/gitlab/models/connection.go
index 411b7a82f..f9c15f2af 100644
--- a/backend/plugins/gitlab/models/connection.go
+++ b/backend/plugins/gitlab/models/connection.go
@@ -24,7 +24,6 @@ import (
 	"github.com/apache/incubator-devlake/core/errors"
 	"github.com/apache/incubator-devlake/core/plugin"
 	"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
-	"github.com/apache/incubator-devlake/helpers/pluginhelper/api/apihelperabstract"
 )
 
 // GitlabConn holds the essential information to connect to the Gitlab API
@@ -48,7 +47,7 @@ func (conn *GitlabConn) Sanitize() GitlabConn {
 }
 
 // PrepareApiClient test api and set the IsPrivateToken,version,UserId and so on.
-func (conn *GitlabConn) PrepareApiClient(apiClient apihelperabstract.ApiClientAbstract) errors.Error {
+func (conn *GitlabConn) PrepareApiClient(apiClient plugin.ApiClient) errors.Error {
 	header1 := http.Header{}
 	header1.Set("Authorization", fmt.Sprintf("Bearer %v", conn.Token))
 	// test request for access token
diff --git a/backend/plugins/jenkins/api/jobs.go b/backend/plugins/jenkins/api/jobs.go
index 07ded1152..b6f2da309 100644
--- a/backend/plugins/jenkins/api/jobs.go
+++ b/backend/plugins/jenkins/api/jobs.go
@@ -26,11 +26,11 @@ import (
 	"github.com/apache/incubator-devlake/plugins/jenkins/models"
 
 	"github.com/apache/incubator-devlake/core/errors"
+	"github.com/apache/incubator-devlake/core/plugin"
 	helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
-	aha "github.com/apache/incubator-devlake/helpers/pluginhelper/api/apihelperabstract"
 )
 
-func GetJobsPage(apiClient aha.ApiClientAbstract, path string, page int, pageSize int, callback func(job *models.Job) errors.Error) (int, errors.Error) {
+func GetJobsPage(apiClient plugin.ApiClient, path string, page int, pageSize int, callback func(job *models.Job) errors.Error) (int, errors.Error) {
 	i := page * pageSize
 	var data struct {
 		Jobs []json.RawMessage `json:"jobs"`
@@ -70,7 +70,7 @@ func GetJobsPage(apiClient aha.ApiClientAbstract, path string, page int, pageSiz
 	return len(data.Jobs), nil
 }
 
-func GetJobs(apiClient aha.ApiClientAbstract, path string, pageSize int, callback func(job *models.Job) errors.Error) errors.Error {
+func GetJobs(apiClient plugin.ApiClient, path string, pageSize int, callback func(job *models.Job) errors.Error) errors.Error {
 	for i := 0; ; i++ {
 		count, err := GetJobsPage(apiClient, path, i, pageSize, callback)
 		if err != nil {
@@ -84,7 +84,7 @@ func GetJobs(apiClient aha.ApiClientAbstract, path string, pageSize int, callbac
 }
 
 func GetJob(
-	apiClient aha.ApiClientAbstract,
+	apiClient plugin.ApiClient,
 	path string,
 	name string,
 	fullName string,
@@ -115,7 +115,7 @@ func GetJob(
 
 // request all jobs
 func GetAllJobs(
-	apiClient aha.ApiClientAbstract,
+	apiClient plugin.ApiClient,
 	path string,
 	beforename string,
 	pageSize int,
diff --git a/backend/plugins/jenkins/api/jobs_test.go b/backend/plugins/jenkins/api/jobs_test.go
index 411939b6f..21c23132d 100644
--- a/backend/plugins/jenkins/api/jobs_test.go
+++ b/backend/plugins/jenkins/api/jobs_test.go
@@ -25,7 +25,7 @@ import (
 	"testing"
 
 	mockdal "github.com/apache/incubator-devlake/mocks/core/dal"
-	mockaha "github.com/apache/incubator-devlake/mocks/helpers/pluginhelper/api/apihelperabstract"
+	mockplugin "github.com/apache/incubator-devlake/mocks/core/plugin"
 
 	"github.com/apache/incubator-devlake/core/errors"
 	"github.com/apache/incubator-devlake/helpers/unithelper"
@@ -68,7 +68,7 @@ func TestGetJob(t *testing.T) {
 		},
 	}
 
-	mockApiClient := mockaha.NewApiClientAbstract(t)
+	mockApiClient := mockplugin.NewApiClient(t)
 
 	var data struct {
 		Jobs []json.RawMessage `json:"jobs"`
@@ -218,7 +218,7 @@ func TestGetAllJobs(t *testing.T) {
 		},
 	}
 
-	mockApiClient := mockaha.NewApiClientAbstract(t)
+	mockApiClient := mockplugin.NewApiClient(t)
 
 	var data struct {
 		Jobs []json.RawMessage `json:"jobs"`
diff --git a/backend/plugins/jira/api/scope.go b/backend/plugins/jira/api/scope.go
index d1ad1e687..9f2344ab3 100644
--- a/backend/plugins/jira/api/scope.go
+++ b/backend/plugins/jira/api/scope.go
@@ -26,7 +26,6 @@ import (
 	"github.com/apache/incubator-devlake/core/errors"
 	"github.com/apache/incubator-devlake/core/plugin"
 	"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
-	aha "github.com/apache/incubator-devlake/helpers/pluginhelper/api/apihelperabstract"
 	"github.com/apache/incubator-devlake/plugins/jira/models"
 	"github.com/apache/incubator-devlake/plugins/jira/tasks"
 	"github.com/apache/incubator-devlake/plugins/jira/tasks/apiv2models"
@@ -117,7 +116,7 @@ func DeleteScope(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, err
 	return scopeHelper.Delete(input)
 }
 
-func GetApiJira(op *tasks.JiraOptions, apiClient aha.ApiClientAbstract) (*apiv2models.Board, errors.Error) {
+func GetApiJira(op *tasks.JiraOptions, apiClient plugin.ApiClient) (*apiv2models.Board, errors.Error) {
 	boardRes := &apiv2models.Board{}
 	res, err := apiClient.Get(fmt.Sprintf("agile/1.0/board/%d", op.BoardId), nil, nil)
 	if err != nil {
diff --git a/backend/plugins/sonarqube/api/blueprint_v200.go b/backend/plugins/sonarqube/api/blueprint_v200.go
index b1148e530..f1feff666 100644
--- a/backend/plugins/sonarqube/api/blueprint_v200.go
+++ b/backend/plugins/sonarqube/api/blueprint_v200.go
@@ -30,7 +30,6 @@ import (
 	"github.com/apache/incubator-devlake/core/models/domainlayer/didgen"
 	"github.com/apache/incubator-devlake/core/plugin"
 	helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
-	aha "github.com/apache/incubator-devlake/helpers/pluginhelper/api/apihelperabstract"
 	"github.com/apache/incubator-devlake/plugins/sonarqube/models"
 )
 
@@ -110,7 +109,7 @@ func makeScopesV200(bpScopes []*coreModels.BlueprintScope, connectionId uint64)
 
 func GetApiProject(
 	projectKey string,
-	apiClient aha.ApiClientAbstract,
+	apiClient plugin.ApiClient,
 ) (*models.SonarqubeApiProject, errors.Error) {
 	var resData struct {
 		Data []models.SonarqubeApiProject `json:"components"`
diff --git a/backend/plugins/tapd/api/remote.go b/backend/plugins/tapd/api/remote.go
index b11c74412..edc403538 100644
--- a/backend/plugins/tapd/api/remote.go
+++ b/backend/plugins/tapd/api/remote.go
@@ -29,7 +29,6 @@ import (
 	"github.com/apache/incubator-devlake/core/errors"
 	"github.com/apache/incubator-devlake/core/plugin"
 	"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
-	aha "github.com/apache/incubator-devlake/helpers/pluginhelper/api/apihelperabstract"
 	"github.com/apache/incubator-devlake/plugins/tapd/models"
 	"github.com/apache/incubator-devlake/plugins/tapd/tasks"
 )
@@ -142,7 +141,7 @@ func RemoteScopes(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, er
 	)
 }
 
-func GetApiWorkspace(op *tasks.TapdOptions, apiClient aha.ApiClientAbstract) (*models.TapdWorkspace, errors.Error) {
+func GetApiWorkspace(op *tasks.TapdOptions, apiClient plugin.ApiClient) (*models.TapdWorkspace, errors.Error) {
 	query := url.Values{}
 	query.Set("workspace_id", fmt.Sprintf("%v", op.WorkspaceId))
 	res, err := apiClient.Get("workspaces/get_workspace_info", query, nil)
diff --git a/backend/plugins/zentao/api/proxy.go b/backend/plugins/zentao/api/proxy.go
index 91da596ee..5ce50e94b 100644
--- a/backend/plugins/zentao/api/proxy.go
+++ b/backend/plugins/zentao/api/proxy.go
@@ -33,9 +33,6 @@ import (
 // @Tags plugins/zentao
 // @Param connectionId path int true "connection ID"
 // @Param path path string true "path to Zentao API"
-// @Success 200  {object} ZentaoTestConnResponse "Success"
-// @Failure 400  {string} errcode.Error "Bad Request"
-// @Failure 500  {string} errcode.Error "Internal Error"
 // @Router /plugins/zentao/connections/{connectionId}/proxy/{path} [GET]
 func Proxy(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
 	connection := &models.ZentaoConnection{}
diff --git a/backend/plugins/zentao/models/connection.go b/backend/plugins/zentao/models/connection.go
index 0d68067f3..9245cc1cf 100644
--- a/backend/plugins/zentao/models/connection.go
+++ b/backend/plugins/zentao/models/connection.go
@@ -24,12 +24,12 @@ import (
 	"strings"
 
 	"github.com/apache/incubator-devlake/core/errors"
+	"github.com/apache/incubator-devlake/core/plugin"
 	helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
-	"github.com/apache/incubator-devlake/helpers/pluginhelper/api/apihelperabstract"
 )
 
 // PrepareApiClient fetches token from Zentao API for future requests
-func (connection ZentaoConn) PrepareApiClient(apiClient apihelperabstract.ApiClientAbstract) errors.Error {
+func (connection ZentaoConn) PrepareApiClient(apiClient plugin.ApiClient) errors.Error {
 	// request for access token
 	tokenReqBody := &ApiAccessTokenRequest{
 		Account:  connection.Username,