Merge pull request #11126 from ywk253100/200318_label_resource

Remove the API to listing the resources that added with the specific label
This commit is contained in:
Wenkai Yin(尹文开) 2020-03-18 20:58:28 +08:00 committed by GitHub
commit c505c82d57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 86 deletions

View File

@ -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:

View File

@ -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")

View File

@ -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()
}

View File

@ -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")