MCPcopy Create free account
hub / github.com/Icinga/icinga2 / AutoCompleteScript

Method AutoCompleteScript

lib/cli/consolecommand.cpp:695–724  ·  view source on GitHub ↗

* Executes the auto completion script via HTTP and returns HTTP and user errors. * * @param session Local session handler. * @param command The auto completion string. * @param sandboxed Whether to run this sandboxed. * @return Result value, also contains user errors. */

Source from the content-addressed store, hash-verified

693 * @return Result value, also contains user errors.
694 */
695Array::Ptr ConsoleCommand::AutoCompleteScript(const String& session, const String& command, bool sandboxed)
696{
697 /* Extend the url parameters for the request. */
698 l_Url->SetPath({ "v1", "console", "auto-complete-script" });
699
700 l_Url->SetQuery({
701 {"session", session},
702 {"command", command},
703 {"sandboxed", sandboxed ? "1" : "0"}
704 });
705
706 Dictionary::Ptr jsonResponse = SendRequest();
707
708 /* Extract the result, and handle user input errors too. */
709 Array::Ptr results = jsonResponse->Get("results");
710 Array::Ptr suggestions;
711
712 if (results && results->GetLength() > 0) {
713 Dictionary::Ptr resultInfo = results->Get(0);
714
715 if (resultInfo->Get("code") >= 200 && resultInfo->Get("code") <= 299) {
716 suggestions = resultInfo->Get("suggestions");
717 } else {
718 String errorMessage = resultInfo->Get("status");
719 BOOST_THROW_EXCEPTION(ScriptError(errorMessage));
720 }
721 }
722
723 return suggestions;
724}

Callers

nothing calls this directly

Calls 5

ScriptErrorClass · 0.85
SetPathMethod · 0.80
SetQueryMethod · 0.80
GetMethod · 0.45
GetLengthMethod · 0.45

Tested by

no test coverage detected