Package: pypertrail
pypertrail==========|pypi| |travis| |doc| |pyup|Python wrapper library and CLI for papertrail API.Installation------------Install using pip:.. code:: bash$ pip install pypertrailRequirements------------- Python 2.6, 2.7, 3.3, 3.4, or 3.5- A Papertrail accountLibrary-------Accounts~~~~~~~~.. code:: pythonimport osfrom pypertrail.accounts import Accountaccounts = Account(os.environ['PAPERTRAIL_API_TOKEN'])# List account usageaccounts.list()Archives~~~~~~~~.. code:: pythonimport osfrom pypertrail.archives import Archivearchives = Archive(os.environ['PAPERTRAIL_API_TOKEN'])# List archive informationarchives.list()Groups~~~~~~.. code:: pythonimport osfrom pypertrail.groups import Groupgroups = Group(os.environ['PAPERTRAIL_API_TOKEN'])# List groupsgroups.list()# Show a groupgroups.show(group_id)# Update a groupgroups.update(group_id)# Delete a groupgroups.delete(group_id)Saved searches~~~~~~~~~~~~~~.. code:: pythonimport osfrom pypertrail.saved_searches import SavedSearchsaved_searches = SavedSearch(os.environ['PAPERTRAIL_API_TOKEN'])# List saved_searchessaved_searches.list()# Show a saved searchsaved_searches.show(saved_search_id)# Create a saved searchpayload = {'name':'my_query', 'query':'sshd'}saved_searches.create(payload)# Update a saved searchpayload = {'search[query]':'another_query'}saved_searches.update(payload)# Delete a saved searchsaved_searches.delete(saved_search_id)Search~~~~~~~~~~~~~~.. code:: pythonimport osfrom pypertrail.search import Searchsearch = Search(os.environ['PAPERTRAIL_API_TOKEN'])# Search eventssearch.events("sshd")Systems~~~~~~.. code:: pythonimport osfrom pypertrail.systems import Systemsystems = Search(os.environ['PAPERTRAIL_API_TOKEN'])# List systemssystems.list()# Show a systemsystems.show(system_id)# Create a systempayload = {'system[name]':'foo', 'system[hostname]':'bar', 'destination_port':46865}systems.create(payload)# Update a systempayload = {'system[name]':'another_name'}systems.update(system_id, payload)# Delete a systemsystems.delete(system_id)# Join a grouppayload = {'group_id':10}systems.join_group(system_id, payload)# Leave a grouppayload = {'group_id':10}systems.leave_group(system_id, payload)Users~~~~~.. code:: pythonimport osfrom pypertrail.users import Userusers = User(os.environ['PAPERTRAIL_API_TOKEN'])# List usersusers.list()# Invite a userpayload = {'email':'contact@quent.in', 'read_only':'true'}users.invite(payload)# Delete a userusers.delete(user_id)CLI---CLI Authentication~~~~~~~~~~~~~~~~~~Via environment variables:.. code:: bash$ export PAPERTRAIL_API_TOKEN=my_token$ pypertrail users listVia implicit ~/.pypertrail.yml:.. code:: bash$ echo "token: my_token" > ~/.pypertrail.yml$ pypertrail users listVia (--conf/-c) option:.. code:: bash$ echo "token: my_token" > /path/to/config$ pypertrail --conf /path/to/config users listVia (--token/-t) option:.. code:: bash$ pypertrail --token my_token users listSubcommands~~~~~~~~~~~.. code:: plainUsage: pypertrail.py [OPTIONS] COMMAND [ARGS]...Options:-d, --debug       Debug mode.-p, --pretty      Prettify JSON output.-t, --token TEXT  Papertrail API token.-c, --conf TEXT   Path to config (~/.pypertrail.yml).--version         Show the version and exit.-h, --help        Show this message and exit.Commands:accountsarchivesgroupssaved_searchessearchsystemsusersAccounts~~~~~~~~.. code:: plainUsage: papertrail.py accounts [OPTIONS] COMMAND [ARGS]...Options:-h, --help  Show this message and exit.Commands:list  List account usageExamples:.. code:: bash$ pypertrail --pretty accounts listArchives~~~~~~~~.. code:: plainUsage: papertrail.py archives [OPTIONS] COMMAND [ARGS]...Options:-h, --help  Show this message and exit.Commands:list  List archive informationExamples:.. code:: bash$ pypertrail --pretty archives listSaved searches~~~~~~~~~~~~~~.. code:: plainUsage: cli.py saved_searches [OPTIONS] COMMAND [ARGS]...Options:-h, --help  Show this message and exit.Commands:create  Create a saved searchdelete  Delete a saved searchlist    List saved_searchesshow    Show a saved searchupdate  Update a saved searchExamples:.. code:: bash$ pypertrail saved_searches create --payload '{"search[name]":"foo", "search[query]":"bar"}'$ pypertrail saved_searches delete 1$ pypertrail saved_searches list$ pypertrail saved_searches show 1$ pypertrail saved_searches update 1 --payload '{"search[query]":"another_query"}'Groups~~~~~~.. code:: plainUsage: papertrail.py groups [OPTIONS] COMMAND [ARGS]...Options:-h, --help  Show this message and exit.Commands:delete  Delete a grouplist    List groupsshow    Show a groupupdate  Update a groupExamples:.. code:: bash$ pypertrail groups delete 1$ pypertrail groups list$ pypertrail groups show 1$ pypertrail groups update 1 --payload '{"group[name]":"another_name"}'Search~~~~~~.. code:: plainUsage: papertrail.py search events [OPTIONS]Search eventsOptions:-q, --query TEXT                Terms to query.-s, --system INTEGER            System to search.-g, --group INTEGER             Group to search.-e, --min-time INTEGER          Earliest time to search from.-l, --max-time INTEGER          Latest time to search from.-f, --follow                    Continue running and printing new events(off).-d, --delay INTEGER             Delay between refresh (5).-j, --json                      Output raw JSON data (off).-c, --color [program|system|all|off]Attribute(s) to colorize based on (program).-h, --help                      Show this message and exit.Examples:.. code:: bash$ pypertrail search events$ pypertrail search events --follow$ pypertrail search events --follow --color program$ pypertrail search events --follow --query sshd$ pypertrail search events --follow --jsonSystems~~~~~~~.. code:: plainUsage: papertrail.py systems [OPTIONS] COMMAND [ARGS]...Options:-h, --help  Show this message and exit.Commands:create       Create a saved searchdelete       Delete a systemjoin_group   Join a groupleave_group  Leave a grouplist         List systemsshow         Show a systemupdate       Update a systemExamples:.. code:: bash$ pypertrail systems create --payload '{"system[name]":"foo", "system[hostname]":"bar", "destination_port":46865}'$ pypertrail systems delete 1$ pypertrail systems join_group 1 --payload '{"group_id":10}'$ pypertrail systems leave_group 1 --payload '{"group_id":10}'$ pypertrail systems list$ pypertrail systems show 1$ pypertrail systems update 1 --payload '{"system[name]":"another_name"}'Users~~~~~.. code:: plainUsage: papertrail.py users [OPTIONS] COMMAND [ARGS]...Options:-h, --help  Show this message and exit.Commands:delete  Delete a userinvite  Invite a userlist    List usersExamples:.. code:: bash$ pypertrail users delete 1$ pypertrail users invite --payload '{"email":"contact@quent.in", "read_only":true}'$ pypertrail users listDocumentation=============- https://pypertrail.readthedocs.io- http://help.papertrailapp.com/kb/how-it-works/http-apiHistory=======View the `changelog`_Authors=======-  `Quentin Rousseau`_License=======.. code:: plainCopyright (c) 2016 Quentin Rousseau <contact@quent.in>Permission is hereby granted, free of charge, to any personobtaining a copy of this software and associated documentationfiles (the "Software"), to deal in the Software withoutrestriction, including without limitation the rights to use,copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom theSoftware is furnished to do so, subject to the followingconditions:The above copyright notice and this permission notice shall beincluded in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIESOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE ANDNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHTHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISINGFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OROTHER DEALINGS IN THE SOFTWARE... _changelog: https://github.com/kwent/pypertrail/blob/master/HISTORY.rst.. _Quentin Rousseau: https://github.com/kwent.. |pypi| image:: https://img.shields.io/pypi/v/pypertrail.svg:target: https://pypi.python.org/pypi/pypertrail.. |travis| image:: https://img.shields.io/travis/kwent/pypertrail.svg:target: https://travis-ci.org/kwent/pypertrail.. |doc| image:: https://readthedocs.org/projects/pypertrail/badge/?version=latest:target: https://pypertrail.readthedocs.io/en/latest/?badge=latest.. |pyup| image:: https://pyup.io/repos/github/kwent/pypertrail/shield.svg:target: https://pyup.io/repos/github/kwent/pypertrail/=======History=======1.0.0 (2016-10-06)------------------* First release on PyPI.