From f44ae64773bc861250d1b6291acc969a90b00d53 Mon Sep 17 00:00:00 2001 From: zhengjiajie Date: Sat, 15 Sep 2018 19:25:48 +0800 Subject: [PATCH] zhengjiajie modify list method --- cmd/climc/shell/res_results.go | 47 ++++++---------------------------- 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/cmd/climc/shell/res_results.go b/cmd/climc/shell/res_results.go index c64c29f218..78d1daa4f3 100644 --- a/cmd/climc/shell/res_results.go +++ b/cmd/climc/shell/res_results.go @@ -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"` + Keys string `help:"keys of the query"` + Texts string `help:"texts 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.Keys) > 0 { + params.Add(jsonutils.NewString(args.Keys), "keys") + } + if len(args.Texts) > 0 { + params.Add(jsonutils.NewString(args.Texts), "texts") + } 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 - }) }