d4x1 commented on code in PR #6494:
URL:
https://github.com/apache/incubator-devlake/pull/6494#discussion_r1402984513
##########
backend/plugins/ae/api/connection.go:
##########
@@ -32,6 +32,33 @@ type ApiMeResponse struct {
Name string `json:"name"`
}
+func testConnection(ctx context.Context, connection models.AeConn)
(*plugin.ApiResourceOutput, errors.Error) {
+ // validate
+ if vld != nil {
+ if err := vld.Struct(connection); err != nil {
+ return nil, errors.Default.Wrap(err, "error validating
target")
+ }
+ }
+ apiClient, err := api.NewApiClientFromConnection(ctx, basicRes,
&connection)
+ if err != nil {
+ return nil, err
+ }
+ res, err := apiClient.Get("projects", nil, nil)
+ if err != nil {
+ return nil, err
+ }
+ switch res.StatusCode {
+ case 200: // right StatusCode
+ return &plugin.ApiResourceOutput{Body: true, Status: 200}, nil
+ case 401: // error secretKey or nonceStr
+ return &plugin.ApiResourceOutput{Body: false, Status:
http.StatusBadRequest}, nil
+ default: // unknow what happen , back to user
+ return &plugin.ApiResourceOutput{Body: res.Body, Status:
res.StatusCode}, nil
+ }
+}
+
+// TestConnection test ae connection
+// Deprecated
Review Comment:
Agreed. This comment should be removed.
--
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]