|
| 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 | + helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api" |
| 24 | + "github.com/apache/incubator-devlake/helpers/srvhelper" |
| 25 | + "github.com/apache/incubator-devlake/plugins/q_dev/models" |
| 26 | +) |
| 27 | + |
| 28 | +type PutScopesReqBody = helper.PutScopesReqBody[models.QDevS3Slice] |
| 29 | +type ScopeDetail = srvhelper.ScopeDetail[models.QDevS3Slice, srvhelper.NoScopeConfig] |
| 30 | + |
| 31 | +// PutScopes create or update Q Developer scopes (S3 prefixes) |
| 32 | +// @Summary create or update Q Developer scopes |
| 33 | +// @Description Create or update Q Developer scopes |
| 34 | +// @Tags plugins/q_dev |
| 35 | +// @Accept application/json |
| 36 | +// @Param connectionId path int true "connection ID" |
| 37 | +// @Param scope body PutScopesReqBody true "json" |
| 38 | +// @Success 200 {object} []models.QDevS3Slice |
| 39 | +// @Failure 400 {object} shared.ApiBody "Bad Request" |
| 40 | +// @Failure 500 {object} shared.ApiBody "Internal Error" |
| 41 | +// @Router /plugins/q_dev/connections/{connectionId}/scopes [PUT] |
| 42 | +func PutScopes(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { |
| 43 | + return dsHelper.ScopeApi.PutMultiple(input) |
| 44 | +} |
| 45 | + |
| 46 | +// GetScopeList returns Q Developer scopes |
| 47 | +// @Summary get Q Developer scopes |
| 48 | +// @Description get Q Developer scopes |
| 49 | +// @Tags plugins/q_dev |
| 50 | +// @Param connectionId path int true "connection ID" |
| 51 | +// @Param pageSize query int false "page size" |
| 52 | +// @Param page query int false "page number" |
| 53 | +// @Param blueprints query bool false "include blueprint references" |
| 54 | +// @Success 200 {object} []ScopeDetail |
| 55 | +// @Failure 400 {object} shared.ApiBody "Bad Request" |
| 56 | +// @Failure 500 {object} shared.ApiBody "Internal Error" |
| 57 | +// @Router /plugins/q_dev/connections/{connectionId}/scopes [GET] |
| 58 | +func GetScopeList(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { |
| 59 | + return dsHelper.ScopeApi.GetPage(input) |
| 60 | +} |
| 61 | + |
| 62 | +// GetScope returns a single scope record |
| 63 | +// @Summary get a Q Developer scope |
| 64 | +// @Description get a Q Developer scope |
| 65 | +// @Tags plugins/q_dev |
| 66 | +// @Param connectionId path int true "connection ID" |
| 67 | +// @Param scopeId path string true "scope id" |
| 68 | +// @Param blueprints query bool false "include blueprint references" |
| 69 | +// @Success 200 {object} ScopeDetail |
| 70 | +// @Failure 400 {object} shared.ApiBody "Bad Request" |
| 71 | +// @Failure 500 {object} shared.ApiBody "Internal Error" |
| 72 | +// @Router /plugins/q_dev/connections/{connectionId}/scopes/{scopeId} [GET] |
| 73 | +func GetScope(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { |
| 74 | + return dsHelper.ScopeApi.GetScopeDetail(input) |
| 75 | +} |
| 76 | + |
| 77 | +// PatchScope updates a scope record |
| 78 | +// @Summary patch a Q Developer scope |
| 79 | +// @Description patch a Q Developer scope |
| 80 | +// @Tags plugins/q_dev |
| 81 | +// @Accept application/json |
| 82 | +// @Param connectionId path int true "connection ID" |
| 83 | +// @Param scopeId path string true "scope id" |
| 84 | +// @Param scope body models.QDevS3Slice true "json" |
| 85 | +// @Success 200 {object} models.QDevS3Slice |
| 86 | +// @Failure 400 {object} shared.ApiBody "Bad Request" |
| 87 | +// @Failure 500 {object} shared.ApiBody "Internal Error" |
| 88 | +// @Router /plugins/q_dev/connections/{connectionId}/scopes/{scopeId} [PATCH] |
| 89 | +func PatchScope(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { |
| 90 | + return dsHelper.ScopeApi.Patch(input) |
| 91 | +} |
| 92 | + |
| 93 | +// DeleteScope removes a scope and optionally associated data. |
| 94 | +// @Summary delete a Q Developer scope |
| 95 | +// @Description delete Q Developer scope data |
| 96 | +// @Tags plugins/q_dev |
| 97 | +// @Param connectionId path int true "connection ID" |
| 98 | +// @Param scopeId path string true "scope id" |
| 99 | +// @Param delete_data_only query bool false "Only delete scope data" |
| 100 | +// @Success 200 |
| 101 | +// @Failure 400 {object} shared.ApiBody "Bad Request" |
| 102 | +// @Failure 409 {object} srvhelper.DsRefs "References exist to this scope" |
| 103 | +// @Failure 500 {object} shared.ApiBody "Internal Error" |
| 104 | +// @Router /plugins/q_dev/connections/{connectionId}/scopes/{scopeId} [DELETE] |
| 105 | +func DeleteScope(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { |
| 106 | + return dsHelper.ScopeApi.Delete(input) |
| 107 | +} |
| 108 | + |
| 109 | +// GetScopeLatestSyncState returns scope sync state info |
| 110 | +// @Summary latest sync state for a Q Developer scope |
| 111 | +// @Description get latest sync state for a Q Developer scope |
| 112 | +// @Tags plugins/q_dev |
| 113 | +// @Param connectionId path int true "connection ID" |
| 114 | +// @Param scopeId path string true "scope id" |
| 115 | +// @Success 200 |
| 116 | +// @Failure 400 {object} shared.ApiBody "Bad Request" |
| 117 | +// @Failure 500 {object} shared.ApiBody "Internal Error" |
| 118 | +// @Router /plugins/q_dev/connections/{connectionId}/scopes/{scopeId}/latest-sync-state [GET] |
| 119 | +func GetScopeLatestSyncState(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { |
| 120 | + return dsHelper.ScopeApi.GetScopeLatestSyncState(input) |
| 121 | +} |
0 commit comments