A python wrapper for the Gitea API
Project description
py-gitea
A very simple API client for Gitea > 1.16.1
This has been somewhat tested (and used), so most things should work as expected.
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.
Originally forked from https://github.com/m301/py-gitea.
Usage
First get a gitea object wrapping access and authentication (via an api token) for your gitea instance:
from gitea import *
gitea = Gitea(URL, TOKEN)
Operations like requesting the Gitea version or authentication user can be requested directly from the gitea object:
print("Gitea Version: " + gitea.get_version())
print("API-Token belongs to user: " + gitea.get_user().username)
Adding entities like Users, Organizations, ... also is done via the gitea object.
user = gitea.create_user("Test Testson", "test@test.test", "password")
All operations on entities in gitea 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 gitea instance.
other_user = User.request(gitea, "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 Gitea-API documentation for the fields names.
Fields that can not be altered via gitea-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 gitea instance.
org = Organization.request(gitea, test_org)
org.description = "some new description"
org.location = "some new location"
org.commit()
An entity in gitea can be deleted by calling delete.
org.delete()
All entity objects do have methods to execute some of the requests possible though the gitea-api:
org = Organization.request(gitea, 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-gitea to install.
Tests
Tests can be run with:
python3 -m pytest test_api.py
Make sure to have a gitea-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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_gitea-0.2.10.tar.gz.
File metadata
- Download URL: py_gitea-0.2.10.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f32a73aa951cb499b8cc2c0891a313794cd582c9dc2dc6aa80c237cbaacef361
|
|
| MD5 |
a5183d5d9a1dba4c6f0775ab2dfc8b1b
|
|
| BLAKE2b-256 |
331557ad97e05918fbf55636c3d069ac0d9c672f3cf2385a0fe1760b162b8810
|
Provenance
The following attestation bundles were made for py_gitea-0.2.10.tar.gz:
Publisher:
publish_pypi.yml on Langenfeld/py-gitea
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_gitea-0.2.10.tar.gz -
Subject digest:
f32a73aa951cb499b8cc2c0891a313794cd582c9dc2dc6aa80c237cbaacef361 - Sigstore transparency entry: 563466866
- Sigstore integration time:
-
Permalink:
Langenfeld/py-gitea@184d7292b3248fbbe5dc6ddc576dedb1e5fd7a8b -
Branch / Tag:
refs/heads/release - Owner: https://github.com/Langenfeld
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@184d7292b3248fbbe5dc6ddc576dedb1e5fd7a8b -
Trigger Event:
push
-
Statement type:
File details
Details for the file py_gitea-0.2.10-py3-none-any.whl.
File metadata
- Download URL: py_gitea-0.2.10-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87bd5a684d29e8af4cef8cde3bd7abcc3f7dfc7394c58f7f313468ea91656cd4
|
|
| MD5 |
89f159b53620be44dc82bc5303034ebd
|
|
| BLAKE2b-256 |
e95fcfc5867266d5779e13104d865064781f5d7d828aa7276ccd6eb14480c31b
|
Provenance
The following attestation bundles were made for py_gitea-0.2.10-py3-none-any.whl:
Publisher:
publish_pypi.yml on Langenfeld/py-gitea
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_gitea-0.2.10-py3-none-any.whl -
Subject digest:
87bd5a684d29e8af4cef8cde3bd7abcc3f7dfc7394c58f7f313468ea91656cd4 - Sigstore transparency entry: 563466885
- Sigstore integration time:
-
Permalink:
Langenfeld/py-gitea@184d7292b3248fbbe5dc6ddc576dedb1e5fd7a8b -
Branch / Tag:
refs/heads/release - Owner: https://github.com/Langenfeld
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@184d7292b3248fbbe5dc6ddc576dedb1e5fd7a8b -
Trigger Event:
push
-
Statement type: