Gitea API wrapper for Python (3 only).
pip install git+https://github.com/h44z/pygitea
import pygitea
api = pygitea.API('http://192.168.100.10:3000')
api.get('/version')
api.get('/orgs/an-organisation/members')
Setup authentification token:
import pygitea
api = pygitea.API('http://192.168.100.10:3000', token="AUTH-TOKEN")
api.delete('/admin/users/arount')
api.get('route') # Send GET query to route
api.post('route') # Send POST query to route
api.patch('route') # Send PATCH query to route
api.put('route') # Send PUT query to route
# Send GET query to route with parameters
api.call('route', method='get', params={"body": "Egg, bacon, sausages and SPAM")
Exceptions are raised before sending query. If API respond error message no exception will be raised (for the moment, at least)
If auth token is not set when you are trying to access to a protected resource:
api = pygitea.API('http://192.168.100.10:3000')
api.delete('/admin/users/arount')
pygitea.PygiteaRequestException: Resource '/admin/users/{username}' require an authentification token.
api.get('/fake/route')
pygitea.PygiteaRequestException: Path '/fake/route' did not match with any resource
api.delete('/markdown')
pygitea.PygiteaRequestException: Resource '/markdown' did not expect method DELETE