-
Notifications
You must be signed in to change notification settings - Fork 635
feat(pagerduty): add scope config filters for incident collection #8603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
csepulveda
wants to merge
2
commits into
apache:main
Choose a base branch
from
csepulveda:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
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 connectionId path int true "connectionId" | ||
// @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 dsHelper.ScopeConfigApi.Post(input) | ||
} | ||
|
||
// PatchScopeConfig update scope config for PagerDuty | ||
// @Summary update scope config for PagerDuty | ||
// @Description update scope config for PagerDuty | ||
// @Tags plugins/pagerduty | ||
// @Accept application/json | ||
// @Param id path int true "id" | ||
// @Param connectionId path int true "connectionId" | ||
// @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 PatchScopeConfig(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { | ||
return dsHelper.ScopeConfigApi.Patch(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" | ||
// @Param connectionId path int true "connectionId" | ||
// @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 dsHelper.ScopeConfigApi.GetDetail(input) | ||
} | ||
|
||
// GetScopeConfigList return all scope configs | ||
// @Summary return all scope configs | ||
// @Description return all scope configs | ||
// @Tags plugins/pagerduty | ||
// @Param connectionId path int true "connectionId" | ||
// @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 dsHelper.ScopeConfigApi.GetAll(input) | ||
} | ||
|
||
// GetServicesByScopeConfig return services details related by scope config | ||
// @Summary return all related services | ||
// @Description return all related services | ||
// @Tags plugins/pagerduty | ||
// @Param id path int true "id" | ||
// @Param scopeConfigId path int true "scopeConfigId" | ||
// @Success 200 {object} models.ProjectScopeOutput | ||
// @Failure 400 {object} shared.ApiBody "Bad Request" | ||
// @Failure 500 {object} shared.ApiBody "Internal Error" | ||
// @Router /plugins/pagerduty/scope-config/{scopeConfigId}/projects [GET] | ||
func GetServicesByScopeConfig(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { | ||
return dsHelper.ScopeConfigApi.GetProjectsByScopeConfig(input) | ||
} | ||
|
||
// DeleteScopeConfig delete a scope config | ||
// @Summary delete a scope config | ||
// @Description delete a scope config | ||
// @Tags plugins/pagerduty | ||
// @Param id path int true "id" | ||
// @Param connectionId path int true "connectionId" | ||
// @Success 200 | ||
// @Failure 400 {object} shared.ApiBody "Bad Request" | ||
// @Failure 500 {object} shared.ApiBody "Internal Error" | ||
// @Router /plugins/pagerduty/connections/{connectionId}/scope-configs/{id} [DELETE] | ||
func DeleteScopeConfig(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { | ||
return dsHelper.ScopeConfigApi.Delete(input) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
.../plugins/pagerduty/models/migrationscripts/20251003_add_filter_fields_to_scope_configs.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
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 migrationscripts | ||
|
||
import ( | ||
"github.com/apache/incubator-devlake/core/context" | ||
"github.com/apache/incubator-devlake/core/errors" | ||
"github.com/apache/incubator-devlake/core/plugin" | ||
) | ||
|
||
var _ plugin.MigrationScript = (*addFilterFieldsToPagerDutyScopeConfig20251003)(nil) | ||
|
||
type PagerDutyScopeConfig20251003 struct { | ||
PriorityFilter []string `mapstructure:"priorityFilter" json:"priorityFilter" gorm:"type:text;serializer:json"` | ||
UrgencyFilter []string `mapstructure:"urgencyFilter" json:"urgencyFilter" gorm:"type:text;serializer:json"` | ||
} | ||
|
||
func (o PagerDutyScopeConfig20251003) TableName() string { | ||
return "_tool_pagerduty_scope_configs" | ||
} | ||
|
||
type addFilterFieldsToPagerDutyScopeConfig20251003 struct{} | ||
|
||
func (script *addFilterFieldsToPagerDutyScopeConfig20251003) Up(basicRes context.BasicRes) errors.Error { | ||
return basicRes.GetDal().AutoMigrate(&PagerDutyScopeConfig20251003{}) | ||
} | ||
|
||
func (*addFilterFieldsToPagerDutyScopeConfig20251003) Version() uint64 { | ||
return 20251003000000 | ||
} | ||
|
||
func (script *addFilterFieldsToPagerDutyScopeConfig20251003) Name() string { | ||
return "add priority_filter and urgency_filter fields to table _tool_pagerduty_scope_configs" | ||
} |
48 changes: 48 additions & 0 deletions
48
...end/plugins/pagerduty/models/migrationscripts/20251003_add_scope_config_id_to_services.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
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 migrationscripts | ||
|
||
import ( | ||
"github.com/apache/incubator-devlake/core/context" | ||
"github.com/apache/incubator-devlake/core/errors" | ||
"github.com/apache/incubator-devlake/core/plugin" | ||
) | ||
|
||
var _ plugin.MigrationScript = (*addScopeConfigIdToServices20251003)(nil) | ||
|
||
type service20251003 struct { | ||
ScopeConfigId uint64 `gorm:"column:scope_config_id"` | ||
} | ||
|
||
func (service20251003) TableName() string { | ||
return "_tool_pagerduty_services" | ||
} | ||
|
||
type addScopeConfigIdToServices20251003 struct{} | ||
|
||
func (script *addScopeConfigIdToServices20251003) Up(basicRes context.BasicRes) errors.Error { | ||
return basicRes.GetDal().AutoMigrate(&service20251003{}) | ||
} | ||
|
||
func (*addScopeConfigIdToServices20251003) Version() uint64 { | ||
return 20251003000001 | ||
} | ||
|
||
func (script *addScopeConfigIdToServices20251003) Name() string { | ||
return "add scope_config_id to _tool_pagerduty_services" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ | |
*/ | ||
|
||
export * from './config'; | ||
export * from './transformation'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change it to
connections/:connectionId/scope-configs/:scopeConfigId/projects
to complyRESTful
convention.