Skip to content

Latest commit

 

History

History
56 lines (42 loc) · 2.75 KB

json_parser.md

File metadata and controls

56 lines (42 loc) · 2.75 KB

libraries.RW.CLI.json_parser

parse_cli_json_output

def parse_cli_json_output(rsp: platform.ShellServiceResponse,
                          set_severity_level: int = 4,
                          set_issue_expected: str = "",
                          set_issue_actual: str = "",
                          set_issue_reproduce_hint: str = "",
                          set_issue_title: str = "",
                          set_issue_details: str = "",
                          set_issue_next_steps: str = "",
                          expected_rsp_statuscodes: list[int] = [200],
                          expected_rsp_returncodes: list[int] = [0],
                          raise_issue_from_rsp_code: bool = False,
                          contains_stderr_ok: bool = True,
                          **kwargs) -> platform.ShellServiceResponse

Parser for json blob data that can raise issues to the RunWhen platform based on data found. Queries can be performed on the data using various kwarg structures with the following syntax:

kwarg syntax:

  • extract_path_to_var__{variable_name}
  • from_var_with_path__{variable1}to{variable2}
  • assign_stdout_from_var
  • {variable_name}__raise_issue_if_gt|lt|contains|ncontains|eq|neq

Using the __ delimiters to separate values and prefixes.

Arguments:

  • rsp platform.ShellServiceResponse - description
  • set_severity_level int, optional - the severity of the issue if it's raised. Defaults to 4.
  • set_issue_expected str, optional - what we expected in the json data. Defaults to "".
  • set_issue_actual str, optional - what was actually detected in the json data. Defaults to "".
  • set_issue_reproduce_hint str, optional - reproduce hints as a string. Defaults to "".
  • set_issue_title str, optional - the title of the issue if raised. Defaults to "".
  • set_issue_details str, optional - details on the issue if raised. Defaults to "".
  • set_issue_next_steps str, optional - next steps or tasks to run based on this issue if raised. Defaults to "".
  • expected_rsp_statuscodes list[int], optional - allowed http codes in the response being parsed. Defaults to [200].
  • expected_rsp_returncodes list[int], optional - allowed shell return codes in the response being parsed. Defaults to [0].
  • raise_issue_from_rsp_code bool, optional - if true, raise an issue when the response object fails validation. Defaults to False.
  • contains_stderr_ok bool, optional - whether or not to fail validation of the response object when it contains stderr. Defaults to True.

Returns:

  • platform.ShellServiceResponse - the unchanged response object that was parsed, for subsequent parses.