def monitored_hostname_autocompleter(value: str, params: Dict) -> Choices: """Return the matching list of dropdown choices Called by the webservice with the current input field value and the completions_params to get the list of choices""" context = params.get("context", {}) context.pop("host", None) context["hostregex"] = {"host_regex": value or "."} query = livestatus_query_bare_string("host", context, ["host_name"], "reload") return _sorted_unique_lq(query, 200, value, params)
def monitored_service_description_autocompleter(value: str, params: Dict) -> Choices: """Return the matching list of dropdown choices Called by the webservice with the current input field value and the completions_params to get the list of choices""" context = params.get("context", {}) if not any((context.get("host"), context.get("hostregex"))) and params["strict"] == "withHost": return [] context.pop("service", None) context["serviceregex"] = {"service_regex": value or "."} query = livestatus_query_bare_string("service", context, ["service_description"], "reload") return _sorted_unique_lq(query, 200, value, params)