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

klesh 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 6a735c4ab refactor: Remove scope_config from pagerduty as it is unused 
(#5369)
6a735c4ab is described below

commit 6a735c4abf842e05c7660dc5fd6387c28a6ddb9c
Author: Keon Amini <[email protected]>
AuthorDate: Tue Jun 6 22:57:34 2023 -0500

    refactor: Remove scope_config from pagerduty as it is unused (#5369)
---
 backend/plugins/pagerduty/api/init.go              |  5 --
 backend/plugins/pagerduty/api/remote.go            |  7 +-
 backend/plugins/pagerduty/api/scope_config.go      | 79 ----------------------
 backend/plugins/pagerduty/e2e/incident_test.go     |  9 ++-
 backend/plugins/pagerduty/impl/impl.go             |  8 ---
 ...register.go => 20230605_remove_scope_config.go} | 26 ++++---
 .../pagerduty/models/migrationscripts/register.go  |  1 +
 backend/plugins/pagerduty/models/service.go        |  9 ++-
 8 files changed, 28 insertions(+), 116 deletions(-)

diff --git a/backend/plugins/pagerduty/api/init.go 
b/backend/plugins/pagerduty/api/init.go
index 18b66be6d..b2a035986 100644
--- a/backend/plugins/pagerduty/api/init.go
+++ b/backend/plugins/pagerduty/api/init.go
@@ -29,7 +29,6 @@ var connectionHelper *api.ConnectionApiHelper
 
 var scopeHelper *api.ScopeApiHelper[models.PagerDutyConnection, 
models.Service, models.PagerdutyScopeConfig]
 
-var scHelper *api.ScopeConfigHelper[models.PagerdutyScopeConfig]
 var basicRes context.BasicRes
 
 func Init(br context.BasicRes) {
@@ -53,8 +52,4 @@ func Init(br context.BasicRes) {
                params,
                &api.ScopeHelperOptions{},
        )
-       scHelper = api.NewScopeConfigHelper[models.PagerdutyScopeConfig](
-               basicRes,
-               vld,
-       )
 }
diff --git a/backend/plugins/pagerduty/api/remote.go 
b/backend/plugins/pagerduty/api/remote.go
index f592bda2e..21bfa8a4d 100644
--- a/backend/plugins/pagerduty/api/remote.go
+++ b/backend/plugins/pagerduty/api/remote.go
@@ -131,10 +131,9 @@ func RemoteScopes(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, er
                        Id:   service.Id,
                        Name: service.Name,
                        Data: models.Service{
-                               Url:           service.HtmlUrl,
-                               Id:            service.Id,
-                               ScopeConfigId: 0, // this is not determined here
-                               Name:          service.Name,
+                               Url:  service.HtmlUrl,
+                               Id:   service.Id,
+                               Name: service.Name,
                        },
                }
                outputBody.Children = append(outputBody.Children, child)
diff --git a/backend/plugins/pagerduty/api/scope_config.go 
b/backend/plugins/pagerduty/api/scope_config.go
deleted file mode 100644
index f23299c6a..000000000
--- a/backend/plugins/pagerduty/api/scope_config.go
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
-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 (
-       "github.com/apache/incubator-devlake/core/errors"
-       "github.com/apache/incubator-devlake/core/plugin"
-)
-
-// CreateScopeConfig create scope config for PagerDuty
-// @Summary create scope config for PagerDuty
-// @Description create scope config for PagerDuty
-// @Tags plugins/pagerduty
-// @Accept application/json
-// @Param scopeConfig body models.PagerdutyScopeConfig true "scope config"
-// @Success 200  {object} models.PagerdutyScopeConfig
-// @Failure 400  {object} shared.ApiBody "Bad Request"
-// @Failure 500  {object} shared.ApiBody "Internal Error"
-// @Router /plugins/pagerduty/connections/:connectionId/scope-configs [POST]
-func CreateScopeConfig(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
-       return scHelper.Create(input)
-}
-
-// UpdateScopeConfig update scope config for Github
-// @Summary update scope config for Github
-// @Description update scope config for Github
-// @Tags plugins/pagerduty
-// @Accept application/json
-// @Param id path int true "id"
-// @Param scopeConfig body models.PagerdutyScopeConfig true "scope config"
-// @Success 200  {object} models.PagerdutyScopeConfig
-// @Failure 400  {object} shared.ApiBody "Bad Request"
-// @Failure 500  {object} shared.ApiBody "Internal Error"
-// @Router /plugins/pagerduty/connections/:connectionId/scope-configs/{id} 
[PATCH]
-func UpdateScopeConfig(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
-       return scHelper.Update(input)
-}
-
-// GetScopeConfig return one scope config
-// @Summary return one scope config
-// @Description return one scope config
-// @Tags plugins/pagerduty
-// @Param id path int true "id"
-// @Success 200  {object} models.PagerdutyScopeConfig
-// @Failure 400  {object} shared.ApiBody "Bad Request"
-// @Failure 500  {object} shared.ApiBody "Internal Error"
-// @Router /plugins/pagerduty/connections/:connectionId/scope-configs/{id} 
[GET]
-func GetScopeConfig(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
-       return scHelper.Get(input)
-}
-
-// GetScopeConfigList return all scope configs
-// @Summary return all scope configs
-// @Description return all scope configs
-// @Tags plugins/pagerduty
-// @Param pageSize query int false "page size, default 50"
-// @Param page query int false "page size, default 1"
-// @Success 200  {object} []models.PagerdutyScopeConfig
-// @Failure 400  {object} shared.ApiBody "Bad Request"
-// @Failure 500  {object} shared.ApiBody "Internal Error"
-// @Router /plugins/pagerduty/connections/:connectionId/scope-configs [GET]
-func GetScopeConfigList(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
-       return scHelper.List(input)
-}
diff --git a/backend/plugins/pagerduty/e2e/incident_test.go 
b/backend/plugins/pagerduty/e2e/incident_test.go
index fd1536dfb..14ec2038d 100644
--- a/backend/plugins/pagerduty/e2e/incident_test.go
+++ b/backend/plugins/pagerduty/e2e/incident_test.go
@@ -52,11 +52,10 @@ func TestIncidentDataFlow(t *testing.T) {
        // tx-rule
        require.NoError(t, dataflowTester.Dal.CreateOrUpdate(&scopeConfig))
        service := models.Service{
-               ConnectionId:  options.ConnectionId,
-               Url:           
fmt.Sprintf("https://keon-test.pagerduty.com/service-directory/%s";, 
options.ServiceId),
-               Id:            options.ServiceId,
-               ScopeConfigId: scopeConfig.ID,
-               Name:          options.ServiceName,
+               ConnectionId: options.ConnectionId,
+               Url:          
fmt.Sprintf("https://keon-test.pagerduty.com/service-directory/%s";, 
options.ServiceId),
+               Id:           options.ServiceId,
+               Name:         options.ServiceName,
        }
        // scope
        require.NoError(t, dataflowTester.Dal.CreateOrUpdate(&service))
diff --git a/backend/plugins/pagerduty/impl/impl.go 
b/backend/plugins/pagerduty/impl/impl.go
index caf2bde5e..ee274e0ee 100644
--- a/backend/plugins/pagerduty/impl/impl.go
+++ b/backend/plugins/pagerduty/impl/impl.go
@@ -148,14 +148,6 @@ func (p PagerDuty) ApiResources() 
map[string]map[string]plugin.ApiResourceHandle
                        "PATCH":  api.UpdateScope,
                        "DELETE": api.DeleteScope,
                },
-               "connections/:connectionId/scope-configs": {
-                       "POST": api.CreateScopeConfig,
-                       "GET":  api.GetScopeConfigList,
-               },
-               "connections/:connectionId/scope-configs/:id": {
-                       "PATCH": api.UpdateScopeConfig,
-                       "GET":   api.GetScopeConfig,
-               },
        }
 }
 
diff --git a/backend/plugins/pagerduty/models/migrationscripts/register.go 
b/backend/plugins/pagerduty/models/migrationscripts/20230605_remove_scope_config.go
similarity index 63%
copy from backend/plugins/pagerduty/models/migrationscripts/register.go
copy to 
backend/plugins/pagerduty/models/migrationscripts/20230605_remove_scope_config.go
index a52ffebd4..37cf3bd43 100644
--- a/backend/plugins/pagerduty/models/migrationscripts/register.go
+++ 
b/backend/plugins/pagerduty/models/migrationscripts/20230605_remove_scope_config.go
@@ -18,16 +18,22 @@ limitations under the License.
 package migrationscripts
 
 import (
-       "github.com/apache/incubator-devlake/core/plugin"
+       "github.com/apache/incubator-devlake/core/context"
+       "github.com/apache/incubator-devlake/core/errors"
 )
 
-// All return all the migration scripts
-func All() []plugin.MigrationScript {
-       return []plugin.MigrationScript{
-               new(addInitTables),
-               new(addEndpointAndProxyToConnection),
-               new(addPagerdutyConnectionFields20230123),
-               new(addTransformationRulesToService20230303),
-               new(renameTr2ScopeConfig),
-       }
+type removeScopeConfig struct {
+}
+
+func (u *removeScopeConfig) Up(baseRes context.BasicRes) errors.Error {
+       db := baseRes.GetDal()
+       return db.DropTables("_tool_pagerduty_scope_configs")
+}
+
+func (*removeScopeConfig) Version() uint64 {
+       return 20230605130109
+}
+
+func (*removeScopeConfig) Name() string {
+       return "remove _tool_pagerduty_scope_configs table"
 }
diff --git a/backend/plugins/pagerduty/models/migrationscripts/register.go 
b/backend/plugins/pagerduty/models/migrationscripts/register.go
index a52ffebd4..9d6d0c74b 100644
--- a/backend/plugins/pagerduty/models/migrationscripts/register.go
+++ b/backend/plugins/pagerduty/models/migrationscripts/register.go
@@ -29,5 +29,6 @@ func All() []plugin.MigrationScript {
                new(addPagerdutyConnectionFields20230123),
                new(addTransformationRulesToService20230303),
                new(renameTr2ScopeConfig),
+               new(removeScopeConfig),
        }
 }
diff --git a/backend/plugins/pagerduty/models/service.go 
b/backend/plugins/pagerduty/models/service.go
index 114a6ac62..418d3f80c 100644
--- a/backend/plugins/pagerduty/models/service.go
+++ b/backend/plugins/pagerduty/models/service.go
@@ -23,11 +23,10 @@ import (
 
 type Service struct {
        common.NoPKModel
-       ConnectionId  uint64 `json:"connection_id" 
mapstructure:"connectionId,omitempty" gorm:"primaryKey" `
-       Id            string `json:"id" mapstructure:"id" 
gorm:"primaryKey;autoIncrement:false" `
-       Url           string `json:"url" mapstructure:"url"`
-       ScopeConfigId uint64 `json:"scopeConfigId" 
mapstructure:"scopeConfigId,omitempty"` //keys to PagerdutyScopeConfigs.ID
-       Name          string `json:"name" mapstructure:"name"`
+       ConnectionId uint64 `json:"connection_id" 
mapstructure:"connectionId,omitempty" gorm:"primaryKey" `
+       Id           string `json:"id" mapstructure:"id" 
gorm:"primaryKey;autoIncrement:false" `
+       Url          string `json:"url" mapstructure:"url"`
+       Name         string `json:"name" mapstructure:"name"`
 }
 
 func (Service) TableName() string {

Reply via email to