fix: recode project-role rpc handle to support group role assignment

results by user or project
This commit is contained in:
Qiu Jian
2020-09-09 18:17:53 +08:00
parent 6ea5995242
commit 332ba04bd1
13 changed files with 638 additions and 283 deletions
+34 -14
View File
@@ -23,20 +23,25 @@ import (
func init() {
type RoleAssignmentsOptions struct {
Effective bool `help:"Include role assignment of group members"`
System bool `help:"Include system user account"`
Policy bool `help:"Show matched policies"`
Domain string `help:"Role assignments for domain"`
User string `help:"For user"`
UserDomain string `help:"Domain for user"`
Group string `help:"For group"`
GroupDomain string `help:"Domain for group"`
Project string `help:"Role assignments for project"`
ProjectDomain string `help:"Domain for project"`
Role string `help:"Role assignments for role"`
RoleDomain string `help:"Domain for role"`
Limit int64 `help:"maximal returned number of rows"`
Offset int64 `help:"offset index of returned results"`
Effective bool `help:"Include role assignment of group members"`
System bool `help:"Include system user account"`
Policy bool `help:"Show matched policies"`
Domain string `help:"Role assignments for domain"`
User string `help:"For user"`
UserDomain string `help:"Domain for user"`
Group string `help:"For group"`
GroupDomain string `help:"Domain for group"`
Project string `help:"Role assignments for project"`
ProjectDomain string `help:"Domain for project"`
Role string `help:"Role assignments for role"`
RoleDomain string `help:"Domain for role"`
Limit int64 `help:"maximal returned number of rows"`
Offset int64 `help:"offset index of returned results"`
Users []string `help:"fitler by users id or name"`
Groups []string `help:"fitler by users id or name"`
Roles []string `help:"fitler by users id or name"`
Projects []string `help:"fitler by users id or name"`
Domains []string `help:"fitler by users id or name"`
}
R(&RoleAssignmentsOptions{}, "role-assignments", "List all role assignments", func(s *mcclient.ClientSession, args *RoleAssignmentsOptions) error {
query := jsonutils.NewDict()
@@ -85,6 +90,21 @@ func init() {
}
query.Add(jsonutils.NewString(rid), "role", "id")
}
if len(args.Users) > 0 {
query.Add(jsonutils.NewStringArray(args.Users), "users")
}
if len(args.Groups) > 0 {
query.Add(jsonutils.NewStringArray(args.Groups), "groups")
}
if len(args.Roles) > 0 {
query.Add(jsonutils.NewStringArray(args.Roles), "roles")
}
if len(args.Projects) > 0 {
query.Add(jsonutils.NewStringArray(args.Projects), "projects")
}
if len(args.Domains) > 0 {
query.Add(jsonutils.NewStringArray(args.Domains), "domains")
}
if args.Limit > 0 {
query.Add(jsonutils.NewInt(args.Limit), "limit")
}