You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/11/17 12:26:07 UTC

[GitHub] [incubator-devlake] mindlesscloud opened a new pull request, #3753: feat: scope and transformation rule for jira

mindlesscloud opened a new pull request, #3753:
URL: https://github.com/apache/incubator-devlake/pull/3753

   ### Summary
   1. define the interfaces `PluginSource` 
   2. implement it for the plugin Jira
   3. expose `Jira board` and `Jira transformation rule` as RESTful resources 
   4. supply swagger docs for the new HTTP endpoints
   
   ### Does this close any open issues?
   No, but partially fulfilled issue #3468 
   
   ### Screenshots
   ![image](https://user-images.githubusercontent.com/8455907/202445741-53380ddd-388b-43cd-b5ae-b84f8f541aa6.png)
   ![image](https://user-images.githubusercontent.com/8455907/202445819-6e50164b-4768-4294-8a5b-4caa01c317f4.png)
   


-- 
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


[GitHub] [incubator-devlake] klesh merged pull request #3753: feat: scope and transformation rule for jira

Posted by GitBox <gi...@apache.org>.
klesh merged PR #3753:
URL: https://github.com/apache/incubator-devlake/pull/3753


-- 
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


[GitHub] [incubator-devlake] klesh commented on a diff in pull request #3753: feat: scope and transformation rule for jira

Posted by GitBox <gi...@apache.org>.
klesh commented on code in PR #3753:
URL: https://github.com/apache/incubator-devlake/pull/3753#discussion_r1028724306


##########
plugins/jira/impl/impl.go:
##########
@@ -217,6 +249,21 @@ func (plugin Jira) ApiResources() map[string]map[string]core.ApiResourceHandler
 		"connections/:connectionId/proxy/rest/*path": {
 			"GET": api.Proxy,
 		},
+		"connections/:connectionId/scopes/:boardId": {
+			"GET": api.GetScope,
+			"PUT": api.PutScope,
+		},
+		"connections/:connectionId/scopes": {
+			"GET": api.GetScopeList,
+		},
+		"transformation_rules": {
+			"POST": api.CreateTransformationRule,
+			"GET":  api.GetTransformationRuleList,
+		},
+		"transformation_rules/:id": {
+			"PUT": api.UpdateTransformationRule,

Review Comment:
   It should be PATCH and act like `PATCH /plugins/jira/connections/:connectionId`



-- 
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


[GitHub] [incubator-devlake] klesh commented on a diff in pull request #3753: feat: scope and transformation rule for jira

Posted by GitBox <gi...@apache.org>.
klesh commented on code in PR #3753:
URL: https://github.com/apache/incubator-devlake/pull/3753#discussion_r1028721981


##########
plugins/jira/api/scope.go:
##########
@@ -0,0 +1,138 @@
+/*
+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 (
+	"net/http"
+	"net/url"
+	"strconv"
+
+	"github.com/apache/incubator-devlake/errors"
+	"github.com/apache/incubator-devlake/plugins/core"
+	"github.com/apache/incubator-devlake/plugins/core/dal"
+	"github.com/apache/incubator-devlake/plugins/jira/models"
+	"github.com/mitchellh/mapstructure"
+)
+
+type putBoardRequest struct {
+	ConnectionId uint64 `json:"connectionId"`
+	BoardId      uint64 `json:"boardId"`
+	ProjectId    uint   `json:"projectId"`
+	Name         string `json:"name"`
+	Self         string `json:"self"`
+	Type         string `json:"type"`
+}
+
+// PutScope create or update jira board
+// @Summary create or update jira board
+// @Description Create or update Jira board
+// @Tags plugins/jira
+// @Accept application/json
+// @Param scope body putBoardRequest true "json"
+// @Success 200  {object} core.ApiResourceOutput
+// @Failure 400  {object} shared.ApiBody "Bad Request"
+// @Failure 500  {object} shared.ApiBody "Internal Error"
+// @Router /plugins/jira/scopes [PUT]
+func PutScope(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error) {
+	// update from request and save to database
+	var req putBoardRequest
+	err := mapstructure.Decode(input.Body, &req)
+	if err != nil {
+		return nil, errors.Default.Wrap(err, "error decoding map into putBoardRequest")
+	}
+	board := &models.JiraBoard{

Review Comment:
   Ok, let's keep it simple.



-- 
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


[GitHub] [incubator-devlake] klesh commented on a diff in pull request #3753: feat: scope and transformation rule for jira

Posted by GitBox <gi...@apache.org>.
klesh commented on code in PR #3753:
URL: https://github.com/apache/incubator-devlake/pull/3753#discussion_r1027509427


##########
plugins/jira/api/scope.go:
##########
@@ -0,0 +1,138 @@
+/*
+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 (
+	"net/http"
+	"net/url"
+	"strconv"
+
+	"github.com/apache/incubator-devlake/errors"
+	"github.com/apache/incubator-devlake/plugins/core"
+	"github.com/apache/incubator-devlake/plugins/core/dal"
+	"github.com/apache/incubator-devlake/plugins/jira/models"
+	"github.com/mitchellh/mapstructure"
+)
+
+type putBoardRequest struct {
+	ConnectionId uint64 `json:"connectionId"`
+	BoardId      uint64 `json:"boardId"`
+	ProjectId    uint   `json:"projectId"`
+	Name         string `json:"name"`
+	Self         string `json:"self"`
+	Type         string `json:"type"`
+}
+
+// PutScope create or update jira board
+// @Summary create or update jira board
+// @Description Create or update Jira board
+// @Tags plugins/jira
+// @Accept application/json
+// @Param scope body putBoardRequest true "json"
+// @Success 200  {object} core.ApiResourceOutput
+// @Failure 400  {object} shared.ApiBody "Bad Request"
+// @Failure 500  {object} shared.ApiBody "Internal Error"
+// @Router /plugins/jira/scopes [PUT]
+func PutScope(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error) {
+	// update from request and save to database
+	var req putBoardRequest
+	err := mapstructure.Decode(input.Body, &req)
+	if err != nil {
+		return nil, errors.Default.Wrap(err, "error decoding map into putBoardRequest")
+	}
+	board := &models.JiraBoard{
+		ConnectionId: req.ConnectionId,
+		BoardId:      req.BoardId,
+		ProjectId:    req.ProjectId,
+		Name:         req.Name,
+		Self:         req.Self,
+		Type:         req.Type,
+	}
+	err = basicRes.GetDal().CreateOrUpdate(&board)
+	if err != nil {
+		return nil, errors.Default.Wrap(err, "error on saving JiraBoard")
+	}
+	return &core.ApiResourceOutput{Status: http.StatusOK}, nil
+}
+
+// DeleteScope delete a jira board
+// @Summary delete a jira board
+// @Description delete a jira board
+// @Tags plugins/jira
+// @Param connectionId query int false "connection ID"
+// @Param boardId query int false "board ID"
+// @Success 200  {object} core.ApiResourceOutput
+// @Failure 400  {object} shared.ApiBody "Bad Request"
+// @Failure 500  {object} shared.ApiBody "Internal Error"
+// @Router /plugins/jira/scopes [DELETE]
+func DeleteScope(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error) {

Review Comment:
   No delete 



##########
plugins/jira/api/scope.go:
##########
@@ -0,0 +1,138 @@
+/*
+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 (
+	"net/http"
+	"net/url"
+	"strconv"
+
+	"github.com/apache/incubator-devlake/errors"
+	"github.com/apache/incubator-devlake/plugins/core"
+	"github.com/apache/incubator-devlake/plugins/core/dal"
+	"github.com/apache/incubator-devlake/plugins/jira/models"
+	"github.com/mitchellh/mapstructure"
+)
+
+type putBoardRequest struct {
+	ConnectionId uint64 `json:"connectionId"`
+	BoardId      uint64 `json:"boardId"`
+	ProjectId    uint   `json:"projectId"`
+	Name         string `json:"name"`
+	Self         string `json:"self"`
+	Type         string `json:"type"`
+}
+
+// PutScope create or update jira board
+// @Summary create or update jira board
+// @Description Create or update Jira board
+// @Tags plugins/jira
+// @Accept application/json
+// @Param scope body putBoardRequest true "json"
+// @Success 200  {object} core.ApiResourceOutput
+// @Failure 400  {object} shared.ApiBody "Bad Request"
+// @Failure 500  {object} shared.ApiBody "Internal Error"
+// @Router /plugins/jira/scopes [PUT]
+func PutScope(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error) {
+	// update from request and save to database
+	var req putBoardRequest
+	err := mapstructure.Decode(input.Body, &req)
+	if err != nil {
+		return nil, errors.Default.Wrap(err, "error decoding map into putBoardRequest")
+	}
+	board := &models.JiraBoard{

Review Comment:
   this `api` package is getting complex, should we create a `services` for the plugin to hold the Biz Logic?



##########
plugins/jira/api/transformation_rule.go:
##########
@@ -0,0 +1,160 @@
+/*
+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

Review Comment:
   This file has the same problems as `api/scope.go`



##########
plugins/jira/api/scope.go:
##########
@@ -0,0 +1,138 @@
+/*
+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 (
+	"net/http"
+	"net/url"
+	"strconv"
+
+	"github.com/apache/incubator-devlake/errors"
+	"github.com/apache/incubator-devlake/plugins/core"
+	"github.com/apache/incubator-devlake/plugins/core/dal"
+	"github.com/apache/incubator-devlake/plugins/jira/models"
+	"github.com/mitchellh/mapstructure"
+)
+
+type putBoardRequest struct {
+	ConnectionId uint64 `json:"connectionId"`
+	BoardId      uint64 `json:"boardId"`
+	ProjectId    uint   `json:"projectId"`
+	Name         string `json:"name"`
+	Self         string `json:"self"`
+	Type         string `json:"type"`
+}
+
+// PutScope create or update jira board
+// @Summary create or update jira board
+// @Description Create or update Jira board
+// @Tags plugins/jira
+// @Accept application/json
+// @Param scope body putBoardRequest true "json"
+// @Success 200  {object} core.ApiResourceOutput
+// @Failure 400  {object} shared.ApiBody "Bad Request"
+// @Failure 500  {object} shared.ApiBody "Internal Error"
+// @Router /plugins/jira/scopes [PUT]
+func PutScope(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error) {
+	// update from request and save to database
+	var req putBoardRequest
+	err := mapstructure.Decode(input.Body, &req)
+	if err != nil {
+		return nil, errors.Default.Wrap(err, "error decoding map into putBoardRequest")
+	}
+	board := &models.JiraBoard{
+		ConnectionId: req.ConnectionId,
+		BoardId:      req.BoardId,
+		ProjectId:    req.ProjectId,
+		Name:         req.Name,
+		Self:         req.Self,
+		Type:         req.Type,
+	}
+	err = basicRes.GetDal().CreateOrUpdate(&board)
+	if err != nil {
+		return nil, errors.Default.Wrap(err, "error on saving JiraBoard")
+	}
+	return &core.ApiResourceOutput{Status: http.StatusOK}, nil
+}
+
+// DeleteScope delete a jira board
+// @Summary delete a jira board
+// @Description delete a jira board
+// @Tags plugins/jira
+// @Param connectionId query int false "connection ID"
+// @Param boardId query int false "board ID"
+// @Success 200  {object} core.ApiResourceOutput
+// @Failure 400  {object} shared.ApiBody "Bad Request"
+// @Failure 500  {object} shared.ApiBody "Internal Error"
+// @Router /plugins/jira/scopes [DELETE]
+func DeleteScope(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error) {
+	connectionId, boardId := extractQuery(input.Query)
+	if connectionId == 0 {
+		return nil, errors.Default.New("invalid connectionId")
+	}
+	if boardId == 0 {
+		return nil, errors.Default.New("invalid boardId")
+	}
+	err := basicRes.GetDal().Delete(&models.JiraBoard{}, dal.Where("connection_id = ? AND board_id = ?", connectionId, boardId))
+	if err != nil {
+		return nil, errors.Default.Wrap(err, "error on deleting JiraBoard")
+	}
+	return &core.ApiResourceOutput{Status: http.StatusOK}, nil
+}
+
+// GetScope get Jira board

Review Comment:
   boards?



##########
plugins/jira/api/scope.go:
##########
@@ -0,0 +1,138 @@
+/*
+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 (
+	"net/http"
+	"net/url"
+	"strconv"
+
+	"github.com/apache/incubator-devlake/errors"
+	"github.com/apache/incubator-devlake/plugins/core"
+	"github.com/apache/incubator-devlake/plugins/core/dal"
+	"github.com/apache/incubator-devlake/plugins/jira/models"
+	"github.com/mitchellh/mapstructure"
+)
+
+type putBoardRequest struct {
+	ConnectionId uint64 `json:"connectionId"`
+	BoardId      uint64 `json:"boardId"`
+	ProjectId    uint   `json:"projectId"`
+	Name         string `json:"name"`
+	Self         string `json:"self"`
+	Type         string `json:"type"`
+}
+
+// PutScope create or update jira board
+// @Summary create or update jira board
+// @Description Create or update Jira board
+// @Tags plugins/jira
+// @Accept application/json
+// @Param scope body putBoardRequest true "json"
+// @Success 200  {object} core.ApiResourceOutput
+// @Failure 400  {object} shared.ApiBody "Bad Request"
+// @Failure 500  {object} shared.ApiBody "Internal Error"
+// @Router /plugins/jira/scopes [PUT]

Review Comment:
   `PUT /plugin/jira/connections/:connectionId/scopes/:scopeIdOrName`



##########
plugins/jira/models/transformation_rules.go:
##########
@@ -0,0 +1,31 @@
+/*
+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 models
+
+import (
+	"github.com/apache/incubator-devlake/models/common"
+	"gorm.io/datatypes"
+)
+
+type JiraTransformationRule struct {
+	common.Model
+	EpicKeyField               string         `json:"epicKeyField"`
+	StoryPointField            string         `json:"storyPointField"`
+	RemotelinkCommitShaPattern string         `json:"remotelinkCommitShaPattern"`
+	TypeMappings               datatypes.JSON `json:"typeMappings"`

Review Comment:
   same as above



##########
plugins/jira/models/migrationscripts/archived/transformation_rules.go:
##########
@@ -0,0 +1,31 @@
+/*
+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 archived
+
+import (
+	"github.com/apache/incubator-devlake/models/migrationscripts/archived"
+	"gorm.io/datatypes"
+)
+
+type JiraTransformationRule struct {
+	archived.Model
+	EpicKeyField               string         `json:"epicKeyField"`
+	StoryPointField            string         `json:"storyPointField"`
+	RemotelinkCommitShaPattern string         `json:"remotelinkCommitShaPattern"`
+	TypeMappings               datatypes.JSON `json:"typeMappings"`

Review Comment:
   please avoid using `gorm` package, use `json.RawMessage` instead



##########
plugins/jira/api/scope.go:
##########
@@ -0,0 +1,138 @@
+/*
+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 (
+	"net/http"
+	"net/url"
+	"strconv"
+
+	"github.com/apache/incubator-devlake/errors"
+	"github.com/apache/incubator-devlake/plugins/core"
+	"github.com/apache/incubator-devlake/plugins/core/dal"
+	"github.com/apache/incubator-devlake/plugins/jira/models"
+	"github.com/mitchellh/mapstructure"
+)
+
+type putBoardRequest struct {
+	ConnectionId uint64 `json:"connectionId"`
+	BoardId      uint64 `json:"boardId"`
+	ProjectId    uint   `json:"projectId"`
+	Name         string `json:"name"`
+	Self         string `json:"self"`
+	Type         string `json:"type"`
+}
+
+// PutScope create or update jira board
+// @Summary create or update jira board
+// @Description Create or update Jira board
+// @Tags plugins/jira
+// @Accept application/json
+// @Param scope body putBoardRequest true "json"
+// @Success 200  {object} core.ApiResourceOutput
+// @Failure 400  {object} shared.ApiBody "Bad Request"
+// @Failure 500  {object} shared.ApiBody "Internal Error"
+// @Router /plugins/jira/scopes [PUT]
+func PutScope(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error) {
+	// update from request and save to database
+	var req putBoardRequest
+	err := mapstructure.Decode(input.Body, &req)
+	if err != nil {
+		return nil, errors.Default.Wrap(err, "error decoding map into putBoardRequest")
+	}
+	board := &models.JiraBoard{
+		ConnectionId: req.ConnectionId,
+		BoardId:      req.BoardId,
+		ProjectId:    req.ProjectId,
+		Name:         req.Name,
+		Self:         req.Self,
+		Type:         req.Type,
+	}
+	err = basicRes.GetDal().CreateOrUpdate(&board)
+	if err != nil {
+		return nil, errors.Default.Wrap(err, "error on saving JiraBoard")
+	}
+	return &core.ApiResourceOutput{Status: http.StatusOK}, nil
+}
+
+// DeleteScope delete a jira board
+// @Summary delete a jira board
+// @Description delete a jira board
+// @Tags plugins/jira
+// @Param connectionId query int false "connection ID"
+// @Param boardId query int false "board ID"
+// @Success 200  {object} core.ApiResourceOutput
+// @Failure 400  {object} shared.ApiBody "Bad Request"
+// @Failure 500  {object} shared.ApiBody "Internal Error"
+// @Router /plugins/jira/scopes [DELETE]
+func DeleteScope(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error) {
+	connectionId, boardId := extractQuery(input.Query)
+	if connectionId == 0 {
+		return nil, errors.Default.New("invalid connectionId")
+	}
+	if boardId == 0 {
+		return nil, errors.Default.New("invalid boardId")
+	}
+	err := basicRes.GetDal().Delete(&models.JiraBoard{}, dal.Where("connection_id = ? AND board_id = ?", connectionId, boardId))
+	if err != nil {
+		return nil, errors.Default.Wrap(err, "error on deleting JiraBoard")
+	}
+	return &core.ApiResourceOutput{Status: http.StatusOK}, nil
+}
+
+// GetScope get Jira board

Review Comment:
   This is very RESTful, we need a `list(search)` API as well as `detail` API, we need them side by side:
   1. `GET /plugin/jira/connections/:connectionId/scopes?keyboard=xxx`
   2. `GET /plugin/jira/connections/:connectionId/scopes/:scopeIdOrName`



-- 
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


[GitHub] [incubator-devlake] mindlesscloud commented on a diff in pull request #3753: feat: scope and transformation rule for jira

Posted by GitBox <gi...@apache.org>.
mindlesscloud commented on code in PR #3753:
URL: https://github.com/apache/incubator-devlake/pull/3753#discussion_r1027919747


##########
plugins/jira/api/scope.go:
##########
@@ -0,0 +1,138 @@
+/*
+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 (
+	"net/http"
+	"net/url"
+	"strconv"
+
+	"github.com/apache/incubator-devlake/errors"
+	"github.com/apache/incubator-devlake/plugins/core"
+	"github.com/apache/incubator-devlake/plugins/core/dal"
+	"github.com/apache/incubator-devlake/plugins/jira/models"
+	"github.com/mitchellh/mapstructure"
+)
+
+type putBoardRequest struct {
+	ConnectionId uint64 `json:"connectionId"`
+	BoardId      uint64 `json:"boardId"`
+	ProjectId    uint   `json:"projectId"`
+	Name         string `json:"name"`
+	Self         string `json:"self"`
+	Type         string `json:"type"`
+}
+
+// PutScope create or update jira board
+// @Summary create or update jira board
+// @Description Create or update Jira board
+// @Tags plugins/jira
+// @Accept application/json
+// @Param scope body putBoardRequest true "json"
+// @Success 200  {object} core.ApiResourceOutput
+// @Failure 400  {object} shared.ApiBody "Bad Request"
+// @Failure 500  {object} shared.ApiBody "Internal Error"
+// @Router /plugins/jira/scopes [PUT]
+func PutScope(input *core.ApiResourceInput) (*core.ApiResourceOutput, errors.Error) {
+	// update from request and save to database
+	var req putBoardRequest
+	err := mapstructure.Decode(input.Body, &req)
+	if err != nil {
+		return nil, errors.Default.Wrap(err, "error decoding map into putBoardRequest")
+	}
+	board := &models.JiraBoard{

Review Comment:
   Most handler functions contain less than 10 lines of code, and only do a very straightforward job. The complexity of `api` comes from the amount of `HTTP` endpoints, not the complex business logic. Introducing a new `services` package has little effect on reducing the complexity of `api`



-- 
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


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3753: feat: scope and transformation rule for jira

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3753:
URL: https://github.com/apache/incubator-devlake/pull/3753#discussion_r1029410749


##########
plugins/jira/impl/impl.go:
##########
@@ -217,6 +249,21 @@ func (plugin Jira) ApiResources() map[string]map[string]core.ApiResourceHandler
 		"connections/:connectionId/proxy/rest/*path": {
 			"GET": api.Proxy,
 		},
+		"connections/:connectionId/scopes/:boardId": {
+			"GET": api.GetScope,
+			"PUT": api.PutScope,

Review Comment:
   When will `PutScope` be used? In my opinion, `board` is only created when collecting and extracting. Do these APIs write for config-ui?



-- 
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


[GitHub] [incubator-devlake] klesh commented on a diff in pull request #3753: feat: scope and transformation rule for jira

Posted by GitBox <gi...@apache.org>.
klesh commented on code in PR #3753:
URL: https://github.com/apache/incubator-devlake/pull/3753#discussion_r1028896925


##########
plugins/jira/api/scope.go:
##########
@@ -0,0 +1,124 @@
+/*
+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 (
+	"net/http"
+	"strconv"
+
+	"github.com/apache/incubator-devlake/errors"
+	"github.com/apache/incubator-devlake/plugins/core"
+	"github.com/apache/incubator-devlake/plugins/core/dal"
+	"github.com/apache/incubator-devlake/plugins/jira/models"
+	"github.com/mitchellh/mapstructure"
+)
+
+type putBoardRequest struct {
+	ProjectId uint   `json:"projectId"`
+	Name      string `json:"name"`
+	Self      string `json:"self"`
+	Type      string `json:"type"`
+}
+
+// PutScope create or update jira board
+// @Summary create or update jira board
+// @Description Create or update Jira board
+// @Tags plugins/jira
+// @Accept application/json
+// @Param connectionId path int false "connection ID"
+// @Param boardId path int false "board ID"
+// @Param scope body putBoardRequest true "json"
+// @Success 200  {object} core.ApiResourceOutput

Review Comment:
   `core.ApiResourceOutput` doesn't seem right, same as the following APIs.
   They should be a `struct` that can represent the output of the API



-- 
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