How to use the datadog.dogshell.common.report_errors 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 / comment.py View on Github external
def _update(cls, args):
        handle = args.handle
        comment = args.comment
        id = args.comment_id
        format = args.format
        if comment is None:
            comment = sys.stdin.read()
        res = api.Comment.update(id, handle=handle, message=comment)
        report_warnings(res)
        report_errors(res)
        if format == 'pretty':
            message = res['comment']['message']
            lines = message.split('\n')
            message = '\n'.join(['    ' + line for line in lines])
            print('id\t\t' + str(res['comment']['id']))
            print('url\t\t' + res['comment']['url'])
            print('resource\t' + res['comment']['resource'])
            print('handle\t\t' + res['comment']['handle'])
            print('message\n' + message)
        elif format == 'raw':
            print(json.dumps(res))
        else:
            print('id\t\t' + str(res['comment']['id']))
            print('url\t\t' + res['comment']['url'])
            print('resource\t' + res['comment']['resource'])
            print('handle\t\t' + res['comment']['handle'])
github DataDog / datadogpy / datadog / dogshell / comment.py View on Github external
def _post(cls, args):
        api._timeout = args.timeout
        handle = args.handle
        comment = args.comment
        format = args.format
        if comment is None:
            comment = sys.stdin.read()
        res = api.Comment.create(handle=handle, message=comment)
        report_warnings(res)
        report_errors(res)
        if format == 'pretty':
            message = res['comment']['message']
            lines = message.split('\n')
            message = '\n'.join(['    ' + line for line in lines])
            print('id\t\t' + str(res['comment']['id']))
            print('url\t\t' + res['comment']['url'])
            print('resource\t' + res['comment']['resource'])
            print('handle\t\t' + res['comment']['handle'])
            print('message\n' + message)
        elif format == 'raw':
            print(json.dumps(res))
        else:
            print('id\t\t' + str(res['comment']['id']))
            print('url\t\t' + res['comment']['url'])
            print('resource\t' + res['comment']['resource'])
            print('handle\t\t' + res['comment']['handle'])
github DataDog / datadogpy / datadog / dogshell / downtime.py View on Github external
def _cancel_downtime(cls, args):
        api._timeout = args.timeout
        res = api.Downtime.delete(args.downtime_id)
        if res is not None:
            report_warnings(res)
            report_errors(res)
github DataDog / datadogpy / datadog / dogshell / service_level_objective.py View on Github external
def _show_all(cls, args):
        api._timeout = args.timeout
        format = args.format

        params = {"offset": args.offset, "limit": args.limit}
        if args.query:
            params["query"] = args.query
        else:
            params["ids"] = args.slo_ids

        res = api.ServiceLevelObjective.get_all(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 / host.py View on Github external
def _mute(cls, args):
        api._timeout = args.timeout
        format = args.format
        res = api.Host.mute(args.host_name, end=args.end, message=args.message,
                            override=args.override)
        report_warnings(res)
        report_errors(res)
        if format == 'pretty':
            print(pretty_json(res))
        else:
            print(json.dumps(res))
github DataDog / datadogpy / datadog / dogshell / dashboard.py View on Github external
def _delete(cls, args):
        api._timeout = args.timeout
        res = api.Dashboard.delete(args.dashboard_id)
        if res is not None:
            report_warnings(res)
            report_errors(res)
github DataDog / datadogpy / datadog / dogshell / dashboard_list.py View on Github external
def _show_dashboards(cls, args):
        api._timeout = args.timeout
        format = args.format
        dashboard_list_id = args.dashboard_list_id

        res = api.DashboardList.get_items(dashboard_list_id)
        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
# Always convert to int, in case it was originally a string.
                dash_obj["id"] = int(dash_obj["id"])
                res = api.Timeboard.update(dash_obj["id"], title=dash_obj["title"],
                                           description=dash_obj["description"],
                                           graphs=dash_obj["graphs"], template_variables=tpl_vars)
            else:
                res = api.Timeboard.create(title=dash_obj["title"],
                                           description=dash_obj["description"],
                                           graphs=dash_obj["graphs"], template_variables=tpl_vars)

            if 'errors' in res:
                print_err('Upload of dashboard {0} from file {1} failed.'
                          .format(dash_obj["id"], f.name))

            report_warnings(res)
            report_errors(res)

            if format == 'pretty':
                print(pretty_json(res))
            else:
                print(json.dumps(res))

            if args.format == 'pretty':
                print("Uploaded file {0} (dashboard {1})".format(f.name, dash_obj["id"]))
github DataDog / datadogpy / datadog / dogshell / downtime.py View on Github external
def _update_downtime(cls, args):
        api._timeout = args.timeout
        format = args.format
        res = api.Downtime.update(args.downtime_id, scope=args.scope, start=args.start,
                                  end=args.end, message=args.message)
        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 _schedule_downtime(cls, args):
        api._timeout = args.timeout
        format = args.format
        res = api.Downtime.create(scope=args.scope, start=args.start,
                                  end=args.end, message=args.message)
        report_warnings(res)
        report_errors(res)
        if format == 'pretty':
            print(pretty_json(res))
        else:
            print(json.dumps(res))