From 28d2bddfdcb57e2d2f44fff2808e27522b208dc4 Mon Sep 17 00:00:00 2001 From: Mist Gitlab Runner Date: Thu, 20 May 2021 03:03:55 +0000 Subject: [PATCH] Regenerate mist-cli after: Update RapiDoc --- mist-api-v2.go | 808 ++++++++++++++++++++++++------------------------- 1 file changed, 404 insertions(+), 404 deletions(-) diff --git a/mist-api-v2.go b/mist-api-v2.go index 111145d..b69ea53 100644 --- a/mist-api-v2.go +++ b/mist-api-v2.go @@ -82,9 +82,9 @@ func getToken() (string, error) { return cli.Creds.GetString("contexts." + mistContext + ".api_key"), nil } -// MistApiV2ListClouds List clouds -func MistApiV2ListClouds(params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { - handlerPath := "list-clouds" +// MistApiV2AddCloud Add cloud +func MistApiV2AddCloud(params *viper.Viper, body string) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { + handlerPath := "add-cloud" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -101,31 +101,10 @@ func MistApiV2ListClouds(params *viper.Viper) (*gentleman.Response, map[string]i url := server + "/api/v2/clouds" - req := cli.Client.Get().URL(url) + req := cli.Client.Post().URL(url) - paramSearch := params.GetString("search") - if paramSearch != "" { - req = req.AddQuery("search", fmt.Sprintf("%v", paramSearch)) - } - paramSort := params.GetString("sort") - if paramSort != "" { - req = req.AddQuery("sort", fmt.Sprintf("%v", paramSort)) - } - paramStart := params.GetString("start") - if paramStart != "" { - req = req.AddQuery("start", fmt.Sprintf("%v", paramStart)) - } - paramLimit := params.GetInt64("limit") - if paramLimit != 0 { - req = req.AddQuery("limit", fmt.Sprintf("%v", paramLimit)) - } - paramOnly := params.GetString("only") - if paramOnly != "" { - req = req.AddQuery("only", fmt.Sprintf("%v", paramOnly)) - } - paramDeref := params.GetString("deref") - if paramDeref != "" { - req = req.AddQuery("deref", fmt.Sprintf("%v", paramDeref)) + if body != "" { + req = req.AddHeader("Content-Type", "application/json").BodyString(body) } cli.HandleBefore(handlerPath, params, req) @@ -150,12 +129,12 @@ func MistApiV2ListClouds(params *viper.Viper) (*gentleman.Response, map[string]i decoded = after.(map[string]interface{}) } - return resp, decoded, cli.CLIOutputOptions{[]string{"name", "provider", "tags"}, []string{"id", "name", "provider", "tags", "owned_by", "created_by"}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil } -// MistApiV2AddCloud Add cloud -func MistApiV2AddCloud(params *viper.Viper, body string) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { - handlerPath := "add-cloud" +// MistApiV2ListClouds List clouds +func MistApiV2ListClouds(params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { + handlerPath := "list-clouds" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -172,10 +151,31 @@ func MistApiV2AddCloud(params *viper.Viper, body string) (*gentleman.Response, m url := server + "/api/v2/clouds" - req := cli.Client.Post().URL(url) + req := cli.Client.Get().URL(url) - if body != "" { - req = req.AddHeader("Content-Type", "application/json").BodyString(body) + paramSearch := params.GetString("search") + if paramSearch != "" { + req = req.AddQuery("search", fmt.Sprintf("%v", paramSearch)) + } + paramSort := params.GetString("sort") + if paramSort != "" { + req = req.AddQuery("sort", fmt.Sprintf("%v", paramSort)) + } + paramStart := params.GetString("start") + if paramStart != "" { + req = req.AddQuery("start", fmt.Sprintf("%v", paramStart)) + } + paramLimit := params.GetInt64("limit") + if paramLimit != 0 { + req = req.AddQuery("limit", fmt.Sprintf("%v", paramLimit)) + } + paramOnly := params.GetString("only") + if paramOnly != "" { + req = req.AddQuery("only", fmt.Sprintf("%v", paramOnly)) + } + paramDeref := params.GetString("deref") + if paramDeref != "" { + req = req.AddQuery("deref", fmt.Sprintf("%v", paramDeref)) } cli.HandleBefore(handlerPath, params, req) @@ -200,12 +200,12 @@ func MistApiV2AddCloud(params *viper.Viper, body string) (*gentleman.Response, m decoded = after.(map[string]interface{}) } - return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{"name", "provider", "tags"}, []string{"id", "name", "provider", "tags", "owned_by", "created_by"}}, nil } -// MistApiV2DeleteCloud Delete cloud -func MistApiV2DeleteCloud(paramCloud string, params *viper.Viper) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { - handlerPath := "delete-cloud" +// MistApiV2GetCloud Get cloud +func MistApiV2GetCloud(paramCloud string, params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { + handlerPath := "get-cloud" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -223,7 +223,20 @@ func MistApiV2DeleteCloud(paramCloud string, params *viper.Viper) (*gentleman.Re url := server + "/api/v2/clouds/{cloud}" url = strings.Replace(url, "{cloud}", paramCloud, 1) - req := cli.Client.Delete().URL(url) + req := cli.Client.Get().URL(url) + + paramSort := params.GetString("sort") + if paramSort != "" { + req = req.AddQuery("sort", fmt.Sprintf("%v", paramSort)) + } + paramOnly := params.GetString("only") + if paramOnly != "" { + req = req.AddQuery("only", fmt.Sprintf("%v", paramOnly)) + } + paramDeref := params.GetString("deref") + if paramDeref != "" { + req = req.AddQuery("deref", fmt.Sprintf("%v", paramDeref)) + } cli.HandleBefore(handlerPath, params, req) @@ -232,7 +245,7 @@ func MistApiV2DeleteCloud(paramCloud string, params *viper.Viper) (*gentleman.Re return nil, nil, cli.CLIOutputOptions{}, errors.Wrap(err, "Request failed") } - var decoded interface{} + var decoded map[string]interface{} if resp.StatusCode < 400 { if err := cli.UnmarshalResponse(resp, &decoded); err != nil { @@ -244,15 +257,15 @@ func MistApiV2DeleteCloud(paramCloud string, params *viper.Viper) (*gentleman.Re after := cli.HandleAfter(handlerPath, params, resp, decoded) if after != nil { - decoded = after + decoded = after.(map[string]interface{}) } - return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{"name", "provider", "tags"}, []string{"id", "name", "provider", "tags", "owned_by", "created_by"}}, nil } -// MistApiV2GetCloud Get cloud -func MistApiV2GetCloud(paramCloud string, params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { - handlerPath := "get-cloud" +// MistApiV2EditCloud Edit cloud +func MistApiV2EditCloud(paramCloud string, params *viper.Viper, body string) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { + handlerPath := "edit-cloud" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -270,19 +283,10 @@ func MistApiV2GetCloud(paramCloud string, params *viper.Viper) (*gentleman.Respo url := server + "/api/v2/clouds/{cloud}" url = strings.Replace(url, "{cloud}", paramCloud, 1) - req := cli.Client.Get().URL(url) + req := cli.Client.Put().URL(url) - paramSort := params.GetString("sort") - if paramSort != "" { - req = req.AddQuery("sort", fmt.Sprintf("%v", paramSort)) - } - paramOnly := params.GetString("only") - if paramOnly != "" { - req = req.AddQuery("only", fmt.Sprintf("%v", paramOnly)) - } - paramDeref := params.GetString("deref") - if paramDeref != "" { - req = req.AddQuery("deref", fmt.Sprintf("%v", paramDeref)) + if body != "" { + req = req.AddHeader("Content-Type", "application/json").BodyString(body) } cli.HandleBefore(handlerPath, params, req) @@ -292,7 +296,7 @@ func MistApiV2GetCloud(paramCloud string, params *viper.Viper) (*gentleman.Respo return nil, nil, cli.CLIOutputOptions{}, errors.Wrap(err, "Request failed") } - var decoded map[string]interface{} + var decoded interface{} if resp.StatusCode < 400 { if err := cli.UnmarshalResponse(resp, &decoded); err != nil { @@ -304,15 +308,15 @@ func MistApiV2GetCloud(paramCloud string, params *viper.Viper) (*gentleman.Respo after := cli.HandleAfter(handlerPath, params, resp, decoded) if after != nil { - decoded = after.(map[string]interface{}) + decoded = after } - return resp, decoded, cli.CLIOutputOptions{[]string{"name", "provider", "tags"}, []string{"id", "name", "provider", "tags", "owned_by", "created_by"}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil } -// MistApiV2EditCloud Edit cloud -func MistApiV2EditCloud(paramCloud string, params *viper.Viper, body string) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { - handlerPath := "edit-cloud" +// MistApiV2DeleteCloud Delete cloud +func MistApiV2DeleteCloud(paramCloud string, params *viper.Viper) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { + handlerPath := "delete-cloud" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -330,11 +334,7 @@ func MistApiV2EditCloud(paramCloud string, params *viper.Viper, body string) (*g url := server + "/api/v2/clouds/{cloud}" url = strings.Replace(url, "{cloud}", paramCloud, 1) - req := cli.Client.Put().URL(url) - - if body != "" { - req = req.AddHeader("Content-Type", "application/json").BodyString(body) - } + req := cli.Client.Delete().URL(url) cli.HandleBefore(handlerPath, params, req) @@ -613,9 +613,9 @@ func MistApiV2AddKey(params *viper.Viper, body string) (*gentleman.Response, map return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil } -// MistApiV2EditKey Edit key -func MistApiV2EditKey(paramKey string, params *viper.Viper, body string) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { - handlerPath := "edit-key" +// MistApiV2DeleteKey Delete key +func MistApiV2DeleteKey(paramKey string, params *viper.Viper) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { + handlerPath := "delete-key" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -633,20 +633,7 @@ func MistApiV2EditKey(paramKey string, params *viper.Viper, body string) (*gentl url := server + "/api/v2/keys/{key}" url = strings.Replace(url, "{key}", paramKey, 1) - req := cli.Client.Put().URL(url) - - paramName := params.GetString("name") - if paramName != "" { - req = req.AddQuery("name", fmt.Sprintf("%v", paramName)) - } - paramDefault := params.GetBool("default") - if paramDefault != false { - req = req.AddQuery("default", fmt.Sprintf("%v", paramDefault)) - } - - if body != "" { - req = req.AddHeader("Content-Type", "").BodyString(body) - } + req := cli.Client.Delete().URL(url) cli.HandleBefore(handlerPath, params, req) @@ -673,9 +660,9 @@ func MistApiV2EditKey(paramKey string, params *viper.Viper, body string) (*gentl return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil } -// MistApiV2DeleteKey Delete key -func MistApiV2DeleteKey(paramKey string, params *viper.Viper) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { - handlerPath := "delete-key" +// MistApiV2GetKey Get key +func MistApiV2GetKey(paramKey string, params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { + handlerPath := "get-key" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -693,7 +680,24 @@ func MistApiV2DeleteKey(paramKey string, params *viper.Viper) (*gentleman.Respon url := server + "/api/v2/keys/{key}" url = strings.Replace(url, "{key}", paramKey, 1) - req := cli.Client.Delete().URL(url) + req := cli.Client.Get().URL(url) + + paramPrivate := params.GetBool("private") + if paramPrivate != false { + req = req.AddQuery("private", fmt.Sprintf("%v", paramPrivate)) + } + paramSort := params.GetString("sort") + if paramSort != "" { + req = req.AddQuery("sort", fmt.Sprintf("%v", paramSort)) + } + paramOnly := params.GetString("only") + if paramOnly != "" { + req = req.AddQuery("only", fmt.Sprintf("%v", paramOnly)) + } + paramDeref := params.GetString("deref") + if paramDeref != "" { + req = req.AddQuery("deref", fmt.Sprintf("%v", paramDeref)) + } cli.HandleBefore(handlerPath, params, req) @@ -702,7 +706,7 @@ func MistApiV2DeleteKey(paramKey string, params *viper.Viper) (*gentleman.Respon return nil, nil, cli.CLIOutputOptions{}, errors.Wrap(err, "Request failed") } - var decoded interface{} + var decoded map[string]interface{} if resp.StatusCode < 400 { if err := cli.UnmarshalResponse(resp, &decoded); err != nil { @@ -714,15 +718,15 @@ func MistApiV2DeleteKey(paramKey string, params *viper.Viper) (*gentleman.Respon after := cli.HandleAfter(handlerPath, params, resp, decoded) if after != nil { - decoded = after + decoded = after.(map[string]interface{}) } - return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{"name", "default", "tags"}, []string{"id", "name", "default", "tags", "owned_by", "created_by"}}, nil } -// MistApiV2GetKey Get key -func MistApiV2GetKey(paramKey string, params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { - handlerPath := "get-key" +// MistApiV2EditKey Edit key +func MistApiV2EditKey(paramKey string, params *viper.Viper, body string) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { + handlerPath := "edit-key" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -740,23 +744,19 @@ func MistApiV2GetKey(paramKey string, params *viper.Viper) (*gentleman.Response, url := server + "/api/v2/keys/{key}" url = strings.Replace(url, "{key}", paramKey, 1) - req := cli.Client.Get().URL(url) + req := cli.Client.Put().URL(url) - paramPrivate := params.GetBool("private") - if paramPrivate != false { - req = req.AddQuery("private", fmt.Sprintf("%v", paramPrivate)) - } - paramSort := params.GetString("sort") - if paramSort != "" { - req = req.AddQuery("sort", fmt.Sprintf("%v", paramSort)) + paramName := params.GetString("name") + if paramName != "" { + req = req.AddQuery("name", fmt.Sprintf("%v", paramName)) } - paramOnly := params.GetString("only") - if paramOnly != "" { - req = req.AddQuery("only", fmt.Sprintf("%v", paramOnly)) + paramDefault := params.GetBool("default") + if paramDefault != false { + req = req.AddQuery("default", fmt.Sprintf("%v", paramDefault)) } - paramDeref := params.GetString("deref") - if paramDeref != "" { - req = req.AddQuery("deref", fmt.Sprintf("%v", paramDeref)) + + if body != "" { + req = req.AddHeader("Content-Type", "").BodyString(body) } cli.HandleBefore(handlerPath, params, req) @@ -766,7 +766,7 @@ func MistApiV2GetKey(paramKey string, params *viper.Viper) (*gentleman.Response, return nil, nil, cli.CLIOutputOptions{}, errors.Wrap(err, "Request failed") } - var decoded map[string]interface{} + var decoded interface{} if resp.StatusCode < 400 { if err := cli.UnmarshalResponse(resp, &decoded); err != nil { @@ -778,10 +778,10 @@ func MistApiV2GetKey(paramKey string, params *viper.Viper) (*gentleman.Response, after := cli.HandleAfter(handlerPath, params, resp, decoded) if after != nil { - decoded = after.(map[string]interface{}) + decoded = after } - return resp, decoded, cli.CLIOutputOptions{[]string{"name", "default", "tags"}, []string{"id", "name", "default", "tags", "owned_by", "created_by"}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil } // MistApiV2ListLocations List locations @@ -2328,9 +2328,9 @@ func MistApiV2AddRule(paramQueries string, paramWindow string, paramFrequency st return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil } -// MistApiV2ToggleRule Toggle rule -func MistApiV2ToggleRule(paramRule string, paramAction string, params *viper.Viper, body string) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { - handlerPath := "toggle-rule" +// MistApiV2GetRule Get rule +func MistApiV2GetRule(paramRule string, params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { + handlerPath := "get-rule" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -2348,12 +2348,15 @@ func MistApiV2ToggleRule(paramRule string, paramAction string, params *viper.Vip url := server + "/api/v2/rules/{rule}" url = strings.Replace(url, "{rule}", paramRule, 1) - req := cli.Client.Put().URL(url) - - req = req.AddQuery("action", paramAction) + req := cli.Client.Get().URL(url) - if body != "" { - req = req.AddHeader("Content-Type", "").BodyString(body) + paramSort := params.GetString("sort") + if paramSort != "" { + req = req.AddQuery("sort", fmt.Sprintf("%v", paramSort)) + } + paramOnly := params.GetString("only") + if paramOnly != "" { + req = req.AddQuery("only", fmt.Sprintf("%v", paramOnly)) } cli.HandleBefore(handlerPath, params, req) @@ -2363,7 +2366,7 @@ func MistApiV2ToggleRule(paramRule string, paramAction string, params *viper.Vip return nil, nil, cli.CLIOutputOptions{}, errors.Wrap(err, "Request failed") } - var decoded interface{} + var decoded map[string]interface{} if resp.StatusCode < 400 { if err := cli.UnmarshalResponse(resp, &decoded); err != nil { @@ -2375,15 +2378,15 @@ func MistApiV2ToggleRule(paramRule string, paramAction string, params *viper.Vip after := cli.HandleAfter(handlerPath, params, resp, decoded) if after != nil { - decoded = after + decoded = after.(map[string]interface{}) } - return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{"title", "queries", "actions", "tags"}, []string{"id", "title", "resource_type", "selectors", "queries", "actions", "window", "frequency", "tags"}}, nil } -// MistApiV2DeleteRule Delete rule -func MistApiV2DeleteRule(paramRule string, params *viper.Viper) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { - handlerPath := "delete-rule" +// MistApiV2RenameRule Rename rule +func MistApiV2RenameRule(paramRule string, paramAction string, params *viper.Viper, body string) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { + handlerPath := "rename-rule" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -2401,7 +2404,13 @@ func MistApiV2DeleteRule(paramRule string, params *viper.Viper) (*gentleman.Resp url := server + "/api/v2/rules/{rule}" url = strings.Replace(url, "{rule}", paramRule, 1) - req := cli.Client.Delete().URL(url) + req := cli.Client.Patch().URL(url) + + req = req.AddQuery("action", paramAction) + + if body != "" { + req = req.AddHeader("Content-Type", "").BodyString(body) + } cli.HandleBefore(handlerPath, params, req) @@ -2428,9 +2437,9 @@ func MistApiV2DeleteRule(paramRule string, params *viper.Viper) (*gentleman.Resp return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil } -// MistApiV2GetRule Get rule -func MistApiV2GetRule(paramRule string, params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { - handlerPath := "get-rule" +// MistApiV2UpdateRule Update rule +func MistApiV2UpdateRule(paramRule string, params *viper.Viper, body string) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { + handlerPath := "update-rule" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -2448,15 +2457,35 @@ func MistApiV2GetRule(paramRule string, params *viper.Viper) (*gentleman.Respons url := server + "/api/v2/rules/{rule}" url = strings.Replace(url, "{rule}", paramRule, 1) - req := cli.Client.Get().URL(url) + req := cli.Client.Post().URL(url) - paramSort := params.GetString("sort") - if paramSort != "" { - req = req.AddQuery("sort", fmt.Sprintf("%v", paramSort)) + paramQueries := params.GetString("queries") + if paramQueries != "" { + req = req.AddQuery("queries", fmt.Sprintf("%v", paramQueries)) } - paramOnly := params.GetString("only") - if paramOnly != "" { - req = req.AddQuery("only", fmt.Sprintf("%v", paramOnly)) + paramWindow := params.GetString("window") + if paramWindow != "" { + req = req.AddQuery("window", fmt.Sprintf("%v", paramWindow)) + } + paramFrequency := params.GetString("frequency") + if paramFrequency != "" { + req = req.AddQuery("frequency", fmt.Sprintf("%v", paramFrequency)) + } + paramTriggerAfter := params.GetString("trigger-after") + if paramTriggerAfter != "" { + req = req.AddQuery("trigger_after", fmt.Sprintf("%v", paramTriggerAfter)) + } + paramActions := params.GetString("actions") + if paramActions != "" { + req = req.AddQuery("actions", fmt.Sprintf("%v", paramActions)) + } + paramSelectors := params.GetString("selectors") + if paramSelectors != "" { + req = req.AddQuery("selectors", fmt.Sprintf("%v", paramSelectors)) + } + + if body != "" { + req = req.AddHeader("Content-Type", "").BodyString(body) } cli.HandleBefore(handlerPath, params, req) @@ -2481,12 +2510,12 @@ func MistApiV2GetRule(paramRule string, params *viper.Viper) (*gentleman.Respons decoded = after.(map[string]interface{}) } - return resp, decoded, cli.CLIOutputOptions{[]string{"title", "queries", "actions", "tags"}, []string{"id", "title", "resource_type", "selectors", "queries", "actions", "window", "frequency", "tags"}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil } -// MistApiV2RenameRule Rename rule -func MistApiV2RenameRule(paramRule string, paramAction string, params *viper.Viper, body string) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { - handlerPath := "rename-rule" +// MistApiV2ToggleRule Toggle rule +func MistApiV2ToggleRule(paramRule string, paramAction string, params *viper.Viper, body string) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { + handlerPath := "toggle-rule" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -2504,7 +2533,7 @@ func MistApiV2RenameRule(paramRule string, paramAction string, params *viper.Vip url := server + "/api/v2/rules/{rule}" url = strings.Replace(url, "{rule}", paramRule, 1) - req := cli.Client.Patch().URL(url) + req := cli.Client.Put().URL(url) req = req.AddQuery("action", paramAction) @@ -2537,9 +2566,9 @@ func MistApiV2RenameRule(paramRule string, paramAction string, params *viper.Vip return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil } -// MistApiV2UpdateRule Update rule -func MistApiV2UpdateRule(paramRule string, params *viper.Viper, body string) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { - handlerPath := "update-rule" +// MistApiV2DeleteRule Delete rule +func MistApiV2DeleteRule(paramRule string, params *viper.Viper) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { + handlerPath := "delete-rule" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -2557,36 +2586,7 @@ func MistApiV2UpdateRule(paramRule string, params *viper.Viper, body string) (*g url := server + "/api/v2/rules/{rule}" url = strings.Replace(url, "{rule}", paramRule, 1) - req := cli.Client.Post().URL(url) - - paramQueries := params.GetString("queries") - if paramQueries != "" { - req = req.AddQuery("queries", fmt.Sprintf("%v", paramQueries)) - } - paramWindow := params.GetString("window") - if paramWindow != "" { - req = req.AddQuery("window", fmt.Sprintf("%v", paramWindow)) - } - paramFrequency := params.GetString("frequency") - if paramFrequency != "" { - req = req.AddQuery("frequency", fmt.Sprintf("%v", paramFrequency)) - } - paramTriggerAfter := params.GetString("trigger-after") - if paramTriggerAfter != "" { - req = req.AddQuery("trigger_after", fmt.Sprintf("%v", paramTriggerAfter)) - } - paramActions := params.GetString("actions") - if paramActions != "" { - req = req.AddQuery("actions", fmt.Sprintf("%v", paramActions)) - } - paramSelectors := params.GetString("selectors") - if paramSelectors != "" { - req = req.AddQuery("selectors", fmt.Sprintf("%v", paramSelectors)) - } - - if body != "" { - req = req.AddHeader("Content-Type", "").BodyString(body) - } + req := cli.Client.Delete().URL(url) cli.HandleBefore(handlerPath, params, req) @@ -2595,7 +2595,7 @@ func MistApiV2UpdateRule(paramRule string, params *viper.Viper, body string) (*g return nil, nil, cli.CLIOutputOptions{}, errors.Wrap(err, "Request failed") } - var decoded map[string]interface{} + var decoded interface{} if resp.StatusCode < 400 { if err := cli.UnmarshalResponse(resp, &decoded); err != nil { @@ -2607,7 +2607,7 @@ func MistApiV2UpdateRule(paramRule string, params *viper.Viper, body string) (*g after := cli.HandleAfter(handlerPath, params, resp, decoded) if after != nil { - decoded = after.(map[string]interface{}) + decoded = after } return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil @@ -2978,9 +2978,9 @@ func MistApiV2GetSize(paramSize string, params *viper.Viper) (*gentleman.Respons return resp, decoded, cli.CLIOutputOptions{[]string{"name", "cloud"}, []string{"id", "name", "cloud", "locations", "external_id", "machines"}}, nil } -// MistApiV2ListVolumes List volumes -func MistApiV2ListVolumes(params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { - handlerPath := "list-volumes" +// MistApiV2CreateVolume Create volume +func MistApiV2CreateVolume(params *viper.Viper, body string) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { + handlerPath := "create-volume" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -2997,35 +2997,10 @@ func MistApiV2ListVolumes(params *viper.Viper) (*gentleman.Response, map[string] url := server + "/api/v2/volumes" - req := cli.Client.Get().URL(url) + req := cli.Client.Post().URL(url) - paramCloud := params.GetString("cloud") - if paramCloud != "" { - req = req.AddQuery("cloud", fmt.Sprintf("%v", paramCloud)) - } - paramSearch := params.GetString("search") - if paramSearch != "" { - req = req.AddQuery("search", fmt.Sprintf("%v", paramSearch)) - } - paramSort := params.GetString("sort") - if paramSort != "" { - req = req.AddQuery("sort", fmt.Sprintf("%v", paramSort)) - } - paramStart := params.GetString("start") - if paramStart != "" { - req = req.AddQuery("start", fmt.Sprintf("%v", paramStart)) - } - paramLimit := params.GetInt64("limit") - if paramLimit != 0 { - req = req.AddQuery("limit", fmt.Sprintf("%v", paramLimit)) - } - paramOnly := params.GetString("only") - if paramOnly != "" { - req = req.AddQuery("only", fmt.Sprintf("%v", paramOnly)) - } - paramDeref := params.GetString("deref") - if paramDeref != "" { - req = req.AddQuery("deref", fmt.Sprintf("%v", paramDeref)) + if body != "" { + req = req.AddHeader("Content-Type", "application/json").BodyString(body) } cli.HandleBefore(handlerPath, params, req) @@ -3050,12 +3025,12 @@ func MistApiV2ListVolumes(params *viper.Viper) (*gentleman.Response, map[string] decoded = after.(map[string]interface{}) } - return resp, decoded, cli.CLIOutputOptions{[]string{"name", "size", "cloud", "location", "attached_to", "tags"}, []string{"id", "name", "size", "cloud", "location", "external_id", "attached_to", "tags", "owned_by", "created_by"}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil } -// MistApiV2CreateVolume Create volume -func MistApiV2CreateVolume(params *viper.Viper, body string) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { - handlerPath := "create-volume" +// MistApiV2ListVolumes List volumes +func MistApiV2ListVolumes(params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { + handlerPath := "list-volumes" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -3072,10 +3047,35 @@ func MistApiV2CreateVolume(params *viper.Viper, body string) (*gentleman.Respons url := server + "/api/v2/volumes" - req := cli.Client.Post().URL(url) + req := cli.Client.Get().URL(url) - if body != "" { - req = req.AddHeader("Content-Type", "application/json").BodyString(body) + paramCloud := params.GetString("cloud") + if paramCloud != "" { + req = req.AddQuery("cloud", fmt.Sprintf("%v", paramCloud)) + } + paramSearch := params.GetString("search") + if paramSearch != "" { + req = req.AddQuery("search", fmt.Sprintf("%v", paramSearch)) + } + paramSort := params.GetString("sort") + if paramSort != "" { + req = req.AddQuery("sort", fmt.Sprintf("%v", paramSort)) + } + paramStart := params.GetString("start") + if paramStart != "" { + req = req.AddQuery("start", fmt.Sprintf("%v", paramStart)) + } + paramLimit := params.GetInt64("limit") + if paramLimit != 0 { + req = req.AddQuery("limit", fmt.Sprintf("%v", paramLimit)) + } + paramOnly := params.GetString("only") + if paramOnly != "" { + req = req.AddQuery("only", fmt.Sprintf("%v", paramOnly)) + } + paramDeref := params.GetString("deref") + if paramDeref != "" { + req = req.AddQuery("deref", fmt.Sprintf("%v", paramDeref)) } cli.HandleBefore(handlerPath, params, req) @@ -3100,7 +3100,7 @@ func MistApiV2CreateVolume(params *viper.Viper, body string) (*gentleman.Respons decoded = after.(map[string]interface{}) } - return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{"name", "size", "cloud", "location", "attached_to", "tags"}, []string{"id", "name", "size", "cloud", "location", "external_id", "attached_to", "tags", "owned_by", "created_by"}}, nil } // MistApiV2GetVolume Get volume @@ -3215,9 +3215,9 @@ func MistApiV2EditVolume(paramVolume string, params *viper.Viper, body string) ( return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil } -// MistApiV2CreateZone Create zone -func MistApiV2CreateZone(params *viper.Viper, body string) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { - handlerPath := "create-zone" +// MistApiV2ListZones List zones +func MistApiV2ListZones(params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { + handlerPath := "list-zones" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -3234,10 +3234,35 @@ func MistApiV2CreateZone(params *viper.Viper, body string) (*gentleman.Response, url := server + "/api/v2/zones" - req := cli.Client.Post().URL(url) + req := cli.Client.Get().URL(url) - if body != "" { - req = req.AddHeader("Content-Type", "application/json").BodyString(body) + paramCloud := params.GetString("cloud") + if paramCloud != "" { + req = req.AddQuery("cloud", fmt.Sprintf("%v", paramCloud)) + } + paramSearch := params.GetString("search") + if paramSearch != "" { + req = req.AddQuery("search", fmt.Sprintf("%v", paramSearch)) + } + paramSort := params.GetString("sort") + if paramSort != "" { + req = req.AddQuery("sort", fmt.Sprintf("%v", paramSort)) + } + paramStart := params.GetString("start") + if paramStart != "" { + req = req.AddQuery("start", fmt.Sprintf("%v", paramStart)) + } + paramLimit := params.GetInt64("limit") + if paramLimit != 0 { + req = req.AddQuery("limit", fmt.Sprintf("%v", paramLimit)) + } + paramOnly := params.GetString("only") + if paramOnly != "" { + req = req.AddQuery("only", fmt.Sprintf("%v", paramOnly)) + } + paramDeref := params.GetString("deref") + if paramDeref != "" { + req = req.AddQuery("deref", fmt.Sprintf("%v", paramDeref)) } cli.HandleBefore(handlerPath, params, req) @@ -3262,12 +3287,12 @@ func MistApiV2CreateZone(params *viper.Viper, body string) (*gentleman.Response, decoded = after.(map[string]interface{}) } - return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{"name", "cloud", "machines", "tags"}, []string{"id", "name", "cloud", "external_id", "machines", "tags", "owned_by", "created_by"}}, nil } -// MistApiV2ListZones List zones -func MistApiV2ListZones(params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { - handlerPath := "list-zones" +// MistApiV2CreateZone Create zone +func MistApiV2CreateZone(params *viper.Viper, body string) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { + handlerPath := "create-zone" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -3284,35 +3309,10 @@ func MistApiV2ListZones(params *viper.Viper) (*gentleman.Response, map[string]in url := server + "/api/v2/zones" - req := cli.Client.Get().URL(url) + req := cli.Client.Post().URL(url) - paramCloud := params.GetString("cloud") - if paramCloud != "" { - req = req.AddQuery("cloud", fmt.Sprintf("%v", paramCloud)) - } - paramSearch := params.GetString("search") - if paramSearch != "" { - req = req.AddQuery("search", fmt.Sprintf("%v", paramSearch)) - } - paramSort := params.GetString("sort") - if paramSort != "" { - req = req.AddQuery("sort", fmt.Sprintf("%v", paramSort)) - } - paramStart := params.GetString("start") - if paramStart != "" { - req = req.AddQuery("start", fmt.Sprintf("%v", paramStart)) - } - paramLimit := params.GetInt64("limit") - if paramLimit != 0 { - req = req.AddQuery("limit", fmt.Sprintf("%v", paramLimit)) - } - paramOnly := params.GetString("only") - if paramOnly != "" { - req = req.AddQuery("only", fmt.Sprintf("%v", paramOnly)) - } - paramDeref := params.GetString("deref") - if paramDeref != "" { - req = req.AddQuery("deref", fmt.Sprintf("%v", paramDeref)) + if body != "" { + req = req.AddHeader("Content-Type", "application/json").BodyString(body) } cli.HandleBefore(handlerPath, params, req) @@ -3337,7 +3337,7 @@ func MistApiV2ListZones(params *viper.Viper) (*gentleman.Response, map[string]in decoded = after.(map[string]interface{}) } - return resp, decoded, cli.CLIOutputOptions{[]string{"name", "cloud", "machines", "tags"}, []string{"id", "name", "cloud", "external_id", "machines", "tags", "owned_by", "created_by"}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}}, nil } // MistApiV2GetZone Get zone @@ -3467,48 +3467,6 @@ func mistApiV2Register(subcommand bool) { cli.Root.Long = cli.Markdown("") } - func() { - params := viper.New() - - var examples string - - cmd := &cobra.Command{ - Use: "list-clouds", - Short: "List clouds", - Long: cli.Markdown("List clouds owned by the active org. READ permission required on cloud."), - Example: examples, - Group: "clouds", - Args: cobra.MinimumNArgs(0), - Run: func(cmd *cobra.Command, args []string) { - - _, decoded, outputOptions, err := MistApiV2ListClouds(params) - if err != nil { - logger.Fatalf("Error calling operation: %s", err.Error()) - } - - if err := cli.Formatter.Format(decoded, outputOptions); err != nil { - logger.Fatalf("Formatting failed: %s", err.Error()) - } - - }, - } - root.AddCommand(cmd) - - cmd.Flags().String("search", "", "Only return results matching search filter") - cmd.Flags().String("sort", "", "Order results by") - cmd.Flags().String("start", "", "Start results from index or id") - cmd.Flags().Int64("limit", 0, "Limit number of results, 1000 max") - cmd.Flags().String("only", "", "Only return these fields") - cmd.Flags().String("deref", "", "Dereference foreign keys") - - cli.SetCustomFlags(cmd) - - if cmd.Flags().HasFlags() { - params.BindPFlags(cmd.Flags()) - } - - }() - func() { params := viper.New() @@ -3554,15 +3512,15 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "delete-cloud cloud", - Short: "Delete cloud", - Long: cli.Markdown("Delete target cloud"), + Use: "list-clouds", + Short: "List clouds", + Long: cli.Markdown("List clouds owned by the active org. READ permission required on cloud."), Example: examples, Group: "clouds", - Args: cobra.MinimumNArgs(1), + Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { - _, decoded, outputOptions, err := MistApiV2DeleteCloud(args[0], params) + _, decoded, outputOptions, err := MistApiV2ListClouds(params) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -3575,6 +3533,13 @@ func mistApiV2Register(subcommand bool) { } root.AddCommand(cmd) + cmd.Flags().String("search", "", "Only return results matching search filter") + cmd.Flags().String("sort", "", "Order results by") + cmd.Flags().String("start", "", "Start results from index or id") + cmd.Flags().Int64("limit", 0, "Limit number of results, 1000 max") + cmd.Flags().String("only", "", "Only return these fields") + cmd.Flags().String("deref", "", "Dereference foreign keys") + cli.SetCustomFlags(cmd) if cmd.Flags().HasFlags() { @@ -3661,6 +3626,41 @@ func mistApiV2Register(subcommand bool) { }() + func() { + params := viper.New() + + var examples string + + cmd := &cobra.Command{ + Use: "delete-cloud cloud", + Short: "Delete cloud", + Long: cli.Markdown("Delete target cloud"), + Example: examples, + Group: "clouds", + Args: cobra.MinimumNArgs(1), + Run: func(cmd *cobra.Command, args []string) { + + _, decoded, outputOptions, err := MistApiV2DeleteCloud(args[0], params) + if err != nil { + logger.Fatalf("Error calling operation: %s", err.Error()) + } + + if err := cli.Formatter.Format(decoded, outputOptions); err != nil { + logger.Fatalf("Formatting failed: %s", err.Error()) + } + + }, + } + root.AddCommand(cmd) + + cli.SetCustomFlags(cmd) + + if cmd.Flags().HasFlags() { + params.BindPFlags(cmd.Flags()) + } + + }() + func() { params := viper.New() @@ -3829,19 +3829,15 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "edit-key key", - Short: "Edit key", - Long: cli.Markdown("Edit target key"), + Use: "delete-key key", + Short: "Delete key", + Long: cli.Markdown("Delete target key"), Example: examples, Group: "keys", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - body, err := cli.GetBody("", args[1:]) - if err != nil { - logger.Fatalf("Unable to get body: %s", err.Error()) - } - _, decoded, outputOptions, err := MistApiV2EditKey(args[0], params, body) + _, decoded, outputOptions, err := MistApiV2DeleteKey(args[0], params) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -3854,9 +3850,6 @@ func mistApiV2Register(subcommand bool) { } root.AddCommand(cmd) - cmd.Flags().String("name", "", "New key name") - cmd.Flags().String("default", "", "Set as default") - cli.SetCustomFlags(cmd) if cmd.Flags().HasFlags() { @@ -3871,15 +3864,15 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "delete-key key", - Short: "Delete key", - Long: cli.Markdown("Delete target key"), + Use: "get-key key", + Short: "Get key", + Long: cli.Markdown("Get details about target key"), Example: examples, Group: "keys", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - _, decoded, outputOptions, err := MistApiV2DeleteKey(args[0], params) + _, decoded, outputOptions, err := MistApiV2GetKey(args[0], params) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -3892,6 +3885,11 @@ func mistApiV2Register(subcommand bool) { } root.AddCommand(cmd) + cmd.Flags().String("private", "", "Return the private key. Requires READ_PRIVATE permission on key.") + cmd.Flags().String("sort", "", "Order results by") + cmd.Flags().String("only", "", "Only return these fields") + cmd.Flags().String("deref", "", "Dereference foreign keys") + cli.SetCustomFlags(cmd) if cmd.Flags().HasFlags() { @@ -3906,15 +3904,19 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "get-key key", - Short: "Get key", - Long: cli.Markdown("Get details about target key"), + Use: "edit-key key", + Short: "Edit key", + Long: cli.Markdown("Edit target key"), Example: examples, Group: "keys", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { + body, err := cli.GetBody("", args[1:]) + if err != nil { + logger.Fatalf("Unable to get body: %s", err.Error()) + } - _, decoded, outputOptions, err := MistApiV2GetKey(args[0], params) + _, decoded, outputOptions, err := MistApiV2EditKey(args[0], params, body) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -3927,10 +3929,8 @@ func mistApiV2Register(subcommand bool) { } root.AddCommand(cmd) - cmd.Flags().String("private", "", "Return the private key. Requires READ_PRIVATE permission on key.") - cmd.Flags().String("sort", "", "Order results by") - cmd.Flags().String("only", "", "Only return these fields") - cmd.Flags().String("deref", "", "Dereference foreign keys") + cmd.Flags().String("name", "", "New key name") + cmd.Flags().String("default", "", "Set as default") cli.SetCustomFlags(cmd) @@ -5045,19 +5045,15 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "toggle-rule rule action", - Short: "Toggle rule", - Long: cli.Markdown("Enable or disable a rule"), + Use: "get-rule rule", + Short: "Get rule", + Long: cli.Markdown("Get details about target rule"), Example: examples, Group: "rules", - Args: cobra.MinimumNArgs(2), + Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - body, err := cli.GetBody("", args[2:]) - if err != nil { - logger.Fatalf("Unable to get body: %s", err.Error()) - } - _, decoded, outputOptions, err := MistApiV2ToggleRule(args[0], args[1], params, body) + _, decoded, outputOptions, err := MistApiV2GetRule(args[0], params) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -5070,6 +5066,9 @@ func mistApiV2Register(subcommand bool) { } root.AddCommand(cmd) + cmd.Flags().String("sort", "", "Order results by") + cmd.Flags().String("only", "", "Only return these fields") + cli.SetCustomFlags(cmd) if cmd.Flags().HasFlags() { @@ -5084,15 +5083,19 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "delete-rule rule", - Short: "Delete rule", - Long: cli.Markdown("Delete a rule given its UUID."), + Use: "rename-rule rule action", + Short: "Rename rule", + Long: cli.Markdown("Rename a rule"), Example: examples, Group: "rules", - Args: cobra.MinimumNArgs(1), + Args: cobra.MinimumNArgs(2), Run: func(cmd *cobra.Command, args []string) { + body, err := cli.GetBody("", args[2:]) + if err != nil { + logger.Fatalf("Unable to get body: %s", err.Error()) + } - _, decoded, outputOptions, err := MistApiV2DeleteRule(args[0], params) + _, decoded, outputOptions, err := MistApiV2RenameRule(args[0], args[1], params, body) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -5119,15 +5122,19 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "get-rule rule", - Short: "Get rule", - Long: cli.Markdown("Get details about target rule"), + Use: "update-rule rule", + Short: "Update rule", + Long: cli.Markdown("Update a rule given its UUID, EDIT permission required on rule"), Example: examples, Group: "rules", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { + body, err := cli.GetBody("", args[1:]) + if err != nil { + logger.Fatalf("Unable to get body: %s", err.Error()) + } - _, decoded, outputOptions, err := MistApiV2GetRule(args[0], params) + _, decoded, outputOptions, err := MistApiV2UpdateRule(args[0], params, body) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -5140,8 +5147,12 @@ func mistApiV2Register(subcommand bool) { } root.AddCommand(cmd) - cmd.Flags().String("sort", "", "Order results by") - cmd.Flags().String("only", "", "Only return these fields") + cmd.Flags().String("queries", "", "") + cmd.Flags().String("window", "", "") + cmd.Flags().String("frequency", "", "") + cmd.Flags().String("trigger-after", "", "") + cmd.Flags().String("actions", "", "") + cmd.Flags().String("selectors", "", "") cli.SetCustomFlags(cmd) @@ -5157,9 +5168,9 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "rename-rule rule action", - Short: "Rename rule", - Long: cli.Markdown("Rename a rule"), + Use: "toggle-rule rule action", + Short: "Toggle rule", + Long: cli.Markdown("Enable or disable a rule"), Example: examples, Group: "rules", Args: cobra.MinimumNArgs(2), @@ -5169,7 +5180,7 @@ func mistApiV2Register(subcommand bool) { logger.Fatalf("Unable to get body: %s", err.Error()) } - _, decoded, outputOptions, err := MistApiV2RenameRule(args[0], args[1], params, body) + _, decoded, outputOptions, err := MistApiV2ToggleRule(args[0], args[1], params, body) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -5196,19 +5207,15 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "update-rule rule", - Short: "Update rule", - Long: cli.Markdown("Update a rule given its UUID, EDIT permission required on rule"), + Use: "delete-rule rule", + Short: "Delete rule", + Long: cli.Markdown("Delete a rule given its UUID."), Example: examples, Group: "rules", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - body, err := cli.GetBody("", args[1:]) - if err != nil { - logger.Fatalf("Unable to get body: %s", err.Error()) - } - _, decoded, outputOptions, err := MistApiV2UpdateRule(args[0], params, body) + _, decoded, outputOptions, err := MistApiV2DeleteRule(args[0], params) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -5221,13 +5228,6 @@ func mistApiV2Register(subcommand bool) { } root.AddCommand(cmd) - cmd.Flags().String("queries", "", "") - cmd.Flags().String("window", "", "") - cmd.Flags().String("frequency", "", "") - cmd.Flags().String("trigger-after", "", "") - cmd.Flags().String("actions", "", "") - cmd.Flags().String("selectors", "", "") - cli.SetCustomFlags(cmd) if cmd.Flags().HasFlags() { @@ -5480,15 +5480,19 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "list-volumes", - Short: "List volumes", - Long: cli.Markdown("List volumes owned by the active org. READ permission required on volume & cloud."), + Use: "create-volume", + Short: "Create volume", + Long: cli.Markdown("Creates one or more volumes on the specified cloud. If async is true, a jobId will be returned. READ permission required on cloud. CREATE_RESOURCES permission required on cloud. READ permission required on location. CREATE_RESOURCES permission required on location. CREATE permission required on volume.\n## Request Schema (application/json)\n\nproperties:\n cloud:\n description: Specify cloud to provision on\n type: string\n dry:\n description: Return provisioning plan and exit without executing it\n type: boolean\n extra:\n description: Configure additional parameters\n type: object\n location:\n description: Where to provision e.g. region, datacenter, rack\n type: string\n name:\n description: Specify volume name\n type: string\n provider:\n $ref: '#/components/schemas/SupportedProviders'\n quantity:\n description: Provision multiple volumes of this type\n type: number\n save:\n description: Save provisioning plan as template\n type: boolean\n size:\n description: Volume sizing spec\n type: object\n tags:\n description: Assign tags to provisioned volume\n type: object\n template:\n type: object\nrequired:\n- name\n- size\ntype: object\n"), Example: examples, Group: "volumes", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { + body, err := cli.GetBody("application/json", args[0:]) + if err != nil { + logger.Fatalf("Unable to get body: %s", err.Error()) + } - _, decoded, outputOptions, err := MistApiV2ListVolumes(params) + _, decoded, outputOptions, err := MistApiV2CreateVolume(params, body) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -5501,14 +5505,6 @@ func mistApiV2Register(subcommand bool) { } root.AddCommand(cmd) - cmd.Flags().String("cloud", "", "") - cmd.Flags().String("search", "", "Only return results matching search filter") - cmd.Flags().String("sort", "", "Order results by") - cmd.Flags().String("start", "", "Start results from index or id") - cmd.Flags().Int64("limit", 0, "Limit number of results, 1000 max") - cmd.Flags().String("only", "", "Only return these fields") - cmd.Flags().String("deref", "", "Dereference foreign keys") - cli.SetCustomFlags(cmd) if cmd.Flags().HasFlags() { @@ -5523,19 +5519,15 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "create-volume", - Short: "Create volume", - Long: cli.Markdown("Creates one or more volumes on the specified cloud. If async is true, a jobId will be returned. READ permission required on cloud. CREATE_RESOURCES permission required on cloud. READ permission required on location. CREATE_RESOURCES permission required on location. CREATE permission required on volume.\n## Request Schema (application/json)\n\nproperties:\n cloud:\n description: Specify cloud to provision on\n type: string\n dry:\n description: Return provisioning plan and exit without executing it\n type: boolean\n extra:\n description: Configure additional parameters\n type: object\n location:\n description: Where to provision e.g. region, datacenter, rack\n type: string\n name:\n description: Specify volume name\n type: string\n provider:\n $ref: '#/components/schemas/SupportedProviders'\n quantity:\n description: Provision multiple volumes of this type\n type: number\n save:\n description: Save provisioning plan as template\n type: boolean\n size:\n description: Volume sizing spec\n type: object\n tags:\n description: Assign tags to provisioned volume\n type: object\n template:\n type: object\nrequired:\n- name\n- size\ntype: object\n"), + Use: "list-volumes", + Short: "List volumes", + Long: cli.Markdown("List volumes owned by the active org. READ permission required on volume & cloud."), Example: examples, Group: "volumes", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { - body, err := cli.GetBody("application/json", args[0:]) - if err != nil { - logger.Fatalf("Unable to get body: %s", err.Error()) - } - _, decoded, outputOptions, err := MistApiV2CreateVolume(params, body) + _, decoded, outputOptions, err := MistApiV2ListVolumes(params) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -5548,6 +5540,14 @@ func mistApiV2Register(subcommand bool) { } root.AddCommand(cmd) + cmd.Flags().String("cloud", "", "") + cmd.Flags().String("search", "", "Only return results matching search filter") + cmd.Flags().String("sort", "", "Order results by") + cmd.Flags().String("start", "", "Start results from index or id") + cmd.Flags().Int64("limit", 0, "Limit number of results, 1000 max") + cmd.Flags().String("only", "", "Only return these fields") + cmd.Flags().String("deref", "", "Dereference foreign keys") + cli.SetCustomFlags(cmd) if cmd.Flags().HasFlags() { @@ -5641,19 +5641,15 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "create-zone", - Short: "Create zone", - Long: cli.Markdown("Creates one or more zones on the specified cloud. If async is true, a jobId will be returned. READ permission required on cloud. CREATE_RESOURCES permission required on cloud. CREATE permission required on zone.\n## Request Schema (application/json)\n\nproperties:\n cloud:\n description: Specify cloud to provision on\n type: string\n dry:\n description: Return provisioning plan and exit without executing it\n type: boolean\n extra:\n description: Configure additional parameters\n type: object\n name:\n description: Specify zone name\n type: string\n save:\n description: Save provisioning plan as template\n type: boolean\n tags:\n description: Assign tags to provisioned zone\n type: object\n template:\n type: object\nrequired:\n- name\n- cloud\ntype: object\n"), + Use: "list-zones", + Short: "List zones", + Long: cli.Markdown("List zones owned by the active org. READ permission required on zone & cloud."), Example: examples, Group: "zones", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { - body, err := cli.GetBody("application/json", args[0:]) - if err != nil { - logger.Fatalf("Unable to get body: %s", err.Error()) - } - _, decoded, outputOptions, err := MistApiV2CreateZone(params, body) + _, decoded, outputOptions, err := MistApiV2ListZones(params) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -5666,6 +5662,14 @@ func mistApiV2Register(subcommand bool) { } root.AddCommand(cmd) + cmd.Flags().String("cloud", "", "") + cmd.Flags().String("search", "", "Only return results matching search filter") + cmd.Flags().String("sort", "", "Order results by") + cmd.Flags().String("start", "", "Start results from index or id") + cmd.Flags().Int64("limit", 0, "Limit number of results, 1000 max") + cmd.Flags().String("only", "", "Only return these fields") + cmd.Flags().String("deref", "", "Dereference foreign keys") + cli.SetCustomFlags(cmd) if cmd.Flags().HasFlags() { @@ -5680,15 +5684,19 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "list-zones", - Short: "List zones", - Long: cli.Markdown("List zones owned by the active org. READ permission required on zone & cloud."), + Use: "create-zone", + Short: "Create zone", + Long: cli.Markdown("Creates one or more zones on the specified cloud. If async is true, a jobId will be returned. READ permission required on cloud. CREATE_RESOURCES permission required on cloud. CREATE permission required on zone.\n## Request Schema (application/json)\n\nproperties:\n cloud:\n description: Specify cloud to provision on\n type: string\n dry:\n description: Return provisioning plan and exit without executing it\n type: boolean\n extra:\n description: Configure additional parameters\n type: object\n name:\n description: Specify zone name\n type: string\n save:\n description: Save provisioning plan as template\n type: boolean\n tags:\n description: Assign tags to provisioned zone\n type: object\n template:\n type: object\nrequired:\n- name\n- cloud\ntype: object\n"), Example: examples, Group: "zones", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { + body, err := cli.GetBody("application/json", args[0:]) + if err != nil { + logger.Fatalf("Unable to get body: %s", err.Error()) + } - _, decoded, outputOptions, err := MistApiV2ListZones(params) + _, decoded, outputOptions, err := MistApiV2CreateZone(params, body) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -5701,14 +5709,6 @@ func mistApiV2Register(subcommand bool) { } root.AddCommand(cmd) - cmd.Flags().String("cloud", "", "") - cmd.Flags().String("search", "", "Only return results matching search filter") - cmd.Flags().String("sort", "", "Order results by") - cmd.Flags().String("start", "", "Start results from index or id") - cmd.Flags().Int64("limit", 0, "Limit number of results, 1000 max") - cmd.Flags().String("only", "", "Only return these fields") - cmd.Flags().String("deref", "", "Dereference foreign keys") - cli.SetCustomFlags(cmd) if cmd.Flags().HasFlags() {