How to use the jq.icon_jq.actions.run_jq.schema.Input.FLAGS function in jq

To help you get started, we’ve selected a few jq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rapid7 / insightconnect-plugins / jq / icon_jq / actions / run_jq / action.py View on Github external
def run(self, params=None):
        if params is None:
            params = {}

        json_in = params.get(Input.JSON_IN)
        flags = params.get(Input.FLAGS)
        filter_ = params.get(Input.FILTER)
        timeout = params.get(Input.TIMEOUT)

        jq_cmd_array = ["jq"]

        if len(flags) > 0:
            string_flags = ' '.join(flags)
            jq_cmd_array.append(string_flags)

        jq_cmd_array.append(filter_)

        self.logger.info("Command to Run: {}".format(jq_cmd_array))
        process = subprocess.Popen(jq_cmd_array, stdout=PIPE, stderr=PIPE, stdin=PIPE)
        std_out, std_err = process.communicate(input=json.dumps(json_in).encode(), timeout=timeout)
        return_code = process.returncode