Skip to content
/ pytea Public
forked from arount/pytea

Gitea API wrapper for Python

License

Notifications You must be signed in to change notification settings

amiga23/pytea

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pytea

Gitea API wrapper for Python (3 only).

Install

From sources

python setup.py install

With Pip

pip install git+https://github.com/arount/pytea

Basic usage

import pytea

api = pytea.API('http://192.168.100.10:3000')
api.get('/version')
api.get('/orgs/an-organisation/members')

Authentification token

Setup authentification token:

import pytea
api = pytea.API('http://192.168.100.10:3000', token="AUTH-TOKEN")
api.delete('/admin/users/arount')

Main API methods

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

Alternative API method

# Send GET query to route with parameters
api.call('route', method='get', params={"body": "Egg, bacon, sausages and SPAM")

Exceptions

Exceptions are raised before sending query. If API respond error message no exception will be raised (for the moment, at least)

Authentification token

If auth token is not set when you are trying to access to a protected resource:

api = pytea.API('http://192.168.100.10:3000')
api.delete('/admin/users/arount')
pytea.PyteaRequestException: Resource '/admin/users/{username}' require an authentification token.

Resource do not exists

api.get('/fake/route')
pytea.PyteaRequestException: Path '/fake/route' did not match with any resource

Method do not exists for resource

api.delete('/markdown')
pytea.PyteaRequestException: Resource '/markdown' did not expect method DELETE

About

Gitea API wrapper for Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%