Skip to main content

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

Examples

Check the examples directory for full, working example scripts that you can adapt or refer to for your own needs.

Quickstart

First get an allspice_client object wrapping access and authentication (via an api token) for your instance of AllSpice Hub.

from allspice import *

# By default, points to hub.allspice.io.
allspice_client = AllSpice(token_text=TOKEN)

# If you are self-hosting:
allspice_client = AllSpice(allspice_hub_url=URL, token_text=TOKEN)

Operations like requesting the AllSpice version or authentication user can be requested directly from the allspice_client object:

print("AllSpice Version: " + allspice_client.get_version())
print("API-Token belongs to user: " + allspice_client.get_user().username)

Adding entities like Users, Organizations, ... also is done via the allspice_client object.

user = allspice_client.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_client instance.

other_user = User.request(allspice_client, "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_client instance.

org = Organization.request(allspice_client, 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_client, 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.

A Note on Versioning

This repository does not follow the same versioning policy as py-gitea. After v1.17.x, py-allspice switched to Semantic Versioning with v2.0.0. In general, versions of py-allspice do NOT conform to versions of AllSpice Hub, and the latest version of py-allspice should be compatible with the current version of AllSpice Hub.

Tests

Tests can be run with:

python3 -m pytest test_api.py

Make sure to have an instance of AllSpice Hub 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_allspice-3.0.0.tar.gz (39.4 kB view details)

Uploaded Source

Built Distribution

py_allspice-3.0.0-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

Details for the file py_allspice-3.0.0.tar.gz.

File metadata

  • Download URL: py_allspice-3.0.0.tar.gz
  • Upload date:
  • Size: 39.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for py_allspice-3.0.0.tar.gz
Algorithm Hash digest
SHA256 e90d53c208101fe650bb82a256ace37ca052c032968cb8632a10d6ee9baa012e
MD5 781437281a69c1c1bd6e4def79dd123e
BLAKE2b-256 53584f285284c54da2da8927bef331f6dfd523ef7c4e1652e5cfa699df8dc9a2

See more details on using hashes here.

File details

Details for the file py_allspice-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: py_allspice-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 33.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for py_allspice-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a3fc7720a24402d49ba8af7e41a54685995beba4ce1d167a6c004b54dcc4c46
MD5 6ee17dd2c1bbf3c916f3e239e11c806b
BLAKE2b-256 2afa72437dc7d7efca2db90cc6b5ffeae785f1428ea5454ca0a8e4e39750de1a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page