py-allspice


Namepy-allspice JSON
Version 3.2.0 PyPI version JSON
download
home_pageNone
SummaryA python wrapper for the AllSpice Hub API
upload_time2024-06-12 20:44:53
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT
keywords allspice allspice hub api wrapper
VCS
bugtrack_url
requirements requests frozendict
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://github.com/AllSpiceIO/py-allspice/tree/main/examples)
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.

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

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

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

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

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

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

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

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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "py-allspice",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "AllSpice, AllSpice Hub, api, wrapper",
    "author": null,
    "author_email": "\"AllSpice, Inc.\" <maintainers@allspice.io>",
    "download_url": "https://files.pythonhosted.org/packages/4f/80/392430c1c71f952935da8b673ec0dfdcfa8f8ddc5fa8e8846f8798f42053/py_allspice-3.2.0.tar.gz",
    "platform": null,
    "description": "# py-allspice\n\nA very simple API client for AllSpice Hub\n\nNote that not the full Swagger-API is accessible. The whole implementation is focused\non making access and working with Organizations, Teams, Repositories and Users as pain\nfree as possible.\n\nForked from https://github.com/Langenfeld/py-gitea.\n\n## Usage\n\n### Examples\n\nCheck the [examples directory](https://github.com/AllSpiceIO/py-allspice/tree/main/examples)\nfor full, working example scripts that you can adapt or refer to for your own\nneeds.\n\n### Quickstart\n\nFirst get an `allspice_client` object wrapping access and authentication (via an api token) for your instance of AllSpice Hub.\n\n```python\nfrom allspice import *\n\n# By default, points to hub.allspice.io.\nallspice_client = AllSpice(token_text=TOKEN)\n\n# If you are self-hosting:\nallspice_client = AllSpice(allspice_hub_url=URL, token_text=TOKEN)\n```\n\nOperations like requesting the AllSpice version or authentication user can be requested directly from the `allspice_client` object:\n\n```python\nprint(\"AllSpice Version: \" + allspice_client.get_version())\nprint(\"API-Token belongs to user: \" + allspice_client.get_user().username)\n```\n\nAdding entities like Users, Organizations, ... also is done via the allspice_client object.\n\n```python\nuser = allspice_client.create_user(\"Test Testson\", \"test@test.test\", \"password\")\n```\n\nAll operations on entities in allspice are then accomplished via the according wrapper objects for those entities.\nEach of those objects has a `.request` method that creates an entity according to your allspice_client instance.\n\n```python\nother_user = User.request(allspice_client, \"OtherUserName\")\nprint(other_user.username)\n```\n\nNote 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.\n\nFields 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.\n\n```python\norg = Organization.request(allspice_client, test_org)\norg.description = \"some new description\"\norg.location = \"some new location\"\norg.commit()\n```\n\nAn entity in allspice can be deleted by calling delete.\n\n```python\norg.delete()\n```\n\nAll entity objects do have methods to execute some of the requests possible though the AllSpice api:\n\n```python\norg = Organization.request(allspice_client, ORGNAME)\nteams = org.get_teams()\nfor team in teams:\n\trepos = team.get_repos()\n\tfor repo in repos:\n\t\tprint(repo.name)\n```\n\n## Installation\n\nUse `pip install py-allspice` to install.\n\n## A Note on Versioning\n\nThis repository does not follow the same versioning policy as py-gitea. After v1.17.x,\npy-allspice switched to Semantic Versioning with v2.0.0. In general, versions of\npy-allspice do NOT conform to versions of AllSpice Hub, and the latest version of\npy-allspice should be compatible with the current version of AllSpice Hub.\n\n## Tests\n\nTests can be run with:\n\n`python3 -m pytest test_api.py`\n\nMake sure to have an instance of AllSpice Hub running on `http://localhost:3000`, and an admin-user token at `.token`.\nThe admin user must be named `test`, with email `secondarytest@test.org`.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A python wrapper for the AllSpice Hub API",
    "version": "3.2.0",
    "project_urls": {
        "Homepage": "https://github.com/AllSpiceIO/py-allspice"
    },
    "split_keywords": [
        "allspice",
        " allspice hub",
        " api",
        " wrapper"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b6ffc6135adab4b493ad85885347edf6b28054f652e27eae2aa812b693eda295",
                "md5": "22abacc4bb0f5bae070511288ad9eb05",
                "sha256": "a5628780dbb00ea1d0a28811ca1b725a5b8e0510068036534cf4419afb3fcc57"
            },
            "downloads": -1,
            "filename": "py_allspice-3.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "22abacc4bb0f5bae070511288ad9eb05",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 37692,
            "upload_time": "2024-06-12T20:44:51",
            "upload_time_iso_8601": "2024-06-12T20:44:51.366247Z",
            "url": "https://files.pythonhosted.org/packages/b6/ff/c6135adab4b493ad85885347edf6b28054f652e27eae2aa812b693eda295/py_allspice-3.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4f80392430c1c71f952935da8b673ec0dfdcfa8f8ddc5fa8e8846f8798f42053",
                "md5": "45e5bd1b519070cf3491b0753d60518d",
                "sha256": "184db496892dbbe1f988eaf7cd6c0c08a02b271b1929b9b4ae08c1900530842c"
            },
            "downloads": -1,
            "filename": "py_allspice-3.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "45e5bd1b519070cf3491b0753d60518d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 43925,
            "upload_time": "2024-06-12T20:44:53",
            "upload_time_iso_8601": "2024-06-12T20:44:53.840673Z",
            "url": "https://files.pythonhosted.org/packages/4f/80/392430c1c71f952935da8b673ec0dfdcfa8f8ddc5fa8e8846f8798f42053/py_allspice-3.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-12 20:44:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AllSpiceIO",
    "github_project": "py-allspice",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "requests",
            "specs": [
                [
                    "~=",
                    "2.32"
                ]
            ]
        },
        {
            "name": "frozendict",
            "specs": [
                [
                    "~=",
                    "2.4"
                ]
            ]
        }
    ],
    "lcname": "py-allspice"
}
        
Elapsed time: 0.26818s