Files

245 lines
5.2 KiB
ReStructuredText
Raw Permalink Normal View History

2018-02-05 14:43:08 -06:00
========
Overview
========
.. start-badges
.. list-table::
:stub-columns: 1
* - tests
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
.. |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
2019-01-02 12:35:30 -06:00
:target: https://pypi.org/project/octokitpy/
2018-02-05 14:43:08 -06:00
.. |wheel| image:: https://img.shields.io/pypi/wheel/octokitpy.svg
:alt: PyPI Wheel
2019-01-02 12:35:30 -06:00
:target: https://pypi.org/project/octokitpy/
2018-02-05 14:43:08 -06:00
.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/octokitpy.svg
:alt: Supported versions
2019-01-02 12:35:30 -06:00
:target: https://pypi.org/project/octokitpy/
2018-02-05 14:43:08 -06:00
.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/octokitpy.svg
:alt: Supported implementations
2019-01-02 12:35:30 -06:00
:target: https://pypi.org/project/octokitpy/
2018-02-05 14:43:08 -06:00
.. end-badges
Python client for GitHub API
Installation
============
*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
2020-04-15 19:56:24 -05:00
repos = Octokit().repos.list_for_user(username="octokit")
for repo in repos.json:
print(repo["name"])
# Make an unauthenticated request for octokit's public repositories
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.
2020-04-13 15:13:23 -05:00
Note that webhook names are available at :code:`from octokit_routes import webhook_names`
2018-02-05 14:43:08 -06:00
Authentication
--------------
2019-10-18 01:12:09 -07:00
Instantiate a client with the authentication scheme and credentials that you want to use.
2018-02-05 14:43:08 -06:00
basic::
2018-02-05 14:43:08 -06:00
octokit = Octokit(auth='basic', username='myuser', password='mypassword')
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 installation::
octokit = Octokit(auth='installation', app_id='42', private_key=private_key)
2019-10-18 01:12:09 -07:00
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
2019-01-02 14:47:07 -06:00
API Schema/Routes/Specifications
--------------------------------
One can instantiate the ``Octokit`` with ``routes=specification`` where the ``specification`` is one of ``api.github.com``, ``ghe-2.15``, etc.
2020-04-14 08:27:18 -05:00
Data
----
The :code:`octokit` client based on the available `route data <https://github.com/khornberg/octokitpy-routes>`_ and `webhook data <https://github.com/khornberg/octokitpy-routes>`_
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
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
2020-04-14 08:27:18 -05:00
[x] coverage uploaded to code climate
Errors
------
::
2020-04-14 08:27:18 -05:00
[ ] Raise `OctokitValidationError` for param validation error
2020-04-14 08:27:18 -05:00
[ ] Raise `OctokitAuthenticationError` for auth error
2020-04-14 08:27:18 -05:00
[ ] Raise `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
2019-01-02 14:47:07 -06:00
[x] pagination
2018-02-05 14:43:08 -06:00
2022-10-07 16:35:16 -05:00
Generated Documentation
-----------------------
2018-02-08 09:27:58 -06:00
::
[ ] Auto generated documentation
Deployment
----------
::
2019-01-02 14:47:07 -06:00
[x] Deploy wheels
2020-04-13 15:13:23 -05:00
2020-04-14 08:27:18 -05:00
[ ] GitHub releases
2018-02-08 09:27:58 -06:00
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