py-gitea


Namepy-gitea JSON
Version 0.2.8 PyPI version JSON
download
home_pagehttps://github.com/Langenfeld/py-gitea
SummaryA python wrapper for the Gitea API
upload_time2024-01-18 19:15:55
maintainer
docs_urlNone
authorVincent Langenfeld
requires_python
licenseMIT
keywords gitea api wrapper
VCS
bugtrack_url
requirements requests pytest immutabledict
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

```python
from gitea import *

gitea = Gitea(URL, TOKEN)
```

Operations like requesting the Gitea version or authentication user can be requested directly from the `gitea` object:

```python
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.

```python
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.

```python
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.

```python
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.

```python
org.delete()
```

All entity objects do have methods to execute some of the requests possible though the gitea-api:

```python
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``.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Langenfeld/py-gitea",
    "name": "py-gitea",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Gitea,api,wrapper",
    "author": "Vincent Langenfeld",
    "author_email": "langenfv@tf.uni-freiburg.de",
    "download_url": "https://files.pythonhosted.org/packages/d1/92/e88bea3c6f5a916a78267a90541380966711976987057d75d026b8a0e857/py-gitea-0.2.8.tar.gz",
    "platform": null,
    "description": "# py-gitea\r\n\r\nA very simple API client for Gitea > 1.16.1\r\n\r\nThis has been somewhat tested (and used), so most things should work as expected.\r\n\r\nNote that not the full Swagger-API is accessible. The whole implementation is focused\r\non making access and working with Organizations, Teams, Repositories and Users as pain\r\nfree as possible.\r\n\r\nOriginally forked from https://github.com/m301/py-gitea.\r\n\r\n## Usage\r\n\r\nFirst get a `gitea` object wrapping access and authentication (via an api token) for your gitea instance:\r\n\r\n```python\r\nfrom gitea import *\r\n\r\ngitea = Gitea(URL, TOKEN)\r\n```\r\n\r\nOperations like requesting the Gitea version or authentication user can be requested directly from the `gitea` object:\r\n\r\n```python\r\nprint(\"Gitea Version: \" + gitea.get_version())\r\nprint(\"API-Token belongs to user: \" + gitea.get_user().username)\r\n```\r\n\r\nAdding entities like Users, Organizations, ... also is done via the gitea object.\r\n\r\n```python\r\nuser = gitea.create_user(\"Test Testson\", \"test@test.test\", \"password\")\r\n```\r\n\r\nAll operations on entities in gitea are then accomplished via the according wrapper objects for those entities.\r\nEach of those objects has a `.request` method that creates an entity according to your gitea instance.\r\n\r\n```python\r\nother_user = User.request(gitea, \"OtherUserName\")\r\nprint(other_user.username)\r\n```\r\n\r\nNote that the fields of the User, Organization,... classes are dynamically created at runtime, and thus not visible\r\nduring divelopment. Refer to the Gitea-API documentation for the fields names.\r\n\r\nFields that can not be altered via gitea-api, are read only. After altering a field, the `.commit` method of the\r\naccording object must be called to synchronize the changed fields with your gitea instance.\r\n\r\n```python\r\norg = Organization.request(gitea, test_org)\r\norg.description = \"some new description\"\r\norg.location = \"some new location\"\r\norg.commit()\r\n```\r\n\r\nAn entity in gitea can be deleted by calling delete.\r\n\r\n```python\r\norg.delete()\r\n```\r\n\r\nAll entity objects do have methods to execute some of the requests possible though the gitea-api:\r\n\r\n```python\r\norg = Organization.request(gitea, ORGNAME)\r\nteams = org.get_teams()\r\nfor team in teams:\r\n    repos = team.get_repos()\r\n    for repo in repos:\r\n        print(repo.name)\r\n```\r\n\r\n## Installation\r\n\r\nUse ``pip install py-gitea`` to install.\r\n\r\n## Tests\r\n\r\nTests can be run with:\r\n\r\n```python3 -m pytest test_api.py```\r\n\r\nMake sure to have a gitea-instance running on `http://localhost:3000`, and an admin-user token at `.token`.\r\nThe admin user must be named ``test``, with email ``secondarytest@test.org``.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A python wrapper for the Gitea API",
    "version": "0.2.8",
    "project_urls": {
        "Download": "https://pypi.org/project/py-gitea/",
        "Homepage": "https://github.com/Langenfeld/py-gitea"
    },
    "split_keywords": [
        "gitea",
        "api",
        "wrapper"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0be6b609b2fa50becb63dc80ee75a7f631db8dec21b5548cb20b98bc9ef4b326",
                "md5": "9e198b3444b0973d934300d439cd5191",
                "sha256": "aa9433cb83a528a8560de7affc0d85a838de17a7b28b43be5f0066341af4fda8"
            },
            "downloads": -1,
            "filename": "py_gitea-0.2.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9e198b3444b0973d934300d439cd5191",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 15695,
            "upload_time": "2024-01-18T19:15:54",
            "upload_time_iso_8601": "2024-01-18T19:15:54.470965Z",
            "url": "https://files.pythonhosted.org/packages/0b/e6/b609b2fa50becb63dc80ee75a7f631db8dec21b5548cb20b98bc9ef4b326/py_gitea-0.2.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d192e88bea3c6f5a916a78267a90541380966711976987057d75d026b8a0e857",
                "md5": "dc0e4a8ecdf3564c74eb3cee9b9d176d",
                "sha256": "f7641ea0818529b59f3ca9c38b106a5c2ba06a0f662a022f76a62919f17e8379"
            },
            "downloads": -1,
            "filename": "py-gitea-0.2.8.tar.gz",
            "has_sig": false,
            "md5_digest": "dc0e4a8ecdf3564c74eb3cee9b9d176d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 19076,
            "upload_time": "2024-01-18T19:15:55",
            "upload_time_iso_8601": "2024-01-18T19:15:55.761024Z",
            "url": "https://files.pythonhosted.org/packages/d1/92/e88bea3c6f5a916a78267a90541380966711976987057d75d026b8a0e857/py-gitea-0.2.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-18 19:15:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Langenfeld",
    "github_project": "py-gitea",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "immutabledict",
            "specs": []
        }
    ],
    "lcname": "py-gitea"
}
        
Elapsed time: 0.16208s