Files
octokit.py/README.rst
T

251 lines
5.7 KiB
ReStructuredText
Raw Normal View History

2018-02-05 14:43:08 -06:00
========
Overview
========
.. start-badges
.. list-table::
:stub-columns: 1
* - tests
2018-02-07 09:23:16 -06:00
- | |travis| |pyup|
2018-02-06 09:03:53 -06:00
| |codeclimate| |codeclimate-tests|
2018-02-05 14:43:08 -06:00
* - package
2018-02-07 09:23:16 -06:00
- | |version| |wheel|
| |supported-versions| |supported-implementations|
* - docs
- |docs|
2018-02-05 14:43:08 -06:00
2018-02-07 08:52:13 -06:00
.. |docs| image:: http://octokitpy.readthedocs.io/en/latest/?badge=latest
2018-02-05 14:43:08 -06:00
:target: https://readthedocs.org/projects/octokitpy
:alt: Documentation Status
.. |travis| image:: https://travis-ci.org/khornberg/octokit.py.svg?branch=master
:alt: Travis-CI Build Status
:target: https://travis-ci.org/khornberg/octokit.py
2018-02-07 09:23:16 -06:00
.. |pyup| image:: https://pyup.io/repos/github/khornberg/octokit.py/shield.svg
:target: https://pyup.io/repos/github/khornberg/octokit.py/
:alt: Updates
2018-02-05 14:43:08 -06:00
.. |codeclimate| image:: https://codeclimate.com/github/khornberg/octokit.py/badges/gpa.svg
:target: https://codeclimate.com/github/khornberg/octokit.py
:alt: CodeClimate Quality Status
2018-02-06 09:03:53 -06:00
.. |codeclimate-tests| image:: https://api.codeclimate.com/v1/badges/7954d60682bc6d6c15cd/test_coverage
:target: https://codeclimate.com/github/khornberg/octokit.py
:alt: Test Coverage
2018-02-05 14:43:08 -06:00
.. |version| image:: https://img.shields.io/pypi/v/octokitpy.svg
:alt: PyPI Package latest release
:target: https://pypi.python.org/pypi/octokitpy
.. |wheel| image:: https://img.shields.io/pypi/wheel/octokitpy.svg
:alt: PyPI Wheel
:target: https://pypi.python.org/pypi/octokitpy
.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/octokitpy.svg
:alt: Supported versions
:target: https://pypi.python.org/pypi/octokitpy
.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/octokitpy.svg
:alt: Supported implementations
:target: https://pypi.python.org/pypi/octokitpy
.. end-badges
Python client for GitHub API
Installation
============
2018-02-20 07:45:08 -06:00
**requires python 3.4+**
2018-02-05 14:43:08 -06:00
Yes that is opinionated. Python 2 is near the end of the life and this is a new project.
*Note octokit and octokit.py were already taken in the cheese shop*
::
pip install octokitpy
Documentation
=============
https://octokitpy.readthedocs.io/en/latest/
2018-02-05 14:43:08 -06:00
Examples
--------
2018-02-05 14:43:08 -06:00
2018-02-06 14:08:28 -06:00
REST API::
2018-02-06 07:42:31 -06:00
2018-02-05 14:43:08 -06:00
from octokit import Octokit
2018-02-06 14:08:28 -06:00
repos = Octokit().repos.get_for_org(org='octokit', type='public')
# Make an unauthenticated request for the public repositories of the octokit organization
2018-02-05 14:43:08 -06:00
2018-02-06 14:18:47 -06:00
Webhooks::
from octokit import webhook
webhook.verify(headers, payload, secret, events=['push'])
:code:`octokit.py` provides a function to verify `webhooks <https://developer.github.com/webhooks/>`_ sent to your application.
headers
dictionary of request headers
payload
2018-02-09 13:12:14 -06:00
string; payload of request
secret
string; secret provided to GitHub to sign webhook
events
list; events that you want to receive
verify_user_agent
boolean; whether or not you want to verify the user agent string of the request
return_app_id
boolean; whether or not you want to return the app id from the ping event for GitHub applications. This will only return the ``id`` if the event is the ``ping`` event. Otherwise the return value will be boolean.
2018-02-05 14:43:08 -06:00
Authentication
--------------
Instatiate a client with the authentication scheme and credentials that you want to use.
basic::
2018-02-05 14:43:08 -06:00
octokit = Octokit(auth='basic', username='myuser', password='mypassword')
octokit.repos.get_for_org(org='octokit', type='private')
2018-02-05 14:43:08 -06:00
token::
2018-02-06 07:42:31 -06:00
response = Octokit(auth='token', token='yak').authorization.get(id=100)
2018-02-06 07:42:31 -06:00
app::
2018-02-06 07:42:31 -06:00
octokit = Octokit(auth='app', app_id=42, private_key=private_key)
2018-02-06 07:42:31 -06:00
app::
octokit = Octokit(auth='installation', app_id=42, private_key=private_key)
For applications provide the application id either from the ping webhook or the application's page on GitHub.
The :code:`private_key` is a string of your private key provided for the application.
The :code:`app` scheme will use the application id and private key to get a token for the first installation id of the application.
2018-02-06 07:42:31 -06:00
TODOs
===========
2018-02-06 07:42:31 -06:00
GitHub APIs
-----------
2018-02-06 07:42:31 -06:00
::
2018-02-06 07:42:31 -06:00
[-] REST (see best practices, integration tests, and errors)
[ ] GraphQL client
[x] GitHub Apps
2018-02-06 07:42:31 -06:00
[ ] OAuth Apps
2018-02-05 14:43:08 -06:00
[x] Webhooks
2018-02-05 14:43:08 -06:00
Data
----
The :code:`octokit` client based on the available `rest data <https://github.com/octokit/rest.js/blob/master/lib/routes.json>`_ and `webhook data <https://github.com/octokit/webhooks.js/blob/master/lib/webhook-names.json>`_
2018-02-05 14:43:08 -06:00
2018-02-06 07:42:31 -06:00
::
[ ] Periodically, check if ``routes.json`` has changed and if so fetch and open a PR for it to be merged
2018-02-05 14:43:08 -06:00
[ ] Periodically, check if ``webhook-names.json`` has changed and if so fetch and open a PR for it to be merged
2018-02-05 14:43:08 -06:00
Tests
-----
2018-02-05 14:43:08 -06:00
::
2018-02-05 14:43:08 -06:00
[x] unit tests
2018-02-05 14:43:08 -06:00
[ ] integration tests - need fixtures to assert against
2018-02-05 14:43:08 -06:00
[ ] coverage uploaded to code climate -- not sure why it is not working
Errors
------
::
[ ] Raise :code:`OctokitValidationError` for param validation error
[ ] Raise :code:`OctokitAuthenticationError` for auth error
[ ] Raise :code:`OctokitRateLimitError` for rate limiting errors
Best Practices
--------------
::
[ ] throttling
2018-02-05 14:43:08 -06:00
[ ] handles rate limiting
2018-02-05 14:43:08 -06:00
[ ] pagination
2018-02-05 14:43:08 -06:00
2018-02-08 09:27:58 -06:00
Documentation
-------------
::
[ ] Auto generated documentation
Deployment
----------
::
[ ] Deploy wheels
[ ] Make GitHub releases work
2018-02-05 14:43:08 -06:00
**Check box guide**
::
[ ] Incomplete
[-] Partially completed
[x] Completed
Development
===========
To run the all tests run::
tox
2018-02-05 14:43:08 -06:00
Contributing
============
Pull requests are very welcome!
2018-02-06 09:03:53 -06:00
Please see CONTRIBUTING.md for more information.
2018-02-05 14:43:08 -06:00
Credits
=======
2018-02-06 07:42:31 -06:00
Package based on `cookiecutter-pylibrary <https://github.com/ionelmc/cookiecutter-pylibrary>`_
2018-02-05 14:43:08 -06:00
License
=======
2018-02-06 07:42:31 -06:00
MIT