You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ka...@apache.org on 2023/03/30 03:50:44 UTC

[incubator-devlake] branch main updated: fix: Pagerduty - fix transformation rules endpoints + ticket scopes handling (#4818)

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

ka94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new 6e4846ef9 fix: Pagerduty - fix transformation rules endpoints + ticket scopes handling (#4818)
6e4846ef9 is described below

commit 6e4846ef99a009d2abbbb6a92162e72e8b7b6529
Author: Keon Amini <ke...@merico.dev>
AuthorDate: Wed Mar 29 22:50:40 2023 -0500

    fix: Pagerduty - fix transformation rules endpoints + ticket scopes handling (#4818)
---
 backend/plugins/pagerduty/api/blueprint_v200.go       | 17 +++--------------
 backend/plugins/pagerduty/api/transformation_rules.go |  8 ++++----
 backend/plugins/pagerduty/impl/impl.go                |  4 ++--
 3 files changed, 9 insertions(+), 20 deletions(-)

diff --git a/backend/plugins/pagerduty/api/blueprint_v200.go b/backend/plugins/pagerduty/api/blueprint_v200.go
index af7a077e3..8c257cb4d 100644
--- a/backend/plugins/pagerduty/api/blueprint_v200.go
+++ b/backend/plugins/pagerduty/api/blueprint_v200.go
@@ -22,7 +22,6 @@ import (
 	"github.com/apache/incubator-devlake/core/dal"
 	"github.com/apache/incubator-devlake/core/errors"
 	"github.com/apache/incubator-devlake/core/models/domainlayer"
-	"github.com/apache/incubator-devlake/core/models/domainlayer/devops"
 	"github.com/apache/incubator-devlake/core/models/domainlayer/didgen"
 	"github.com/apache/incubator-devlake/core/models/domainlayer/ticket"
 	"github.com/apache/incubator-devlake/core/plugin"
@@ -114,26 +113,16 @@ func makeScopesV200(bpScopes []*plugin.BlueprintScopeV200, connection *models.Pa
 	scopes := make([]plugin.Scope, 0)
 	for _, bpScope := range bpScopes {
 		service := &models.Service{}
-		// get repo from db
+		// get service from db
 		err := basicRes.GetDal().First(service, dal.Where(`connection_id = ? AND id = ?`, connection.ID, bpScope.Id))
 		if err != nil {
-			return nil, errors.Default.Wrap(err, fmt.Sprintf("fail to find service: %s", bpScope.Id))
-		}
-		// add cicd_scope to scopes
-		if utils.StringsContains(bpScope.Entities, plugin.DOMAIN_TYPE_CICD) {
-			scopeCICD := &devops.CicdScope{
-				DomainEntity: domainlayer.DomainEntity{
-					Id: didgen.NewDomainIdGenerator(&models.Service{}).Generate(connection.ID, service.Id),
-				},
-				Name: service.Name,
-			}
-			scopes = append(scopes, scopeCICD)
+			return nil, errors.Default.Wrap(err, fmt.Sprintf("failed to find service: %s", bpScope.Id))
 		}
 		// add board to scopes
 		if utils.StringsContains(bpScope.Entities, plugin.DOMAIN_TYPE_TICKET) {
 			scopeTicket := &ticket.Board{
 				DomainEntity: domainlayer.DomainEntity{
-					Id: didgen.NewDomainIdGenerator(&models.Incident{}).Generate(connection.ID, service.Id),
+					Id: didgen.NewDomainIdGenerator(&models.Service{}).Generate(connection.ID, service.Id),
 				},
 				Name: service.Name,
 			}
diff --git a/backend/plugins/pagerduty/api/transformation_rules.go b/backend/plugins/pagerduty/api/transformation_rules.go
index 142de4f11..860f0c490 100644
--- a/backend/plugins/pagerduty/api/transformation_rules.go
+++ b/backend/plugins/pagerduty/api/transformation_rules.go
@@ -31,7 +31,7 @@ import (
 // @Success 200  {object} models.PagerdutyTransformationRule
 // @Failure 400  {object} shared.ApiBody "Bad Request"
 // @Failure 500  {object} shared.ApiBody "Internal Error"
-// @Router /plugins/pagerduty/:connectionId/transformation_rules [POST]
+// @Router /plugins/pagerduty/connections/:connectionId/transformation_rules [POST]
 func CreateTransformationRule(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
 	return trHelper.Create(input)
 }
@@ -46,7 +46,7 @@ func CreateTransformationRule(input *plugin.ApiResourceInput) (*plugin.ApiResour
 // @Success 200  {object} models.PagerdutyTransformationRule
 // @Failure 400  {object} shared.ApiBody "Bad Request"
 // @Failure 500  {object} shared.ApiBody "Internal Error"
-// @Router /plugins/pagerduty/:connectionId/transformation_rules/{id} [PATCH]
+// @Router /plugins/pagerduty/connections/:connectionId/transformation_rules/{id} [PATCH]
 func UpdateTransformationRule(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
 	return trHelper.Update(input)
 }
@@ -59,7 +59,7 @@ func UpdateTransformationRule(input *plugin.ApiResourceInput) (*plugin.ApiResour
 // @Success 200  {object} models.PagerdutyTransformationRule
 // @Failure 400  {object} shared.ApiBody "Bad Request"
 // @Failure 500  {object} shared.ApiBody "Internal Error"
-// @Router /plugins/pagerduty/:connectionId/transformation_rules/{id} [GET]
+// @Router /plugins/pagerduty/connections/:connectionId/transformation_rules/{id} [GET]
 func GetTransformationRule(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
 	return trHelper.Get(input)
 }
@@ -73,7 +73,7 @@ func GetTransformationRule(input *plugin.ApiResourceInput) (*plugin.ApiResourceO
 // @Success 200  {object} []models.PagerdutyTransformationRule
 // @Failure 400  {object} shared.ApiBody "Bad Request"
 // @Failure 500  {object} shared.ApiBody "Internal Error"
-// @Router /plugins/pagerduty/:connectionId/transformation_rules [GET]
+// @Router /plugins/pagerduty/connections/:connectionId/transformation_rules [GET]
 func GetTransformationRuleList(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
 	return trHelper.List(input)
 }
diff --git a/backend/plugins/pagerduty/impl/impl.go b/backend/plugins/pagerduty/impl/impl.go
index e0558591b..cdcca4b3f 100644
--- a/backend/plugins/pagerduty/impl/impl.go
+++ b/backend/plugins/pagerduty/impl/impl.go
@@ -133,11 +133,11 @@ func (p PagerDuty) ApiResources() map[string]map[string]plugin.ApiResourceHandle
 			"GET": api.GetScopeList,
 			"PUT": api.PutScope,
 		},
-		"/:connectionId/transformation_rules": {
+		"connections/:connectionId/transformation_rules": {
 			"POST": api.CreateTransformationRule,
 			"GET":  api.GetTransformationRuleList,
 		},
-		"/:connectionId/transformation_rules/:id": {
+		"connections/:connectionId/transformation_rules/:id": {
 			"PATCH": api.UpdateTransformationRule,
 			"GET":   api.GetTransformationRule,
 		},