fix: clouduser can_delete always be false

This commit is contained in:
Qu Xuan
2020-07-03 16:31:43 +08:00
parent 1ace096c5b
commit a54a9c05b1
6 changed files with 22 additions and 8 deletions

View File

@@ -28,6 +28,7 @@ func init() {
ClouduserId string `json:"clouduser_id"`
CloudpolicyId string `json:"cloudpolicy_id"`
Usable bool `json:"usable"`
}
R(&CloudgroupListOptions{}, "cloud-group-list", "List cloud groups", func(s *mcclient.ClientSession, opts *CloudgroupListOptions) error {
params, err := options.ListStructToParams(opts)

View File

@@ -80,6 +80,9 @@ type CloudgroupListInput struct {
// 根据权限过滤权限组
CloudpolicyId string `json:"cloudpolicy_id"`
// 是否可用
Usable *bool `json:"usable"`
}
type SCloudIdBaseResource struct {

View File

@@ -124,7 +124,8 @@ type MetadataResourceInfo struct {
type StatusDomainLevelUserResourceDetails struct {
StatusDomainLevelResourceDetails
UserResourceDetails
// 用户名称
OwnerName string `json:"owner_name"`
}
type UserResourceDetails struct {

View File

@@ -100,6 +100,11 @@ func (manager *SCloudgroupManager) ListItemFilter(ctx context.Context, q *sqlche
q = q.In("id", sq.SubQuery())
}
if query.Usable != nil && *query.Usable {
sq := CloudaccountManager.Query("provider").SubQuery()
q = q.In("provider", sq)
}
return q, nil
}

View File

@@ -167,7 +167,7 @@ func (self *SQcloudClient) ListGroups(keyword string, page int, rp int) ([]SClou
if err != nil {
return nil, 0, errors.Wrap(err, "resp.Unmarshal")
}
total, _ := resp.Int("TotalNum")
total, _ := resp.Float("TotalNum")
return groups, int(total), nil
}
@@ -244,7 +244,7 @@ func (self *SQcloudClient) ListAttachedGroupPolicies(groupId int, page int, rp i
if err != nil {
return nil, 0, errors.Wrap(err, "resp.Unmarshal")
}
total, _ := resp.Int("TotalNum")
total, _ := resp.Float("TotalNum")
return policies, int(total), nil
}
@@ -269,7 +269,7 @@ func (self *SQcloudClient) ListGroupUsers(groupId int, page int, rp int) ([]SClo
if err != nil {
return nil, 0, errors.Wrap(err, "resp.Unmarshal")
}
total, _ := resp.Int("TotalNum")
total, _ := resp.Float("TotalNum")
return users, int(total), nil
}

View File

@@ -174,7 +174,7 @@ func (self *SQcloudClient) ListGroupsForUser(uin string, rp, page int) ([]SCloud
if err != nil {
return nil, 0, errors.Wrap(err, "resp.Unmarshal")
}
total, _ := resp.Int("TotalNum")
total, _ := resp.Float("TotalNum")
return groups, int(total), nil
}
@@ -271,11 +271,15 @@ func (policy *SClouduserPolicy) GetPolicyType() string {
}
func (policy *SClouduserPolicy) GetDescription() string {
if len(policy.Description) > 0 {
return policy.Description
}
p, err := policy.client.GetPolicy(policy.GetGlobalId())
if err != nil {
log.Errorf("failed to get policy %s description: %v", policy.PolicyName, err)
return p.Description
}
return ""
return p.Description
}
func (self *SQcloudClient) ListAttachedUserPolicies(uin string, page int, rp int) ([]SClouduserPolicy, int, error) {
@@ -299,7 +303,7 @@ func (self *SQcloudClient) ListAttachedUserPolicies(uin string, page int, rp int
if err != nil {
return nil, 0, errors.Wrap(err, "resp.Unmarshal")
}
total, _ := resp.Int("TotalNum")
total, _ := resp.Float("TotalNum")
return policies, int(total), nil
}
@@ -348,7 +352,7 @@ func (self *SQcloudClient) ListPolicies(keyword, scope string, page int, rp int)
if err != nil {
return nil, 0, errors.Wrap(err, "resp.Unmarshal")
}
total, _ := resp.Int("TotalNum")
total, _ := resp.Float("TotalNum")
return policies, int(total), nil
}