Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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'])
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'])
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)
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))
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))
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)
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))
# 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"]))
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))
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))