diff --git a/mist-api-v2.go b/mist-api-v2.go index f581273..79e35e3 100644 --- a/mist-api-v2.go +++ b/mist-api-v2.go @@ -978,9 +978,9 @@ func MistApiV2AddKey(params *viper.Viper, body string) (*gentleman.Response, map return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}, []string{}, []string{}}, nil } -// MistApiV2DeleteKey Delete key -func MistApiV2DeleteKey(paramKey string, params *viper.Viper) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { - handlerPath := "delete-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 } @@ -998,7 +998,20 @@ 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.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) + } cli.HandleBefore(handlerPath, params, req) @@ -1025,9 +1038,9 @@ func MistApiV2DeleteKey(paramKey string, params *viper.Viper) (*gentleman.Respon return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}, []string{}, []string{}}, nil } -// MistApiV2GetKey Get key -func MistApiV2GetKey(paramKey string, params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { - handlerPath := "get-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 } @@ -1045,24 +1058,7 @@ 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) - - 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)) - } + req := cli.Client.Delete().URL(url) cli.HandleBefore(handlerPath, params, req) @@ -1071,7 +1067,7 @@ func MistApiV2GetKey(paramKey string, params *viper.Viper) (*gentleman.Response, return resp, 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 { @@ -1083,15 +1079,15 @@ 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"}, []string{}, []string{}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}, []string{}, []string{}}, nil } -// MistApiV2EditKey Edit key -func MistApiV2EditKey(paramKey string, params *viper.Viper, body string) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { - handlerPath := "edit-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 } @@ -1109,19 +1105,23 @@ 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) + req := cli.Client.Get().URL(url) - paramName := params.GetString("name") - if paramName != "" { - req = req.AddQuery("name", fmt.Sprintf("%v", paramName)) + paramPrivate := params.GetBool("private") + if paramPrivate != false { + req = req.AddQuery("private", fmt.Sprintf("%v", paramPrivate)) } - paramDefault := params.GetBool("default") - if paramDefault != false { - req = req.AddQuery("default", fmt.Sprintf("%v", paramDefault)) + paramSort := params.GetString("sort") + if paramSort != "" { + req = req.AddQuery("sort", fmt.Sprintf("%v", paramSort)) } - - if body != "" { - req = req.AddHeader("Content-Type", "").BodyString(body) + 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) @@ -1131,7 +1131,7 @@ func MistApiV2EditKey(paramKey string, params *viper.Viper, body string) (*gentl return resp, 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 { @@ -1143,10 +1143,10 @@ func MistApiV2EditKey(paramKey string, params *viper.Viper, body string) (*gentl after := cli.HandleAfter(handlerPath, params, resp, decoded) if after != nil { - decoded = after + decoded = after.(map[string]interface{}) } - return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}, []string{}, []string{}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{"name", "default", "tags"}, []string{"id", "name", "default", "tags", "owned_by", "created_by"}, []string{}, []string{}}, nil } // MistApiV2ListLocations List locations @@ -2739,9 +2739,9 @@ func MistApiV2AddRule(params *viper.Viper, body string) (*gentleman.Response, ma return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}, []string{}, []string{}}, nil } -// MistApiV2EditRule Update rule -func MistApiV2EditRule(paramRule string, params *viper.Viper, body string) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { - handlerPath := "edit-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 } @@ -2759,11 +2759,7 @@ func MistApiV2EditRule(paramRule string, params *viper.Viper, body string) (*gen url := server + "/api/v2/rules/{rule}" url = strings.Replace(url, "{rule}", paramRule, 1) - req := cli.Client.Post().URL(url) - - if body != "" { - req = req.AddHeader("Content-Type", "application/json").BodyString(body) - } + req := cli.Client.Delete().URL(url) cli.HandleBefore(handlerPath, params, req) @@ -2772,7 +2768,7 @@ func MistApiV2EditRule(paramRule string, params *viper.Viper, body string) (*gen return resp, 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 { @@ -2784,15 +2780,15 @@ func MistApiV2EditRule(paramRule string, params *viper.Viper, body string) (*gen after := cli.HandleAfter(handlerPath, params, resp, decoded) if after != nil { - decoded = after.(map[string]interface{}) + decoded = after } return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}, []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 } @@ -2810,12 +2806,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) @@ -2825,7 +2824,7 @@ func MistApiV2ToggleRule(paramRule string, paramAction string, params *viper.Vip return resp, 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 { @@ -2837,15 +2836,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{}, []string{}, []string{}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{"name", "queries", "actions", "tags"}, []string{"id", "name", "resource_type", "selectors", "queries", "actions", "window", "frequency", "tags"}, []string{}, []string{}}, 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, paramName string, params *viper.Viper, body string) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { + handlerPath := "rename-rule" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -2863,7 +2862,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("name", paramName) + + if body != "" { + req = req.AddHeader("Content-Type", "").BodyString(body) + } cli.HandleBefore(handlerPath, params, req) @@ -2890,9 +2895,9 @@ func MistApiV2DeleteRule(paramRule string, params *viper.Viper) (*gentleman.Resp return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}, []string{}, []string{}}, nil } -// MistApiV2GetRule Get rule -func MistApiV2GetRule(paramRule string, params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { - handlerPath := "get-rule" +// MistApiV2EditRule Update rule +func MistApiV2EditRule(paramRule string, params *viper.Viper, body string) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { + handlerPath := "edit-rule" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -2910,15 +2915,10 @@ 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)) - } - paramOnly := params.GetString("only") - if paramOnly != "" { - req = req.AddQuery("only", fmt.Sprintf("%v", paramOnly)) + if body != "" { + req = req.AddHeader("Content-Type", "application/json").BodyString(body) } cli.HandleBefore(handlerPath, params, req) @@ -2943,12 +2943,12 @@ func MistApiV2GetRule(paramRule string, params *viper.Viper) (*gentleman.Respons decoded = after.(map[string]interface{}) } - return resp, decoded, cli.CLIOutputOptions{[]string{"name", "queries", "actions", "tags"}, []string{"id", "name", "resource_type", "selectors", "queries", "actions", "window", "frequency", "tags"}, []string{}, []string{}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}, []string{}, []string{}}, nil } -// MistApiV2RenameRule Rename rule -func MistApiV2RenameRule(paramRule string, paramName 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 } @@ -2966,9 +2966,9 @@ func MistApiV2RenameRule(paramRule string, paramName string, params *viper.Viper 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("name", paramName) + req = req.AddQuery("action", paramAction) if body != "" { req = req.AddHeader("Content-Type", "").BodyString(body) @@ -3120,9 +3120,9 @@ func MistApiV2AddScript(params *viper.Viper, body string) (*gentleman.Response, return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}, []string{}, []string{}}, nil } -// MistApiV2RunScript Run script -func MistApiV2RunScript(paramScript string, params *viper.Viper, body string) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { - handlerPath := "run-script" +// MistApiV2DeleteScript Delete script +func MistApiV2DeleteScript(paramScript string, params *viper.Viper) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { + handlerPath := "delete-script" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -3140,11 +3140,7 @@ func MistApiV2RunScript(paramScript string, params *viper.Viper, body string) (* url := server + "/api/v2/scripts/{script}" url = strings.Replace(url, "{script}", paramScript, 1) - req := cli.Client.Post().URL(url) - - if body != "" { - req = req.AddHeader("Content-Type", "application/json").BodyString(body) - } + req := cli.Client.Delete().URL(url) cli.HandleBefore(handlerPath, params, req) @@ -3153,7 +3149,7 @@ func MistApiV2RunScript(paramScript string, params *viper.Viper, body string) (* return resp, 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 { @@ -3165,15 +3161,15 @@ func MistApiV2RunScript(paramScript string, params *viper.Viper, body string) (* after := cli.HandleAfter(handlerPath, params, resp, decoded) if after != nil { - decoded = after.(map[string]interface{}) + decoded = after } return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}, []string{}, []string{}}, nil } -// MistApiV2EditScript Edit script -func MistApiV2EditScript(paramScript string, params *viper.Viper, body string) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { - handlerPath := "edit-script" +// MistApiV2GetScript Get script +func MistApiV2GetScript(paramScript string, params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { + handlerPath := "get-script" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -3191,19 +3187,15 @@ func MistApiV2EditScript(paramScript string, params *viper.Viper, body string) ( url := server + "/api/v2/scripts/{script}" url = strings.Replace(url, "{script}", paramScript, 1) - req := cli.Client.Put().URL(url) + req := cli.Client.Get().URL(url) - paramName := params.GetString("name") - if paramName != "" { - req = req.AddQuery("name", fmt.Sprintf("%v", paramName)) - } - paramDescription := params.GetString("description") - if paramDescription != "" { - req = req.AddQuery("description", fmt.Sprintf("%v", paramDescription)) + paramOnly := params.GetString("only") + if paramOnly != "" { + req = req.AddQuery("only", fmt.Sprintf("%v", paramOnly)) } - - if body != "" { - req = req.AddHeader("Content-Type", "").BodyString(body) + paramDeref := params.GetString("deref") + if paramDeref != "" { + req = req.AddQuery("deref", fmt.Sprintf("%v", paramDeref)) } cli.HandleBefore(handlerPath, params, req) @@ -3213,7 +3205,7 @@ func MistApiV2EditScript(paramScript string, params *viper.Viper, body string) ( return resp, 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 { @@ -3225,15 +3217,15 @@ func MistApiV2EditScript(paramScript string, params *viper.Viper, body string) ( after := cli.HandleAfter(handlerPath, params, resp, decoded) if after != nil { - decoded = after + decoded = after.(map[string]interface{}) } - return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}, []string{}, []string{}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{"name", "tags"}, []string{"id", "name", "description", "tags", "owned_by", "created_by"}, []string{}, []string{}}, nil } -// MistApiV2DeleteScript Delete script -func MistApiV2DeleteScript(paramScript string, params *viper.Viper) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { - handlerPath := "delete-script" +// MistApiV2RunScript Run script +func MistApiV2RunScript(paramScript string, params *viper.Viper, body string) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { + handlerPath := "run-script" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -3251,7 +3243,11 @@ func MistApiV2DeleteScript(paramScript string, params *viper.Viper) (*gentleman. url := server + "/api/v2/scripts/{script}" url = strings.Replace(url, "{script}", paramScript, 1) - req := cli.Client.Delete().URL(url) + req := cli.Client.Post().URL(url) + + if body != "" { + req = req.AddHeader("Content-Type", "application/json").BodyString(body) + } cli.HandleBefore(handlerPath, params, req) @@ -3260,7 +3256,7 @@ func MistApiV2DeleteScript(paramScript string, params *viper.Viper) (*gentleman. return resp, 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 { @@ -3272,15 +3268,15 @@ func MistApiV2DeleteScript(paramScript string, params *viper.Viper) (*gentleman. after := cli.HandleAfter(handlerPath, params, resp, decoded) if after != nil { - decoded = after + decoded = after.(map[string]interface{}) } return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}, []string{}, []string{}}, nil } -// MistApiV2GetScript Get script -func MistApiV2GetScript(paramScript string, params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { - handlerPath := "get-script" +// MistApiV2EditScript Edit script +func MistApiV2EditScript(paramScript string, params *viper.Viper, body string) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { + handlerPath := "edit-script" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -3298,15 +3294,19 @@ func MistApiV2GetScript(paramScript string, params *viper.Viper) (*gentleman.Res url := server + "/api/v2/scripts/{script}" url = strings.Replace(url, "{script}", paramScript, 1) - req := cli.Client.Get().URL(url) + req := cli.Client.Put().URL(url) - paramOnly := params.GetString("only") - if paramOnly != "" { - req = req.AddQuery("only", fmt.Sprintf("%v", paramOnly)) + paramName := params.GetString("name") + if paramName != "" { + req = req.AddQuery("name", fmt.Sprintf("%v", paramName)) } - paramDeref := params.GetString("deref") - if paramDeref != "" { - req = req.AddQuery("deref", fmt.Sprintf("%v", paramDeref)) + paramDescription := params.GetString("description") + if paramDescription != "" { + req = req.AddQuery("description", fmt.Sprintf("%v", paramDescription)) + } + + if body != "" { + req = req.AddHeader("Content-Type", "").BodyString(body) } cli.HandleBefore(handlerPath, params, req) @@ -3316,7 +3316,7 @@ func MistApiV2GetScript(paramScript string, params *viper.Viper) (*gentleman.Res return resp, 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 { @@ -3328,10 +3328,10 @@ func MistApiV2GetScript(paramScript string, params *viper.Viper) (*gentleman.Res after := cli.HandleAfter(handlerPath, params, resp, decoded) if after != nil { - decoded = after.(map[string]interface{}) + decoded = after } - return resp, decoded, cli.CLIOutputOptions{[]string{"name", "tags"}, []string{"id", "name", "description", "tags", "owned_by", "created_by"}, []string{}, []string{}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}, []string{}, []string{}}, nil } // MistApiV2DownloadScript Download script @@ -3755,9 +3755,9 @@ func MistApiV2CreateVolume(params *viper.Viper, body string) (*gentleman.Respons return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}, []string{}, []string{}}, nil } -// MistApiV2DeleteVolume Delete volume -func MistApiV2DeleteVolume(paramVolume string, params *viper.Viper) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { - handlerPath := "delete-volume" +// MistApiV2GetVolume Get volume +func MistApiV2GetVolume(paramVolume string, params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { + handlerPath := "get-volume" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -3775,7 +3775,16 @@ func MistApiV2DeleteVolume(paramVolume string, params *viper.Viper) (*gentleman. url := server + "/api/v2/volumes/{volume}" url = strings.Replace(url, "{volume}", paramVolume, 1) - req := cli.Client.Delete().URL(url) + req := cli.Client.Get().URL(url) + + 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) @@ -3784,7 +3793,7 @@ func MistApiV2DeleteVolume(paramVolume string, params *viper.Viper) (*gentleman. return resp, 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 { @@ -3796,15 +3805,15 @@ func MistApiV2DeleteVolume(paramVolume string, params *viper.Viper) (*gentleman. after := cli.HandleAfter(handlerPath, params, resp, decoded) if after != nil { - decoded = after + decoded = after.(map[string]interface{}) } - return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}, []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"}, []string{}, []string{}}, nil } -// MistApiV2GetVolume Get volume -func MistApiV2GetVolume(paramVolume string, params *viper.Viper) (*gentleman.Response, map[string]interface{}, cli.CLIOutputOptions, error) { - handlerPath := "get-volume" +// MistApiV2EditVolume Edit volume +func MistApiV2EditVolume(paramVolume string, params *viper.Viper, body string) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { + handlerPath := "edit-volume" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -3822,15 +3831,15 @@ func MistApiV2GetVolume(paramVolume string, params *viper.Viper) (*gentleman.Res url := server + "/api/v2/volumes/{volume}" url = strings.Replace(url, "{volume}", paramVolume, 1) - req := cli.Client.Get().URL(url) + req := cli.Client.Put().URL(url) - paramOnly := params.GetString("only") - if paramOnly != "" { - req = req.AddQuery("only", fmt.Sprintf("%v", paramOnly)) + paramName := params.GetString("name") + if paramName != "" { + req = req.AddQuery("name", fmt.Sprintf("%v", paramName)) } - 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) @@ -3840,7 +3849,7 @@ func MistApiV2GetVolume(paramVolume string, params *viper.Viper) (*gentleman.Res return resp, 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 { @@ -3852,15 +3861,15 @@ func MistApiV2GetVolume(paramVolume string, params *viper.Viper) (*gentleman.Res after := cli.HandleAfter(handlerPath, params, resp, decoded) if after != nil { - decoded = after.(map[string]interface{}) + decoded = after } - 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"}, []string{}, []string{}}, nil + return resp, decoded, cli.CLIOutputOptions{[]string{}, []string{}, []string{}, []string{}}, nil } -// MistApiV2EditVolume Edit volume -func MistApiV2EditVolume(paramVolume string, params *viper.Viper, body string) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { - handlerPath := "edit-volume" +// MistApiV2DeleteVolume Delete volume +func MistApiV2DeleteVolume(paramVolume string, params *viper.Viper) (*gentleman.Response, interface{}, cli.CLIOutputOptions, error) { + handlerPath := "delete-volume" if mistApiV2Subcommand { handlerPath = "Mist CLI " + handlerPath } @@ -3878,16 +3887,7 @@ func MistApiV2EditVolume(paramVolume string, params *viper.Viper, body string) ( url := server + "/api/v2/volumes/{volume}" url = strings.Replace(url, "{volume}", paramVolume, 1) - req := cli.Client.Put().URL(url) - - paramName := params.GetString("name") - if paramName != "" { - req = req.AddQuery("name", fmt.Sprintf("%v", paramName)) - } - - if body != "" { - req = req.AddHeader("Content-Type", "").BodyString(body) - } + req := cli.Client.Delete().URL(url) cli.HandleBefore(handlerPath, params, req) @@ -5079,15 +5079,19 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "delete-key KEY", - Short: "Delete key", - Long: cli.Markdown("Delete target key"), + Use: "edit-key KEY", + Short: "Edit key", + Long: cli.Markdown("Edit target key"), Hidden: true, Example: examples, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { + body, err := cli.GetBody("", args[1:], params.GetString("filename")) + if err != nil { + logger.Fatalf("Unable to get body: %s", err.Error()) + } - _, decoded, outputOptions, err := MistApiV2DeleteKey(args[0], params) + _, decoded, outputOptions, err := MistApiV2EditKey(args[0], params, body) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -5099,6 +5103,10 @@ func mistApiV2Register(subcommand bool) { }, } root.AddCommand(cmd) + cmd.Flags().StringP("filename", "f", "", "Filename") + + cmd.Flags().String("name", "", "New key name") + cmd.Flags().Bool("default", false, "Set as default") cli.SetCustomFlags(cmd) @@ -5114,15 +5122,15 @@ 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: "delete-key KEY", + Short: "Delete key", + Long: cli.Markdown("Delete target key"), Hidden: true, Example: examples, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - _, decoded, outputOptions, err := MistApiV2GetKey(args[0], params) + _, decoded, outputOptions, err := MistApiV2DeleteKey(args[0], params) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -5135,11 +5143,6 @@ func mistApiV2Register(subcommand bool) { } root.AddCommand(cmd) - cmd.Flags().Bool("private", false, "Return the private key. Requires READ_PRIVATE permission on key. (Only for single resource)") - 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() { @@ -5154,19 +5157,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: "get-key KEY", + Short: "Get key", + Long: cli.Markdown("Get details about target key"), Hidden: true, Example: examples, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - body, err := cli.GetBody("", args[1:], params.GetString("filename")) - if err != nil { - logger.Fatalf("Unable to get body: %s", err.Error()) - } - _, decoded, outputOptions, err := MistApiV2EditKey(args[0], params, body) + _, decoded, outputOptions, err := MistApiV2GetKey(args[0], params) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -5178,10 +5177,11 @@ func mistApiV2Register(subcommand bool) { }, } root.AddCommand(cmd) - cmd.Flags().StringP("filename", "f", "", "Filename") - cmd.Flags().String("name", "", "New key name") - cmd.Flags().Bool("default", false, "Set as default") + cmd.Flags().Bool("private", false, "Return the private key. Requires READ_PRIVATE permission on key. (Only for single resource)") + 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) @@ -5320,6 +5320,8 @@ func mistApiV2Register(subcommand bool) { var examples string + examples += " " + cli.Root.CommandPath() + " create-machine dry: false, image: Ubuntu, name: awsmachine, provider: amazon, size: t3.micro\n" + cmd := &cobra.Command{ Use: "create-machine", Short: "Create machine", @@ -6367,19 +6369,15 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "edit-rule RULE", - Short: "Update rule", - Long: cli.Markdown("Edit 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."), Hidden: true, Example: examples, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - body, err := cli.GetBody("application/json", args[1:], params.GetString("filename")) - if err != nil { - logger.Fatalf("Unable to get body: %s", err.Error()) - } - _, decoded, outputOptions, err := MistApiV2EditRule(args[0], params, body) + _, decoded, outputOptions, err := MistApiV2DeleteRule(args[0], params) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -6391,7 +6389,6 @@ func mistApiV2Register(subcommand bool) { }, } root.AddCommand(cmd) - cmd.Flags().StringP("filename", "f", "", "Filename") cli.SetCustomFlags(cmd) @@ -6407,19 +6404,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"), Hidden: true, Example: examples, - Args: cobra.MinimumNArgs(2), + Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - body, err := cli.GetBody("", args[2:], params.GetString("filename")) - 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()) } @@ -6431,7 +6424,9 @@ func mistApiV2Register(subcommand bool) { }, } root.AddCommand(cmd) - cmd.Flags().StringP("filename", "f", "", "Filename") + + cmd.Flags().String("sort", "", "Order results by") + cmd.Flags().String("only", "", "Only return these fields") cli.SetCustomFlags(cmd) @@ -6447,15 +6442,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 NAME", + Short: "Rename rule", + Long: cli.Markdown("Rename a rule"), Hidden: true, Example: examples, - Args: cobra.MinimumNArgs(1), + Args: cobra.MinimumNArgs(2), Run: func(cmd *cobra.Command, args []string) { + body, err := cli.GetBody("", args[2:], params.GetString("filename")) + 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()) } @@ -6467,6 +6466,7 @@ func mistApiV2Register(subcommand bool) { }, } root.AddCommand(cmd) + cmd.Flags().StringP("filename", "f", "", "Filename") cli.SetCustomFlags(cmd) @@ -6482,15 +6482,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: "edit-rule RULE", + Short: "Update rule", + Long: cli.Markdown("Edit a rule given its UUID, EDIT permission required on rule"), Hidden: true, Example: examples, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { + body, err := cli.GetBody("application/json", args[1:], params.GetString("filename")) + if err != nil { + logger.Fatalf("Unable to get body: %s", err.Error()) + } - _, decoded, outputOptions, err := MistApiV2GetRule(args[0], params) + _, decoded, outputOptions, err := MistApiV2EditRule(args[0], params, body) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -6502,9 +6506,7 @@ func mistApiV2Register(subcommand bool) { }, } root.AddCommand(cmd) - - cmd.Flags().String("sort", "", "Order results by") - cmd.Flags().String("only", "", "Only return these fields") + cmd.Flags().StringP("filename", "f", "", "Filename") cli.SetCustomFlags(cmd) @@ -6520,9 +6522,9 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "rename-rule RULE NAME", - 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"), Hidden: true, Example: examples, Args: cobra.MinimumNArgs(2), @@ -6532,7 +6534,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()) } @@ -6642,19 +6644,15 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "run-script SCRIPT", - Short: "Run script", - Long: cli.Markdown("Start a script job to run the script."), + Use: "delete-script SCRIPT", + Short: "Delete script", + Long: cli.Markdown("Delete target script"), Hidden: true, Example: examples, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - body, err := cli.GetBody("application/json", args[1:], params.GetString("filename")) - if err != nil { - logger.Fatalf("Unable to get body: %s", err.Error()) - } - _, decoded, outputOptions, err := MistApiV2RunScript(args[0], params, body) + _, decoded, outputOptions, err := MistApiV2DeleteScript(args[0], params) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -6666,7 +6664,6 @@ func mistApiV2Register(subcommand bool) { }, } root.AddCommand(cmd) - cmd.Flags().StringP("filename", "f", "", "Filename") cli.SetCustomFlags(cmd) @@ -6681,20 +6678,16 @@ func mistApiV2Register(subcommand bool) { var examples string - cmd := &cobra.Command{ - Use: "edit-script SCRIPT", - Short: "Edit script", - Long: cli.Markdown("Edit target script"), + cmd := &cobra.Command{ + Use: "get-script SCRIPT", + Short: "Get script", + Long: cli.Markdown("Get details about target script"), Hidden: true, Example: examples, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - body, err := cli.GetBody("", args[1:], params.GetString("filename")) - if err != nil { - logger.Fatalf("Unable to get body: %s", err.Error()) - } - _, decoded, outputOptions, err := MistApiV2EditScript(args[0], params, body) + _, decoded, outputOptions, err := MistApiV2GetScript(args[0], params) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -6706,10 +6699,9 @@ func mistApiV2Register(subcommand bool) { }, } root.AddCommand(cmd) - cmd.Flags().StringP("filename", "f", "", "Filename") - cmd.Flags().String("name", "", "New script name") - cmd.Flags().String("description", "", "New script description") + cmd.Flags().String("only", "", "Only return these fields") + cmd.Flags().String("deref", "", "Dereference foreign keys") cli.SetCustomFlags(cmd) @@ -6725,15 +6717,19 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "delete-script SCRIPT", - Short: "Delete script", - Long: cli.Markdown("Delete target script"), + Use: "run-script SCRIPT", + Short: "Run script", + Long: cli.Markdown("Start a script job to run the script."), Hidden: true, Example: examples, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { + body, err := cli.GetBody("application/json", args[1:], params.GetString("filename")) + if err != nil { + logger.Fatalf("Unable to get body: %s", err.Error()) + } - _, decoded, outputOptions, err := MistApiV2DeleteScript(args[0], params) + _, decoded, outputOptions, err := MistApiV2RunScript(args[0], params, body) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -6745,6 +6741,7 @@ func mistApiV2Register(subcommand bool) { }, } root.AddCommand(cmd) + cmd.Flags().StringP("filename", "f", "", "Filename") cli.SetCustomFlags(cmd) @@ -6760,15 +6757,19 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "get-script SCRIPT", - Short: "Get script", - Long: cli.Markdown("Get details about target script"), + Use: "edit-script SCRIPT", + Short: "Edit script", + Long: cli.Markdown("Edit target script"), Hidden: true, Example: examples, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { + body, err := cli.GetBody("", args[1:], params.GetString("filename")) + if err != nil { + logger.Fatalf("Unable to get body: %s", err.Error()) + } - _, decoded, outputOptions, err := MistApiV2GetScript(args[0], params) + _, decoded, outputOptions, err := MistApiV2EditScript(args[0], params, body) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -6780,9 +6781,10 @@ func mistApiV2Register(subcommand bool) { }, } root.AddCommand(cmd) + cmd.Flags().StringP("filename", "f", "", "Filename") - cmd.Flags().String("only", "", "Only return these fields") - cmd.Flags().String("deref", "", "Dereference foreign keys") + cmd.Flags().String("name", "", "New script name") + cmd.Flags().String("description", "", "New script description") cli.SetCustomFlags(cmd) @@ -7074,15 +7076,15 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "delete-volume VOLUME", - Short: "Delete volume", - Long: cli.Markdown("Delete target volume"), + Use: "get-volume VOLUME", + Short: "Get volume", + Long: cli.Markdown("Get details about target volume"), Hidden: true, Example: examples, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - _, decoded, outputOptions, err := MistApiV2DeleteVolume(args[0], params) + _, decoded, outputOptions, err := MistApiV2GetVolume(args[0], params) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -7095,6 +7097,9 @@ func mistApiV2Register(subcommand bool) { } root.AddCommand(cmd) + cmd.Flags().String("only", "", "Only return these fields") + cmd.Flags().String("deref", "", "Dereference foreign keys") + cli.SetCustomFlags(cmd) if cmd.Flags().HasFlags() { @@ -7109,15 +7114,19 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "get-volume VOLUME", - Short: "Get volume", - Long: cli.Markdown("Get details about target volume"), + Use: "edit-volume VOLUME", + Short: "Edit volume", + Long: cli.Markdown("Edit target volume"), Hidden: true, Example: examples, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { + body, err := cli.GetBody("", args[1:], params.GetString("filename")) + if err != nil { + logger.Fatalf("Unable to get body: %s", err.Error()) + } - _, decoded, outputOptions, err := MistApiV2GetVolume(args[0], params) + _, decoded, outputOptions, err := MistApiV2EditVolume(args[0], params, body) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -7129,9 +7138,9 @@ func mistApiV2Register(subcommand bool) { }, } root.AddCommand(cmd) + cmd.Flags().StringP("filename", "f", "", "Filename") - cmd.Flags().String("only", "", "Only return these fields") - cmd.Flags().String("deref", "", "Dereference foreign keys") + cmd.Flags().String("name", "", "New volume name") cli.SetCustomFlags(cmd) @@ -7147,19 +7156,15 @@ func mistApiV2Register(subcommand bool) { var examples string cmd := &cobra.Command{ - Use: "edit-volume VOLUME", - Short: "Edit volume", - Long: cli.Markdown("Edit target volume"), + Use: "delete-volume VOLUME", + Short: "Delete volume", + Long: cli.Markdown("Delete target volume"), Hidden: true, Example: examples, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - body, err := cli.GetBody("", args[1:], params.GetString("filename")) - if err != nil { - logger.Fatalf("Unable to get body: %s", err.Error()) - } - _, decoded, outputOptions, err := MistApiV2EditVolume(args[0], params, body) + _, decoded, outputOptions, err := MistApiV2DeleteVolume(args[0], params) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -7171,9 +7176,6 @@ func mistApiV2Register(subcommand bool) { }, } root.AddCommand(cmd) - cmd.Flags().StringP("filename", "f", "", "Filename") - - cmd.Flags().String("name", "", "New volume name") cli.SetCustomFlags(cmd) @@ -8294,8 +8296,8 @@ func mistApiV2Register(subcommand bool) { "ke", "keys", }, - Short: "Delete key", - Long: cli.Markdown("Delete target key"), + Short: "Edit key", + Long: cli.Markdown("Edit target key"), Example: examples, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { @@ -8316,8 +8318,12 @@ func mistApiV2Register(subcommand bool) { }, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { + body, err := cli.GetBody("", args[1:], params.GetString("filename")) + if err != nil { + logger.Fatalf("Unable to get body: %s", err.Error()) + } - _, decoded, outputOptions, err := MistApiV2DeleteKey(args[0], params) + _, decoded, outputOptions, err := MistApiV2EditKey(args[0], params, body) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -8329,9 +8335,12 @@ func mistApiV2Register(subcommand bool) { }, } cmd.SetErr(os.Stderr) - apiDocs := server + "/api/v2#" + strings.ToLower("Delete") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/keys/{key}", "{", "-"), "}", "-") + apiDocs := server + "/api/v2#" + strings.ToLower("Put") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/keys/{key}", "{", "-"), "}", "-") cmd.SetUsageTemplate(strings.ReplaceAll(customUsageSubCommandTpl, "$API_DOCS", apiDocs)) - deleteCmd.AddCommand(cmd) + editCmd.AddCommand(cmd) + + cmd.Flags().String("name", "", "New key name") + cmd.Flags().Bool("default", false, "Set as default") cli.SetCustomFlags(cmd) @@ -8363,8 +8372,8 @@ func mistApiV2Register(subcommand bool) { "ke", "keys", }, - Short: "Edit key", - Long: cli.Markdown("Edit target key"), + Short: "Delete key", + Long: cli.Markdown("Delete target key"), Example: examples, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { @@ -8385,12 +8394,8 @@ func mistApiV2Register(subcommand bool) { }, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - body, err := cli.GetBody("", args[1:], params.GetString("filename")) - 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()) } @@ -8402,12 +8407,9 @@ func mistApiV2Register(subcommand bool) { }, } cmd.SetErr(os.Stderr) - apiDocs := server + "/api/v2#" + strings.ToLower("Put") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/keys/{key}", "{", "-"), "}", "-") + apiDocs := server + "/api/v2#" + strings.ToLower("Delete") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/keys/{key}", "{", "-"), "}", "-") cmd.SetUsageTemplate(strings.ReplaceAll(customUsageSubCommandTpl, "$API_DOCS", apiDocs)) - editCmd.AddCommand(cmd) - - cmd.Flags().String("name", "", "New key name") - cmd.Flags().Bool("default", false, "Set as default") + deleteCmd.AddCommand(cmd) cli.SetCustomFlags(cmd) @@ -8605,6 +8607,8 @@ func mistApiV2Register(subcommand bool) { var examples string + examples += " " + cli.Root.CommandPath() + " create-machine dry: false, image: Ubuntu, name: awsmachine, provider: amazon, size: t3.micro\n" + err := setMistContext() if err != nil { logger.Fatalf("Could not set mist context: %s", err.Error()) @@ -10522,8 +10526,8 @@ func mistApiV2Register(subcommand bool) { "rul", "rules", }, - Short: "Update rule", - Long: cli.Markdown("Edit a rule given its UUID, EDIT permission required on rule"), + Short: "Delete rule", + Long: cli.Markdown("Delete a rule given its UUID."), Example: examples, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { @@ -10544,12 +10548,8 @@ func mistApiV2Register(subcommand bool) { }, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - body, err := cli.GetBody("application/json", args[1:], params.GetString("filename")) - if err != nil { - logger.Fatalf("Unable to get body: %s", err.Error()) - } - _, decoded, outputOptions, err := MistApiV2EditRule(args[0], params, body) + _, decoded, outputOptions, err := MistApiV2DeleteRule(args[0], params) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -10561,10 +10561,9 @@ func mistApiV2Register(subcommand bool) { }, } cmd.SetErr(os.Stderr) - apiDocs := server + "/api/v2#" + strings.ToLower("Post") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/rules/{rule}", "{", "-"), "}", "-") + apiDocs := server + "/api/v2#" + strings.ToLower("Delete") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/rules/{rule}", "{", "-"), "}", "-") cmd.SetUsageTemplate(strings.ReplaceAll(customUsageSubCommandTpl, "$API_DOCS", apiDocs)) - editCmd.AddCommand(cmd) - cmd.Flags().StringP("filename", "f", "", "Filename") + deleteCmd.AddCommand(cmd) cli.SetCustomFlags(cmd) @@ -10590,15 +10589,15 @@ func mistApiV2Register(subcommand bool) { } cmd := &cobra.Command{ - Use: "rule RULE ACTION", + Use: "rule RULE NAME", Aliases: []string{ "r", "ru", "rul", "rules", }, - Short: "Toggle rule", - Long: cli.Markdown("Enable or disable a rule"), + Short: "Rename rule", + Long: cli.Markdown("Rename a rule"), Example: examples, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { @@ -10625,7 +10624,7 @@ func mistApiV2Register(subcommand bool) { logger.Fatalf("Unable to get body: %s", err.Error()) } - _, decoded, outputOptions, err := MistApiV2ToggleRule(args[0], args[1], params, body) + _, decoded, outputOptions, err := MistApiV2RenameRule(args[0], args[1], params, body) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -10637,9 +10636,9 @@ func mistApiV2Register(subcommand bool) { }, } cmd.SetErr(os.Stderr) - apiDocs := server + "/api/v2#" + strings.ToLower("Put") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/rules/{rule}", "{", "-"), "}", "-") + apiDocs := server + "/api/v2#" + strings.ToLower("Patch") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/rules/{rule}", "{", "-"), "}", "-") cmd.SetUsageTemplate(strings.ReplaceAll(customUsageSubCommandTpl, "$API_DOCS", apiDocs)) - toggleCmd.AddCommand(cmd) + renameCmd.AddCommand(cmd) cli.SetCustomFlags(cmd) @@ -10672,8 +10671,8 @@ func mistApiV2Register(subcommand bool) { "rul", "rules", }, - Short: "Delete rule", - Long: cli.Markdown("Delete a rule given its UUID."), + Short: "Update rule", + Long: cli.Markdown("Edit a rule given its UUID, EDIT permission required on rule"), Example: examples, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { @@ -10694,8 +10693,12 @@ func mistApiV2Register(subcommand bool) { }, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { + body, err := cli.GetBody("application/json", args[1:], params.GetString("filename")) + if err != nil { + logger.Fatalf("Unable to get body: %s", err.Error()) + } - _, decoded, outputOptions, err := MistApiV2DeleteRule(args[0], params) + _, decoded, outputOptions, err := MistApiV2EditRule(args[0], params, body) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -10707,9 +10710,10 @@ func mistApiV2Register(subcommand bool) { }, } cmd.SetErr(os.Stderr) - apiDocs := server + "/api/v2#" + strings.ToLower("Delete") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/rules/{rule}", "{", "-"), "}", "-") + apiDocs := server + "/api/v2#" + strings.ToLower("Post") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/rules/{rule}", "{", "-"), "}", "-") cmd.SetUsageTemplate(strings.ReplaceAll(customUsageSubCommandTpl, "$API_DOCS", apiDocs)) - deleteCmd.AddCommand(cmd) + editCmd.AddCommand(cmd) + cmd.Flags().StringP("filename", "f", "", "Filename") cli.SetCustomFlags(cmd) @@ -10735,15 +10739,15 @@ func mistApiV2Register(subcommand bool) { } cmd := &cobra.Command{ - Use: "rule RULE NAME", + Use: "rule RULE ACTION", Aliases: []string{ "r", "ru", "rul", "rules", }, - Short: "Rename rule", - Long: cli.Markdown("Rename a rule"), + Short: "Toggle rule", + Long: cli.Markdown("Enable or disable a rule"), Example: examples, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { @@ -10770,7 +10774,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()) } @@ -10782,9 +10786,9 @@ func mistApiV2Register(subcommand bool) { }, } cmd.SetErr(os.Stderr) - apiDocs := server + "/api/v2#" + strings.ToLower("Patch") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/rules/{rule}", "{", "-"), "}", "-") + apiDocs := server + "/api/v2#" + strings.ToLower("Put") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/rules/{rule}", "{", "-"), "}", "-") cmd.SetUsageTemplate(strings.ReplaceAll(customUsageSubCommandTpl, "$API_DOCS", apiDocs)) - renameCmd.AddCommand(cmd) + toggleCmd.AddCommand(cmd) cli.SetCustomFlags(cmd) @@ -10970,8 +10974,8 @@ func mistApiV2Register(subcommand bool) { "scrip", "scripts", }, - Short: "Run script", - Long: cli.Markdown("Start a script job to run the script."), + Short: "Delete script", + Long: cli.Markdown("Delete target script"), Example: examples, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { @@ -10992,12 +10996,8 @@ func mistApiV2Register(subcommand bool) { }, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - body, err := cli.GetBody("application/json", args[1:], params.GetString("filename")) - if err != nil { - logger.Fatalf("Unable to get body: %s", err.Error()) - } - _, decoded, outputOptions, err := MistApiV2RunScript(args[0], params, body) + _, decoded, outputOptions, err := MistApiV2DeleteScript(args[0], params) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -11009,10 +11009,9 @@ func mistApiV2Register(subcommand bool) { }, } cmd.SetErr(os.Stderr) - apiDocs := server + "/api/v2#" + strings.ToLower("Post") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/scripts/{script}", "{", "-"), "}", "-") + apiDocs := server + "/api/v2#" + strings.ToLower("Delete") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/scripts/{script}", "{", "-"), "}", "-") cmd.SetUsageTemplate(strings.ReplaceAll(customUsageSubCommandTpl, "$API_DOCS", apiDocs)) - runCmd.AddCommand(cmd) - cmd.Flags().StringP("filename", "f", "", "Filename") + deleteCmd.AddCommand(cmd) cli.SetCustomFlags(cmd) @@ -11047,8 +11046,8 @@ func mistApiV2Register(subcommand bool) { "scrip", "scripts", }, - Short: "Edit script", - Long: cli.Markdown("Edit target script"), + Short: "Run script", + Long: cli.Markdown("Start a script job to run the script."), Example: examples, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { @@ -11069,12 +11068,12 @@ func mistApiV2Register(subcommand bool) { }, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - body, err := cli.GetBody("", args[1:], params.GetString("filename")) + body, err := cli.GetBody("application/json", args[1:], params.GetString("filename")) if err != nil { logger.Fatalf("Unable to get body: %s", err.Error()) } - _, decoded, outputOptions, err := MistApiV2EditScript(args[0], params, body) + _, decoded, outputOptions, err := MistApiV2RunScript(args[0], params, body) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -11086,12 +11085,10 @@ func mistApiV2Register(subcommand bool) { }, } cmd.SetErr(os.Stderr) - apiDocs := server + "/api/v2#" + strings.ToLower("Put") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/scripts/{script}", "{", "-"), "}", "-") + apiDocs := server + "/api/v2#" + strings.ToLower("Post") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/scripts/{script}", "{", "-"), "}", "-") cmd.SetUsageTemplate(strings.ReplaceAll(customUsageSubCommandTpl, "$API_DOCS", apiDocs)) - editCmd.AddCommand(cmd) - - cmd.Flags().String("name", "", "New script name") - cmd.Flags().String("description", "", "New script description") + runCmd.AddCommand(cmd) + cmd.Flags().StringP("filename", "f", "", "Filename") cli.SetCustomFlags(cmd) @@ -11126,8 +11123,8 @@ func mistApiV2Register(subcommand bool) { "scrip", "scripts", }, - Short: "Delete script", - Long: cli.Markdown("Delete target script"), + Short: "Edit script", + Long: cli.Markdown("Edit target script"), Example: examples, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { @@ -11148,8 +11145,12 @@ func mistApiV2Register(subcommand bool) { }, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { + body, err := cli.GetBody("", args[1:], params.GetString("filename")) + if err != nil { + logger.Fatalf("Unable to get body: %s", err.Error()) + } - _, decoded, outputOptions, err := MistApiV2DeleteScript(args[0], params) + _, decoded, outputOptions, err := MistApiV2EditScript(args[0], params, body) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -11161,9 +11162,12 @@ func mistApiV2Register(subcommand bool) { }, } cmd.SetErr(os.Stderr) - apiDocs := server + "/api/v2#" + strings.ToLower("Delete") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/scripts/{script}", "{", "-"), "}", "-") + apiDocs := server + "/api/v2#" + strings.ToLower("Put") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/scripts/{script}", "{", "-"), "}", "-") cmd.SetUsageTemplate(strings.ReplaceAll(customUsageSubCommandTpl, "$API_DOCS", apiDocs)) - deleteCmd.AddCommand(cmd) + editCmd.AddCommand(cmd) + + cmd.Flags().String("name", "", "New script name") + cmd.Flags().String("description", "", "New script description") cli.SetCustomFlags(cmd) @@ -11649,8 +11653,8 @@ func mistApiV2Register(subcommand bool) { "volum", "volumes", }, - Short: "Delete volume", - Long: cli.Markdown("Delete target volume"), + Short: "Edit volume", + Long: cli.Markdown("Edit target volume"), Example: examples, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { @@ -11671,8 +11675,12 @@ func mistApiV2Register(subcommand bool) { }, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { + body, err := cli.GetBody("", args[1:], params.GetString("filename")) + if err != nil { + logger.Fatalf("Unable to get body: %s", err.Error()) + } - _, decoded, outputOptions, err := MistApiV2DeleteVolume(args[0], params) + _, decoded, outputOptions, err := MistApiV2EditVolume(args[0], params, body) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -11684,9 +11692,11 @@ func mistApiV2Register(subcommand bool) { }, } cmd.SetErr(os.Stderr) - apiDocs := server + "/api/v2#" + strings.ToLower("Delete") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/volumes/{volume}", "{", "-"), "}", "-") + apiDocs := server + "/api/v2#" + strings.ToLower("Put") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/volumes/{volume}", "{", "-"), "}", "-") cmd.SetUsageTemplate(strings.ReplaceAll(customUsageSubCommandTpl, "$API_DOCS", apiDocs)) - deleteCmd.AddCommand(cmd) + editCmd.AddCommand(cmd) + + cmd.Flags().String("name", "", "New volume name") cli.SetCustomFlags(cmd) @@ -11721,8 +11731,8 @@ func mistApiV2Register(subcommand bool) { "volum", "volumes", }, - Short: "Edit volume", - Long: cli.Markdown("Edit target volume"), + Short: "Delete volume", + Long: cli.Markdown("Delete target volume"), Example: examples, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { @@ -11743,12 +11753,8 @@ func mistApiV2Register(subcommand bool) { }, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - body, err := cli.GetBody("", args[1:], params.GetString("filename")) - if err != nil { - logger.Fatalf("Unable to get body: %s", err.Error()) - } - _, decoded, outputOptions, err := MistApiV2EditVolume(args[0], params, body) + _, decoded, outputOptions, err := MistApiV2DeleteVolume(args[0], params) if err != nil { logger.Fatalf("Error calling operation: %s", err.Error()) } @@ -11760,11 +11766,9 @@ func mistApiV2Register(subcommand bool) { }, } cmd.SetErr(os.Stderr) - apiDocs := server + "/api/v2#" + strings.ToLower("Put") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/volumes/{volume}", "{", "-"), "}", "-") + apiDocs := server + "/api/v2#" + strings.ToLower("Delete") + "-" + strings.ReplaceAll(strings.ReplaceAll("/api/v2/volumes/{volume}", "{", "-"), "}", "-") cmd.SetUsageTemplate(strings.ReplaceAll(customUsageSubCommandTpl, "$API_DOCS", apiDocs)) - editCmd.AddCommand(cmd) - - cmd.Flags().String("name", "", "New volume name") + deleteCmd.AddCommand(cmd) cli.SetCustomFlags(cmd)