From f44ae64773bc861250d1b6291acc969a90b00d53 Mon Sep 17 00:00:00 2001 From: zhengjiajie Date: Sat, 15 Sep 2018 19:25:48 +0800 Subject: [PATCH 1/7] 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 - }) } From 175f01e5c90e0d85372e50fc8cc6ea9cdface3f3 Mon Sep 17 00:00:00 2001 From: zhengjiajie Date: Sat, 15 Sep 2018 19:31:08 +0800 Subject: [PATCH 2/7] zhengjiajie modify list method --- cmd/climc/shell/res_results.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/climc/shell/res_results.go b/cmd/climc/shell/res_results.go index 78d1daa4f3..bd5e615f68 100644 --- a/cmd/climc/shell/res_results.go +++ b/cmd/climc/shell/res_results.go @@ -14,7 +14,7 @@ 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"` + Keys string `help:"keys of the query"` Texts string `help:"texts of the query"` ProjectId string `help:"project_id of the query"` } @@ -39,11 +39,11 @@ func init() { params.Add(jsonutils.NewString(args.EndDate), "end_date") } if len(args.Keys) > 0 { - params.Add(jsonutils.NewString(args.Keys), "keys") - } + params.Add(jsonutils.NewString(args.Keys), "keys") + } if len(args.Texts) > 0 { - params.Add(jsonutils.NewString(args.Texts), "texts") - } + params.Add(jsonutils.NewString(args.Texts), "texts") + } if len(args.ProjectId) > 0 { params.Add(jsonutils.NewString(args.ProjectId), "project_id") } From 94748d1cdcdb80c5ad4daca8d0226ddfd56363b2 Mon Sep 17 00:00:00 2001 From: zhengjiajie Date: Sat, 15 Sep 2018 19:41:35 +0800 Subject: [PATCH 3/7] modify params --- cmd/climc/shell/res_results.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cmd/climc/shell/res_results.go b/cmd/climc/shell/res_results.go index bd5e615f68..1fdc0ab779 100644 --- a/cmd/climc/shell/res_results.go +++ b/cmd/climc/shell/res_results.go @@ -14,8 +14,9 @@ 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"` + Export string `help:"export of the query"` + ExportKeys string `help:"export_keys of the query"` + ExportTexts string `help:"export_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 { @@ -38,11 +39,14 @@ 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.Export) > 0 { + params.Add(jsonutils.NewString(args.Export), "export") + } + if len(args.ExportKeys) > 0 { + params.Add(jsonutils.NewString(args.ExportKeys), "export_keys") } - if len(args.Texts) > 0 { - params.Add(jsonutils.NewString(args.Texts), "texts") + if len(args.ExportTexts) > 0 { + params.Add(jsonutils.NewString(args.ExportTexts), "export_texts") } if len(args.ProjectId) > 0 { params.Add(jsonutils.NewString(args.ProjectId), "project_id") From 04aaf351322df8528dde2f34374e183b29c9472a Mon Sep 17 00:00:00 2001 From: zhengjiajie Date: Sat, 15 Sep 2018 19:44:27 +0800 Subject: [PATCH 4/7] modify fmt --- cmd/climc/shell/res_results.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/climc/shell/res_results.go b/cmd/climc/shell/res_results.go index 1fdc0ab779..19fb101b98 100644 --- a/cmd/climc/shell/res_results.go +++ b/cmd/climc/shell/res_results.go @@ -40,8 +40,8 @@ func init() { params.Add(jsonutils.NewString(args.EndDate), "end_date") } if len(args.Export) > 0 { - params.Add(jsonutils.NewString(args.Export), "export") - } + params.Add(jsonutils.NewString(args.Export), "export") + } if len(args.ExportKeys) > 0 { params.Add(jsonutils.NewString(args.ExportKeys), "export_keys") } From e686d2996dbf03ca87751332a8b2066b3c46573f Mon Sep 17 00:00:00 2001 From: zhengjiajie Date: Mon, 17 Sep 2018 11:33:45 +0800 Subject: [PATCH 5/7] zhengjiajie add param --- cmd/climc/shell/res_results.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/climc/shell/res_results.go b/cmd/climc/shell/res_results.go index 19fb101b98..876eaf5a6b 100644 --- a/cmd/climc/shell/res_results.go +++ b/cmd/climc/shell/res_results.go @@ -14,9 +14,11 @@ 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"` Export string `help:"export of the query"` - ExportKeys string `help:"export_keys of the query"` - ExportTexts string `help:"export_texts of the query"` + ExportKeys []string `help:"export_keys of the query"` + ExportTexts []string `help:"export_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 { @@ -39,14 +41,20 @@ 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.Export) > 0 { params.Add(jsonutils.NewString(args.Export), "export") } if len(args.ExportKeys) > 0 { - params.Add(jsonutils.NewString(args.ExportKeys), "export_keys") + params.Add(jsonutils.NewStringArray(args.ExportKeys), "export_keys") } if len(args.ExportTexts) > 0 { - params.Add(jsonutils.NewString(args.ExportTexts), "export_texts") + params.Add(jsonutils.NewStringArray(args.ExportTexts), "export_texts") } if len(args.ProjectId) > 0 { params.Add(jsonutils.NewString(args.ProjectId), "project_id") From 61868bcc9dfe932c829811413227d25f99719092 Mon Sep 17 00:00:00 2001 From: zhengjiajie Date: Mon, 17 Sep 2018 11:39:20 +0800 Subject: [PATCH 6/7] zhengjiajjie modify code --- cmd/climc/shell/res_results.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/climc/shell/res_results.go b/cmd/climc/shell/res_results.go index 876eaf5a6b..c5e809ff01 100644 --- a/cmd/climc/shell/res_results.go +++ b/cmd/climc/shell/res_results.go @@ -42,11 +42,11 @@ func init() { params.Add(jsonutils.NewString(args.EndDate), "end_date") } if len(args.ResType) > 0 { - params.Add(jsonutils.NewString(args.ResType), "res_type") - } + params.Add(jsonutils.NewString(args.ResType), "res_type") + } if len(args.Platform) > 0 { - params.Add(jsonutils.NewString(args.Platform), "platform") - } + params.Add(jsonutils.NewString(args.Platform), "platform") + } if len(args.Export) > 0 { params.Add(jsonutils.NewString(args.Export), "export") } From f653f2b4993b1e00263457e23baa0c31c109b3ad Mon Sep 17 00:00:00 2001 From: zhengjiajie Date: Tue, 18 Sep 2018 12:29:27 +0800 Subject: [PATCH 7/7] zhengjiajie delete old param --- cmd/climc/shell/res_results.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/cmd/climc/shell/res_results.go b/cmd/climc/shell/res_results.go index c5e809ff01..11ba29da1a 100644 --- a/cmd/climc/shell/res_results.go +++ b/cmd/climc/shell/res_results.go @@ -16,9 +16,6 @@ func init() { EndDate string `help:"end_date of the query"` ResType string `help:"res_type of the query"` Platform string `help:"platform of the query"` - Export string `help:"export of the query"` - ExportKeys []string `help:"export_keys of the query"` - ExportTexts []string `help:"export_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 { @@ -47,15 +44,6 @@ func init() { if len(args.Platform) > 0 { params.Add(jsonutils.NewString(args.Platform), "platform") } - if len(args.Export) > 0 { - params.Add(jsonutils.NewString(args.Export), "export") - } - if len(args.ExportKeys) > 0 { - params.Add(jsonutils.NewStringArray(args.ExportKeys), "export_keys") - } - if len(args.ExportTexts) > 0 { - params.Add(jsonutils.NewStringArray(args.ExportTexts), "export_texts") - } if len(args.ProjectId) > 0 { params.Add(jsonutils.NewString(args.ProjectId), "project_id") }