diff --git a/api/v2.0/legacy_swagger.yaml b/api/v2.0/legacy_swagger.yaml index f62762c5f..a1a45b1fd 100644 --- a/api/v2.0/legacy_swagger.yaml +++ b/api/v2.0/legacy_swagger.yaml @@ -1666,33 +1666,6 @@ paths: description: The resource does not exist. '500': description: Unexpected internal errors. - '/labels/{id}/resources': - get: - summary: Get the resources that the label is referenced by. - description: | - This endpoint let user get the resources that the label is referenced by. Only the replication policies are returned for now. - parameters: - - name: id - in: path - type: integer - format: int64 - required: true - description: Label ID - tags: - - Products - responses: - '200': - description: Get successfully. - schema: - $ref: '#/definitions/Resource' - '401': - description: User need to log in first. - '403': - description: Forbidden. - '404': - description: The resource does not exist. - '500': - description: Unexpected internal errors. /replication/adapters: get: summary: List supported adapters. @@ -5417,14 +5390,6 @@ definitions: ldap_group_dn: type: string description: The DN of the LDAP group if group type is 1 (LDAP group). - Resource: - type: object - properties: - replication_policies: - type: array - description: The replication policy list. - items: - $ref: '#/definitions/ReplicationPolicy' StringConfigItem: type: object properties: diff --git a/src/core/api/harborapi_test.go b/src/core/api/harborapi_test.go index 078a4a0e6..ed9e5d9ed 100644 --- a/src/core/api/harborapi_test.go +++ b/src/core/api/harborapi_test.go @@ -130,7 +130,6 @@ func init() { beego.Router("/api/email/ping", &EmailAPI{}, "post:Ping") beego.Router("/api/labels", &LabelAPI{}, "post:Post;get:List") beego.Router("/api/labels/:id([0-9]+", &LabelAPI{}, "get:Get;put:Put;delete:Delete") - beego.Router("/api/labels/:id([0-9]+)/resources", &LabelAPI{}, "get:ListResources") beego.Router("/api/ping", &SystemInfoAPI{}, "get:Ping") beego.Router("/api/system/gc/:id", &GCAPI{}, "get:GetGC") beego.Router("/api/system/gc/:id([0-9]+)/log", &GCAPI{}, "get:GetLog") diff --git a/src/core/api/label.go b/src/core/api/label.go index db4636078..8bd04df5d 100644 --- a/src/core/api/label.go +++ b/src/core/api/label.go @@ -298,52 +298,3 @@ func (l *LabelAPI) Delete() { return } } - -// ListResources lists the resources that the label is referenced by -func (l *LabelAPI) ListResources() { - id, err := l.GetInt64FromPath(":id") - if err != nil || id <= 0 { - l.SendBadRequestError(errors.New("invalid label ID")) - return - } - - label, err := dao.GetLabel(id) - if err != nil { - l.SendInternalServerError(fmt.Errorf("failed to get label %d: %v", id, err)) - return - } - - if label == nil || label.Deleted { - l.SendNotFoundError(fmt.Errorf("label %d not found", id)) - return - } - - if !l.requireAccess(label, rbac.ActionList, rbac.ResourceLabelResource) { - return - } - - /* - result, err := core.GlobalController.GetPolicies(rep_models.QueryParameter{}) - if err != nil { - l.HandleInternalServerError(fmt.Sprintf("failed to get policies: %v", err)) - return - } - policies := []*rep_models.ReplicationPolicy{} - if result != nil { - for _, policy := range result.Policies { - for _, filter := range policy.Filters { - if filter.Kind != replication.FilterItemKindLabel { - continue - } - if filter.Value.(int64) == label.ID { - policies = append(policies, policy) - } - } - } - } - */ - resources := map[string]interface{}{} - resources["replication_policies"] = nil - l.Data["json"] = resources - l.ServeJSON() -} diff --git a/src/server/v2.0/route/legacy.go b/src/server/v2.0/route/legacy.go index 61f6e77a5..24d63bd46 100755 --- a/src/server/v2.0/route/legacy.go +++ b/src/server/v2.0/route/legacy.go @@ -84,7 +84,6 @@ func registerLegacyRoutes() { beego.Router("/api/"+version+"/statistics", &api.StatisticAPI{}) beego.Router("/api/"+version+"/labels", &api.LabelAPI{}, "post:Post;get:List") beego.Router("/api/"+version+"/labels/:id([0-9]+)", &api.LabelAPI{}, "get:Get;put:Put;delete:Delete") - beego.Router("/api/"+version+"/labels/:id([0-9]+)/resources", &api.LabelAPI{}, "get:ListResources") beego.Router("/api/"+version+"/systeminfo", &api.SystemInfoAPI{}, "get:GetGeneralInfo") beego.Router("/api/"+version+"/systeminfo/volumes", &api.SystemInfoAPI{}, "get:GetVolumeInfo")