Merge pull request #221 in YUNIONIO/onecloud from ~ZHENGJIAJIE/onecloud:feature/meter-resource-query-export to release/2.2.0

* commit 'f653f2b4993b1e00263457e23baa0c31c109b3ad':
  zhengjiajie delete old param
  zhengjiajjie modify code
  zhengjiajie add param
  modify fmt
  modify params
  zhengjiajie modify list method
  zhengjiajie modify list method
This commit is contained in:
邱剑
2018-09-18 12:30:29 +08:00
+8 -39
View File
@@ -14,6 +14,8 @@ func init() {
StatMonth string `help:"stat_month of the query"`
StartDate string `help:"start_date of the query"`
EndDate string `help:"end_date of the query"`
ResType string `help:"res_type of the query"`
Platform string `help:"platform of the query"`
ProjectId string `help:"project_id of the query"`
}
R(&ResResultsListOptions{}, "resresult-list", "List all res results ", func(s *mcclient.ClientSession, args *ResResultsListOptions) error {
@@ -36,6 +38,12 @@ func init() {
if len(args.EndDate) > 0 {
params.Add(jsonutils.NewString(args.EndDate), "end_date")
}
if len(args.ResType) > 0 {
params.Add(jsonutils.NewString(args.ResType), "res_type")
}
if len(args.Platform) > 0 {
params.Add(jsonutils.NewString(args.Platform), "platform")
}
if len(args.ProjectId) > 0 {
params.Add(jsonutils.NewString(args.ProjectId), "project_id")
}
@@ -48,43 +56,4 @@ func init() {
printList(result, modules.ResResults.GetColumns(s))
return nil
})
type ResResultUpdateOptions struct {
ID string `help:"ID of the query"`
StatMonth string `help:"stat_month of the query"`
StartDate string `help:"start_date of the query"`
EndDate string `help:"end_date of the query"`
ProjectId string `help:"project_id of the query"`
ItemKey string `help:"item_key of the query"`
ItemText string `help:"item_text of the query"`
}
R(&ResResultUpdateOptions{}, "resresult-export", "Update a resresult export", func(s *mcclient.ClientSession, args *ResResultUpdateOptions) error {
params := jsonutils.NewDict()
if len(args.StatMonth) > 0 {
params.Add(jsonutils.NewString(args.StatMonth), "stat_month")
}
if len(args.StartDate) > 0 {
params.Add(jsonutils.NewString(args.StartDate), "start_date")
}
if len(args.EndDate) > 0 {
params.Add(jsonutils.NewString(args.EndDate), "end_date")
}
if len(args.ProjectId) > 0 {
params.Add(jsonutils.NewString(args.ProjectId), "project_id")
}
if len(args.ItemKey) > 0 {
params.Add(jsonutils.NewString(args.ItemKey), "item_key")
}
if len(args.ItemText) > 0 {
params.Add(jsonutils.NewString(args.ItemText), "item_text")
}
resResult, err := modules.ResResults.Put(s, args.ID, params)
if err != nil {
return err
}
printObject(resResult)
return nil
})
}