You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by "mappjzc (via GitHub)" <gi...@apache.org> on 2023/06/06 07:00:51 UTC

[GitHub] [incubator-devlake] mappjzc commented on a diff in pull request #5367: feat: add jira remote api

mappjzc commented on code in PR #5367:
URL: https://github.com/apache/incubator-devlake/pull/5367#discussion_r1219032667


##########
backend/plugins/jira/api/remote.go:
##########
@@ -0,0 +1,78 @@
+/*
+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 api
+
+import (
+	"context"
+	"fmt"
+	"net/url"
+
+	context2 "github.com/apache/incubator-devlake/core/context"
+	"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/plugins/jira/models"
+	"github.com/apache/incubator-devlake/plugins/jira/tasks/apiv2models"
+)
+
+// RemoteScopes list all available scope for users
+// @Summary list all available scope for users
+// @Description list all available scope for users
+// @Tags plugins/jira
+// @Accept application/json
+// @Param connectionId path int false "connection ID"
+// @Param groupId query string false "group ID"
+// @Param pageToken query string false "page Token"
+// @Success 200  {object} api.RemoteScopesOutput
+// @Failure 400  {object} shared.ApiBody "Bad Request"
+// @Failure 500  {object} shared.ApiBody "Internal Error"
+// @Router /plugins/jira/connections/{connectionId}/remote-scopes [GET]
+func RemoteScopes(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
+	return remoteHelper.GetScopesFromRemote(input,
+		nil,
+		func(basicRes context2.BasicRes, gid string, queryData *api.RemoteQueryData, connection models.JiraConnection) ([]apiv2models.Board, errors.Error) {
+			query := initialQuery(queryData)
+			// create api client
+			apiClient, err := api.NewApiClientFromConnection(context.TODO(), basicRes, &connection)
+			if err != nil {
+				return nil, err
+			}
+			res, err := apiClient.Get("agile/1.0/board", query, nil)
+			if err != nil {
+				return nil, err
+			}
+
+			resBody := struct {
+				Values []apiv2models.Board `json:"values"`
+			}{}
+
+			err = api.UnmarshalResponse(res, &resBody)
+			if err != nil {
+				return nil, err
+			}
+
+			return resBody.Values, err
+		})
+}
+

Review Comment:
   No search on config-UI for Jira request.
   ![image](https://github.com/apache/incubator-devlake/assets/2921251/3f91e32b-9d8a-4ab8-a61f-bb8af349c5db)
   So it neednā€˜t SearchRemoteScopes.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org