kopia lustrzana https://github.com/Langenfeld/py-gitea
Update package info
rodzic
3b8f04e31b
commit
138513b4c6
1
LICENSE
1
LICENSE
|
@ -1,5 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2023 AllSpice, Inc.
|
||||
Copyright (c) 2017 Madhurendra Sachan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
|
44
README.md
44
README.md
|
@ -1,66 +1,64 @@
|
|||
# py-gitea
|
||||
# py-allspice
|
||||
|
||||
A very simple API client for Gitea > 1.16.1
|
||||
|
||||
This has been somewhat tested (and used), so most things should work as expected.
|
||||
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.
|
||||
|
||||
Originally forked from https://github.com/m301/py-gitea.
|
||||
Forked from https://github.com/Langenfeld/py-gitea.
|
||||
|
||||
## Usage
|
||||
|
||||
First get a `gitea` object wrapping access and authentication (via an api token) for your gitea instance:
|
||||
First get an `allspice` object wrapping access and authentication (via an api token) for your gitea instance:
|
||||
|
||||
```python
|
||||
from gitea import *
|
||||
|
||||
gitea = Gitea(URL, TOKEN)
|
||||
allspice = Gitea(URL, TOKEN)
|
||||
```
|
||||
|
||||
Operations like requesting the Gitea version or authentication user can be requested directly from the `gitea` object:
|
||||
Operations like requesting the Allspice version or authentication user can be requested directly from the `allspice` object:
|
||||
|
||||
```python
|
||||
print("Gitea Version: " + gitea.get_version())
|
||||
print("API-Token belongs to user: " + gitea.get_user().username)
|
||||
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 gitea object.
|
||||
Adding entities like Users, Organizations, ... also is done via the allspice object.
|
||||
|
||||
```python
|
||||
user = gitea.create_user("Test Testson", "test@test.test", "password")
|
||||
user = allspice.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.
|
||||
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.
|
||||
|
||||
```python
|
||||
other_user = User.request(gitea, "OtherUserName")
|
||||
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 Gitea-API documentation for the fields names.
|
||||
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 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.
|
||||
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.
|
||||
|
||||
```python
|
||||
org = Organization.request(gitea, test_org)
|
||||
org = Organization.request(allspice, test_org)
|
||||
org.description = "some new description"
|
||||
org.location = "some new location"
|
||||
org.commit()
|
||||
```
|
||||
|
||||
An entity in gitea can be deleted by calling delete.
|
||||
An entity in allspice can be deleted by calling delete.
|
||||
```python
|
||||
org.delete()
|
||||
```
|
||||
|
||||
All entity objects do have methods to execute some of the requests possible though the gitea-api:
|
||||
All entity objects do have methods to execute some of the requests possible though the allspice-api:
|
||||
```python
|
||||
org = Organization.request(gitea, ORGNAME)
|
||||
org = Organization.request(allspice, ORGNAME)
|
||||
teams = org.get_teams()
|
||||
for team in teams:
|
||||
repos = team.get_repos()
|
||||
|
@ -71,7 +69,7 @@ for team in teams:
|
|||
|
||||
## Installation
|
||||
|
||||
Use ``pip install py-gitea`` to install.
|
||||
Use ``pip install py-allspice`` to install.
|
||||
|
||||
## Tests
|
||||
|
||||
|
@ -79,5 +77,5 @@ 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`.
|
||||
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``.
|
||||
|
|
14
setup.py
14
setup.py
|
@ -4,18 +4,18 @@ with open('README.md') as readme_file:
|
|||
README = readme_file.read()
|
||||
|
||||
setup_args = dict(
|
||||
name='py-gitea',
|
||||
version='0.2.6',
|
||||
description='A python wrapper for the Gitea API',
|
||||
name='py-allspice',
|
||||
version='{{VERSION_PLACEHOLDER}}',
|
||||
description='A python wrapper for the AllSpice Hub API',
|
||||
long_description_content_type="text/markdown",
|
||||
long_description=README,
|
||||
license='MIT',
|
||||
packages=find_packages(),
|
||||
author='Vincent Langenfeld ',
|
||||
author_email='langenfv@tf.uni-freiburg.de',
|
||||
keywords=['Gitea','api','wrapper'],
|
||||
author='AllSpice, Inc.',
|
||||
author_email='maintainers@allspice.io',
|
||||
keywords=['AllSpice','AllSpice Hub','api','wrapper'],
|
||||
url='https://github.com/Langenfeld/py-gitea',
|
||||
download_url='https://pypi.org/project/py-gitea/'
|
||||
download_url='https://github.com/AllSpiceIO/py-allspice'
|
||||
)
|
||||
|
||||
install_requires = [
|
||||
|
|
Ładowanie…
Reference in New Issue