fix(region): add read only filter for account and provider (#19468)

This commit is contained in:
屈轩
2024-02-07 15:32:58 +08:00
committed by GitHub
parent c0779d8511
commit ca30e50585
7 changed files with 20 additions and 29 deletions
+3
View File
@@ -137,6 +137,7 @@ type CloudaccountResourceInfo struct {
AccountStatus string `json:"account_status,omitempty"`
// 云账号监控状态
AccountHealthStatus string `json:"account_health_status,omitempty"`
AccountReadOnly bool `json:"account_read_only,omitempty"`
}
type CloudaccountCreateInput struct {
@@ -259,6 +260,8 @@ type CloudaccountListInput struct {
// 账号健康状态
HealthStatus []string `json:"health_status"`
ReadOnly *bool `json:"read_only"`
// 共享模式
ShareMode []string `json:"share_mode"`
+2
View File
@@ -257,6 +257,8 @@ type CloudproviderListInput struct {
SyncableBaseResourceListInput
ReadOnly *bool `json:"read_only"`
// 账号健康状态
HealthStatus []string `json:"health_status"`
+4
View File
@@ -2089,6 +2089,10 @@ func (manager *SCloudaccountManager) ListItemFilter(
q = q.In("brand", query.Brands)
}
if query.ReadOnly != nil {
q = q.Equals("read_only", *query.ReadOnly)
}
return q, nil
}
+5
View File
@@ -1422,6 +1422,11 @@ func (manager *SCloudproviderManager) ListItemFilter(
q = q.In("id", subq.SubQuery())
}
if query.ReadOnly != nil {
sq := CloudaccountManager.Query("id").Equals("read_only", *query.ReadOnly).SubQuery()
q = q.In("cloudaccount_id", sq)
}
return q, nil
}
+1
View File
@@ -250,6 +250,7 @@ func (manager *SManagedResourceBaseManager) FetchCustomizeColumns(
rows[i].Account = account.Name
rows[i].AccountStatus = account.Status
rows[i].AccountHealthStatus = account.HealthStatus
rows[i].AccountReadOnly = account.ReadOnly
rows[i].Brand = account.Brand
rows[i].Provider = account.Provider
rows[i].CloudEnv = account.GetCloudEnv()
+1
View File
@@ -28,6 +28,7 @@ type CloudaccountListOptions struct {
BaseListOptions
Capability []string `help:"capability filter" choices:"project|compute|network|loadbalancer|objectstore|rds|cache|event|tablestore"`
ReadOnly *bool `help:"filter read only account" negative:"no-read-only"`
//DistinctField string `help:"distinct field"`
ProxySetting string `help:"Proxy setting id or name"`
// 按宿主机数量排序
+4 -29
View File
@@ -25,42 +25,17 @@ type CloudproviderListOptions struct {
Usable bool `help:"Vpc & Network usable"`
HasObjectStorage bool `help:"filter cloudproviders that has object storage"`
NoObjectStorage bool `help:"filter cloudproviders that has no object storage"`
HasObjectStorage bool `help:"filter cloudproviders that has object storage" negative:"no-object-storage"`
Capability []string `help:"capability filter" choices:"project|compute|network|loadbalancer|objectstore|rds|cache|event"`
Cloudregion string `help:"filter cloudproviders by cloudregion"`
ReadOnly *bool `help:"filter read only account" negative:"no-read-only"`
HostSchedtagId string `help:"filter by host schedtag"`
}
func (opts *CloudproviderListOptions) Params() (jsonutils.JSONObject, error) {
params, err := opts.BaseListOptions.Params()
if err != nil {
return nil, err
}
if opts.Usable {
params.Add(jsonutils.NewBool(true), "usable")
}
if opts.HasObjectStorage {
params.Add(jsonutils.JSONTrue, "has_object_storage")
} else if opts.NoObjectStorage {
params.Add(jsonutils.JSONFalse, "has_object_storage")
}
if len(opts.Capability) > 0 {
params.Add(jsonutils.NewStringArray(opts.Capability), "capability")
}
if len(opts.Cloudregion) > 0 {
params.Add(jsonutils.NewString(opts.Cloudregion), "cloudregion")
}
if len(opts.HostSchedtagId) > 0 {
params.Add(jsonutils.NewString(opts.HostSchedtagId), "host_schedtag_id")
}
return params, nil
return options.ListStructToParams(opts)
}
type CloudproviderUpdateOptions struct {