How to use the datadog.util.format.pretty_json function in datadog

To help you get started, we’ve selected a few datadog 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 DataDog / datadogpy / datadog / dogshell / service_level_objective.py View on Github external
elif args.monitor_search:
            params["monitor_search"] = args.monitor_search
        else:
            params["monitor_ids"] = args.monitor_ids
            if args.groups and len(args.monitor_ids) == 1:
                groups = args.groups.split("|")
                params["groups"] = groups

        if args.tags:
            tags = sorted(set([t.strip() for t in args.tags if t.strip()]))
            params["tags"] = tags
        res = api.ServiceLevelObjective.update(args.slo_id, return_raw=True, **params)
        report_warnings(res)
        report_errors(res)
        if format == "pretty":
            print(pretty_json(res))
        else:
            print(json.dumps(res))
github DataDog / datadogpy / datadog / dogshell / monitor.py View on Github external
def _can_delete(cls, args):
        api._timeout = args.timeout
        monitor_ids = [i.strip() for i in args.monitor_ids.split(',') if i.strip()]
        res = api.Monitor.can_delete(monitor_ids=monitor_ids)
        if format == 'pretty':
            print(pretty_json(res))
        else:
            print(json.dumps(res))
github DataDog / datadogpy / datadog / dogshell / monitor.py View on Github external
def _mute_all(cls, args):
        api._timeout = args.timeout
        format = args.format
        res = api.Monitor.mute_all()
        report_warnings(res)
        report_errors(res)
        if format == 'pretty':
            print(pretty_json(res))
        else:
            print(json.dumps(res))
github DataDog / datadogpy / datadog / dogshell / screenboard.py View on Github external
def _revoke(cls, args):
        api._timeout = args.timeout
        format = args.format
        res = api.Screenboard.revoke(args.screenboard_id)

        if format == 'pretty':
            print(pretty_json(res))
        else:
            print(json.dumps(res))
github DataDog / datadogpy / datadog / dogshell / screenboard.py View on Github external
def _update(cls, args):
        api._timeout = args.timeout
        format = args.format
        graphs = args.graphs
        if args.graphs is None:
            graphs = sys.stdin.read()
        graphs = json.loads(graphs)

        res = api.Screenboard.update(
            args.screenboard_id, board_title=args.title, description=args.description,
            widgets=graphs, template_variables=args.template_variables,
            width=args.width, height=args.height)
        report_warnings(res)
        report_errors(res)
        if format == 'pretty':
            print(pretty_json(res))
        else:
            print(json.dumps(res))
github DataDog / datadogpy / datadog / dogshell / timeboard.py View on Github external
def _show_all(cls, args):
        api._timeout = args.timeout
        format = args.format
        res = api.Timeboard.get_all()
        report_warnings(res)
        report_errors(res)

        if args.string_ids:
            for d in res["dashes"]:
                d["id"] = str(d["id"])

        if format == 'pretty':
            print(pretty_json(res))
        elif format == 'raw':
            print(json.dumps(res))
        else:
            for d in res["dashes"]:
                print("\t".join([(d["id"]),
                                 (d["resource"]),
                                 (d["title"]),
                                 cls._escape(d["description"])]))
github DataDog / datadogpy / datadog / dogshell / screenboard.py View on Github external
def _share(cls, args):
        api._timeout = args.timeout
        format = args.format
        res = api.Screenboard.share(args.screenboard_id)

        if format == 'pretty':
            print(pretty_json(res))
        else:
            print(json.dumps(res))
github DataDog / datadogpy / datadog / dogshell / dashboard_list.py View on Github external
def _add_dashboards(cls, args):
        api._timeout = args.timeout
        format = args.format
        dashboard_list_id = args.dashboard_list_id
        dashboards = json.loads(args.dashboards)

        res = api.DashboardList.add_items(dashboard_list_id, dashboards=dashboards)
        report_warnings(res)
        report_errors(res)

        if format == 'pretty':
            print(pretty_json(res))
        else:
            print(json.dumps(res))
github DataDog / datadogpy / datadog / dogshell / downtime.py View on Github external
def _show_all_downtime(cls, args):
        api._timeout = args.timeout
        format = args.format
        res = api.Downtime.get_all(current_only=args.current_only)
        report_warnings(res)
        report_errors(res)
        if format == 'pretty':
            print(pretty_json(res))
        else:
            print(json.dumps(res))
github DataDog / datadogpy / datadog / dogshell / timeboard.py View on Github external
def _update(cls, args):
        api._timeout = args.timeout
        format = args.format
        graphs = args.graphs
        if args.graphs is None:
            graphs = sys.stdin.read()
        graphs = json.loads(graphs)

        res = api.Timeboard.update(args.timeboard_id, title=args.title,
                                   description=args.description, graphs=graphs,
                                   template_variables=args.template_variables)
        report_warnings(res)
        report_errors(res)
        if format == 'pretty':
            print(pretty_json(res))
        else:
            print(json.dumps(res))