|
| 1 | +/* |
| 2 | +Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | +contributor license agreements. See the NOTICE file distributed with |
| 4 | +this work for additional information regarding copyright ownership. |
| 5 | +The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | +(the "License"); you may not use this file except in compliance with |
| 7 | +the License. You may obtain a copy of the License at |
| 8 | +
|
| 9 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +
|
| 11 | +Unless required by applicable law or agreed to in writing, software |
| 12 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +See the License for the specific language governing permissions and |
| 15 | +limitations under the License. |
| 16 | +*/ |
| 17 | + |
| 18 | +package api |
| 19 | + |
| 20 | +import ( |
| 21 | + "github.com/apache/incubator-devlake/core/errors" |
| 22 | + "github.com/apache/incubator-devlake/core/plugin" |
| 23 | +) |
| 24 | + |
| 25 | +// CreateScopeConfig create scope config for PagerDuty |
| 26 | +// @Summary create scope config for PagerDuty |
| 27 | +// @Description create scope config for PagerDuty |
| 28 | +// @Tags plugins/pagerduty |
| 29 | +// @Accept application/json |
| 30 | +// @Param connectionId path int true "connectionId" |
| 31 | +// @Param scopeConfig body models.PagerdutyScopeConfig true "scope config" |
| 32 | +// @Success 200 {object} models.PagerdutyScopeConfig |
| 33 | +// @Failure 400 {object} shared.ApiBody "Bad Request" |
| 34 | +// @Failure 500 {object} shared.ApiBody "Internal Error" |
| 35 | +// @Router /plugins/pagerduty/connections/{connectionId}/scope-configs [POST] |
| 36 | +func CreateScopeConfig(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { |
| 37 | + return dsHelper.ScopeConfigApi.Post(input) |
| 38 | +} |
| 39 | + |
| 40 | +// PatchScopeConfig update scope config for PagerDuty |
| 41 | +// @Summary update scope config for PagerDuty |
| 42 | +// @Description update scope config for PagerDuty |
| 43 | +// @Tags plugins/pagerduty |
| 44 | +// @Accept application/json |
| 45 | +// @Param id path int true "id" |
| 46 | +// @Param connectionId path int true "connectionId" |
| 47 | +// @Param scopeConfig body models.PagerdutyScopeConfig true "scope config" |
| 48 | +// @Success 200 {object} models.PagerdutyScopeConfig |
| 49 | +// @Failure 400 {object} shared.ApiBody "Bad Request" |
| 50 | +// @Failure 500 {object} shared.ApiBody "Internal Error" |
| 51 | +// @Router /plugins/pagerduty/connections/{connectionId}/scope-configs/{id} [PATCH] |
| 52 | +func PatchScopeConfig(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { |
| 53 | + return dsHelper.ScopeConfigApi.Patch(input) |
| 54 | +} |
| 55 | + |
| 56 | +// GetScopeConfig return one scope config |
| 57 | +// @Summary return one scope config |
| 58 | +// @Description return one scope config |
| 59 | +// @Tags plugins/pagerduty |
| 60 | +// @Param id path int true "id" |
| 61 | +// @Param connectionId path int true "connectionId" |
| 62 | +// @Success 200 {object} models.PagerdutyScopeConfig |
| 63 | +// @Failure 400 {object} shared.ApiBody "Bad Request" |
| 64 | +// @Failure 500 {object} shared.ApiBody "Internal Error" |
| 65 | +// @Router /plugins/pagerduty/connections/{connectionId}/scope-configs/{id} [GET] |
| 66 | +func GetScopeConfig(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { |
| 67 | + return dsHelper.ScopeConfigApi.GetDetail(input) |
| 68 | +} |
| 69 | + |
| 70 | +// GetScopeConfigList return all scope configs |
| 71 | +// @Summary return all scope configs |
| 72 | +// @Description return all scope configs |
| 73 | +// @Tags plugins/pagerduty |
| 74 | +// @Param connectionId path int true "connectionId" |
| 75 | +// @Param pageSize query int false "page size, default 50" |
| 76 | +// @Param page query int false "page size, default 1" |
| 77 | +// @Success 200 {object} []models.PagerdutyScopeConfig |
| 78 | +// @Failure 400 {object} shared.ApiBody "Bad Request" |
| 79 | +// @Failure 500 {object} shared.ApiBody "Internal Error" |
| 80 | +// @Router /plugins/pagerduty/connections/{connectionId}/scope-configs [GET] |
| 81 | +func GetScopeConfigList(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { |
| 82 | + return dsHelper.ScopeConfigApi.GetAll(input) |
| 83 | +} |
| 84 | + |
| 85 | +// GetServicesByScopeConfig return services details related by scope config |
| 86 | +// @Summary return all related services |
| 87 | +// @Description return all related services |
| 88 | +// @Tags plugins/pagerduty |
| 89 | +// @Param id path int true "id" |
| 90 | +// @Param scopeConfigId path int true "scopeConfigId" |
| 91 | +// @Success 200 {object} models.ServiceScopeOutput |
| 92 | +// @Failure 400 {object} shared.ApiBody "Bad Request" |
| 93 | +// @Failure 500 {object} shared.ApiBody "Internal Error" |
| 94 | +// @Router /plugins/pagerduty/scope-config/{scopeConfigId}/projects [GET] |
| 95 | +func GetServicesByScopeConfig(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { |
| 96 | + return dsHelper.ScopeConfigApi.GetProjectsByScopeConfig(input) |
| 97 | +} |
| 98 | + |
| 99 | +// DeleteScopeConfig delete a scope config |
| 100 | +// @Summary delete a scope config |
| 101 | +// @Description delete a scope config |
| 102 | +// @Tags plugins/pagerduty |
| 103 | +// @Param id path int true "id" |
| 104 | +// @Param connectionId path int true "connectionId" |
| 105 | +// @Success 200 |
| 106 | +// @Failure 400 {object} shared.ApiBody "Bad Request" |
| 107 | +// @Failure 500 {object} shared.ApiBody "Internal Error" |
| 108 | +// @Router /plugins/pagerduty/connections/{connectionId}/scope-configs/{id} [DELETE] |
| 109 | +func DeleteScopeConfig(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { |
| 110 | + return dsHelper.ScopeConfigApi.Delete(input) |
| 111 | +} |
0 commit comments