#NEWLINE# def setup_parser( self , subparsers ) : #NEWLINE# #INDENT# parser = subparsers . add_parser ( 'dashboard' , help = 'Create, edit, and delete dashboards.' ) #NEWLINE# parser . add_argument ( '--string_ids' , action = 'store_true' , dest = 'string_ids' , help = 'Represent Dashboard IDs as strings instead of ints in JSON' ) #NEWLINE# verb_parsers = parser . add_subparsers ( title = 'Verbs' ) #NEWLINE# post_parser = verb_parsers . add_parser ( 'post' , help = 'Create dashboards.' ) #NEWLINE# post_parser . add_argument ( 'title' , help = 'title for the new dashboard' ) #NEWLINE# post_parser . add_argument ( 'description' , help = 'short description of the dashboard' ) #NEWLINE# post_parser . add_argument ( 'graphs' , help = 'graph definitions as a JSON string. if unset, reads from stdin.' , nargs = '?' ) #NEWLINE# post_parser . add_argument ( '--template_variables' , type = _template_variables , default = [ ] , help = 'a json list of template variable dicts, e.g.                                     \'[{"name": "host", "prefix": "host", "default": "host:my-host"}]\'' ) #NEWLINE# post_parser . set_defaults ( func = self . _post ) #NEWLINE# update_parser = verb_parsers . add_parser ( 'update' , help = 'Update existing dashboards.' ) #NEWLINE# update_parser . add_argument ( 'dashboard_id' , help = 'dashboard to replace with the new definition' ) #NEWLINE# update_parser . add_argument ( 'title' , help = 'new title for the dashboard' ) #NEWLINE# update_parser . add_argument ( 'description' , help = 'short description of the dashboard' ) #NEWLINE# update_parser . add_argument ( 'graphs' , help = 'graph definitions as a JSON string. if unset, reads from stdin.' , nargs = '?' ) #NEWLINE# update_parser . add_argument ( '--template_variables' , type = _template_variables , default = [ ] , help = 'a json list of template variable dicts, e.g.                                     \'[{"name": "host", "prefix": "host", "default": "host:my-host"}]\'' ) #NEWLINE# update_parser . set_defaults ( func = self . _update ) #NEWLINE# show_parser = verb_parsers . add_parser ( 'show' , help = 'Show a dashboard definition.' ) #NEWLINE# show_parser . add_argument ( 'dashboard_id' , help = 'dashboard to show' ) #NEWLINE# show_parser . set_defaults ( func = self . _show ) #NEWLINE# show_all_parser = verb_parsers . add_parser ( 'show_all' , help = 'Show a list of all dashboards.' ) #NEWLINE# show_all_parser . set_defaults ( func = self . _show_all ) #NEWLINE# pull_parser = verb_parsers . add_parser ( 'pull' , help = 'Pull a dashboard on the server into a local file' ) #NEWLINE# pull_parser . add_argument ( 'dashboard_id' , help = 'ID of dashboard to pull' ) #NEWLINE# pull_parser . add_argument ( 'filename' , help = 'file to pull dashboard into' ) #NEWLINE# pull_parser . set_defaults ( func = self . _pull ) #NEWLINE# pull_all_parser = verb_parsers . add_parser ( 'pull_all' , help = 'Pull all dashboards into files in a directory' ) #NEWLINE# pull_all_parser . add_argument ( 'pull_dir' , help = 'directory to pull dashboards into' ) #NEWLINE# pull_all_parser . set_defaults ( func = self . _pull_all ) #NEWLINE# push_parser = verb_parsers . add_parser ( 'push' , help = 'Push updates to dashboards from local files to the server' ) #NEWLINE# push_parser . add_argument ( '--append_auto_text' , action = 'store_true' , dest = 'append_auto_text' , help = 'When pushing to the server, appends filename and timestamp to the end of the dashboard description' ) #NEWLINE# push_parser . add_argument ( 'file' , help = 'dashboard files to push to the server' , nargs = '+' , type = argparse . FileType ( 'r' ) ) #NEWLINE# push_parser . set_defaults ( func = parser . _push ) #NEWLINE# new_file_parser = verb_parsers . add_parser ( 'new_file' , help = 'Create a new dashboard and put its contents in a file' ) #NEWLINE# new_file_parser . add_argument ( 'filename' , help = 'name of file to create with empty dashboard' ) #NEWLINE# new_file_parser . set_defaults ( func = self . _new_file ) #NEWLINE# web_view_parser = verb_parsers . add_parser ( 'web_view' , help = 'View the dashboard in a web browser' ) #NEWLINE# web_view_parser . add_argument ( 'file' , help = 'dashboard file' , type = argparse . FileType ( 'r' ) ) #NEWLINE# web_view_parser . set_defaults ( func = self . _web_view ) #NEWLINE# delete_parser = verb_parsers . add_parser ( 'delete' , help = 'Delete dashboards.' ) #NEWLINE# delete_parser . add_argument ( 'dashboard_id' , help = 'dashboard to delete' ) #NEWLINE# delete_parser . set_defaults ( func = self . _delete )