A python wrapper for the AllSpice Hub API
Project description
py-allspice
A very simple API client for AllSpice Hub
Note that not the full Swagger-API is accessible. The whole implementation is focused on making access and working with Organizations, Teams, Repositories and Users as pain free as possible.
Forked from https://github.com/Langenfeld/py-gitea.
Usage
First get an allspice
object wrapping access and authentication (via an api token) for your gitea instance:
from gitea import *
allspice = Gitea(URL, TOKEN)
Operations like requesting the Allspice version or authentication user can be requested directly from the allspice
object:
print("AllSpice Version: " + allspice.get_version())
print("API-Token belongs to user: " + allspice.get_user().username)
Adding entities like Users, Organizations, ... also is done via the allspice object.
user = allspice.create_user("Test Testson", "test@test.test", "password")
All operations on entities in allspice are then accomplished via the according wrapper objects for those entities.
Each of those objects has a .request
method that creates an entity according to your allspice instance.
other_user = User.request(allspice, "OtherUserName")
print(other_user.username)
Note that the fields of the User, Organization,... classes are dynamically created at runtime, and thus not visible during divelopment. Refer to the AllSpice-API documentation for the fields names.
Fields that can not be altered via allspice-api, are read only. After altering a field, the .commit
method of the according object must be called to synchronize the changed fields with your allspice instance.
org = Organization.request(allspice, test_org)
org.description = "some new description"
org.location = "some new location"
org.commit()
An entity in allspice can be deleted by calling delete.
org.delete()
All entity objects do have methods to execute some of the requests possible though the allspice-api:
org = Organization.request(allspice, ORGNAME)
teams = org.get_teams()
for team in teams:
repos = team.get_repos()
for repo in repos:
print(repo.name)
Installation
Use pip install py-allspice
to install.
Tests
Tests can be run with:
python3 -m pytest test_api.py
Make sure to have a allspice-instance running on http://localhost:3000
, and an admin-user token at .token
.
The admin user must be named test
, with email secondarytest@test.org
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file py-allspice-1.17.0.tar.gz
.
File metadata
- Download URL: py-allspice-1.17.0.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4c308dd02874e5b7c36d94176574e0031d2bed7869e0cffe3b08e4dbbb7135a |
|
MD5 | da00f5269c74c5cb85829f00a3956c02 |
|
BLAKE2b-256 | 4b7256f9e0500f6df14656c980d3b739fb67c332b27c70a61921d85354f295dd |
File details
Details for the file py_allspice-1.17.0-py3-none-any.whl
.
File metadata
- Download URL: py_allspice-1.17.0-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 490eeebd5b9510147076b241e8ad70b02381e91b05bf256c349aa20456bd6f36 |
|
MD5 | f72b70d7871237e53e19f3fc230bc766 |
|
BLAKE2b-256 | 786d4b715eaec114e41bf310a88f0f2cf12413416972c9b5e84278b21e9e3a9e |