py-allspice


Namepy-allspice JSON
Version 3.6.0 PyPI version JSON
download
home_pageNone
SummaryA python wrapper for the AllSpice Hub API
upload_time2024-10-16 14:13:47
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT
keywords allspice allspice hub api wrapper
VCS
bugtrack_url
requirements No requirements were recorded.
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

### Docs

See the [documentation site](https://allspiceio.github.io/py-allspice/allspice.html).

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

### Cassettes

We use [pytest-recording](https://github.com/kiwicom/pytest-recording) to
record cassettes which speed up tests which access the network. By default,
tests which have been updated to work with pytest-recording will use cassettes.
To disable using cassettes, run:

```sh
python -m pytest --disable-recording
```

The scheduled CI test suite will ignore cassettes using the same command. This
is to ensure that our cassettes aren't out of date in a way that leads to tests
passing with them but failing with a live Hub environment. If a scheduled test
run without the cassettes fails, use:

```sh
python -m pytest --record-mode=rewrite
```

To update the cassettes. Double check the changes in the cassettes and make sure
tests are passing again before pushing the changes.

### Snapshots

We use [syrupy](https://github.com/tophat/syrupy) to snapshot test. This makes
it easier to assert complex outputs. If you have to update snapshots for a test,
run:

```sh
python -m pytest -k <specifier for test> --snapshot-update
```

When updating snapshots, try to run as few tests as possible to ensure you do
not update snapshots that are unrelated to your changes, and double check
snapshot changes to ensure they are what you expect.

            

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/6c/7c/4a36c2e35b84f3573d937cf16e7a4ad0c66d99ebeb67e8adde3aae30be9e/py_allspice-3.6.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### Docs\n\nSee the [documentation site](https://allspiceio.github.io/py-allspice/allspice.html).\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\n`http://localhost:3000`, and an admin-user token at `.token`. The admin user\nmust be named `test`, with email `secondarytest@test.org`.\n\n### Cassettes\n\nWe use [pytest-recording](https://github.com/kiwicom/pytest-recording) to\nrecord cassettes which speed up tests which access the network. By default,\ntests which have been updated to work with pytest-recording will use cassettes.\nTo disable using cassettes, run:\n\n```sh\npython -m pytest --disable-recording\n```\n\nThe scheduled CI test suite will ignore cassettes using the same command. This\nis to ensure that our cassettes aren't out of date in a way that leads to tests\npassing with them but failing with a live Hub environment. If a scheduled test\nrun without the cassettes fails, use:\n\n```sh\npython -m pytest --record-mode=rewrite\n```\n\nTo update the cassettes. Double check the changes in the cassettes and make sure\ntests are passing again before pushing the changes.\n\n### Snapshots\n\nWe use [syrupy](https://github.com/tophat/syrupy) to snapshot test. This makes\nit easier to assert complex outputs. If you have to update snapshots for a test,\nrun:\n\n```sh\npython -m pytest -k <specifier for test> --snapshot-update\n```\n\nWhen updating snapshots, try to run as few tests as possible to ensure you do\nnot update snapshots that are unrelated to your changes, and double check\nsnapshot changes to ensure they are what you expect.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A python wrapper for the AllSpice Hub API",
    "version": "3.6.0",
    "project_urls": {
        "Homepage": "https://github.com/AllSpiceIO/py-allspice"
    },
    "split_keywords": [
        "allspice",
        " allspice hub",
        " api",
        " wrapper"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9da163527571baca58cb94ed22d348b955f5dd2ba30d3b271c239a25dac4181b",
                "md5": "6f806504e900ffd33ef4815555b8787f",
                "sha256": "3dab8eca1178ce6a0892855394789e66a5488b08a6fcdfa88daa83d54397c5ad"
            },
            "downloads": -1,
            "filename": "py_allspice-3.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6f806504e900ffd33ef4815555b8787f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 48667,
            "upload_time": "2024-10-16T14:13:45",
            "upload_time_iso_8601": "2024-10-16T14:13:45.734470Z",
            "url": "https://files.pythonhosted.org/packages/9d/a1/63527571baca58cb94ed22d348b955f5dd2ba30d3b271c239a25dac4181b/py_allspice-3.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6c7c4a36c2e35b84f3573d937cf16e7a4ad0c66d99ebeb67e8adde3aae30be9e",
                "md5": "368c4d96f5265c76bde94944a779af7d",
                "sha256": "22783c76a1eb6033d819da6fcc99b4fe63319cae71f25540b3387759ff279631"
            },
            "downloads": -1,
            "filename": "py_allspice-3.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "368c4d96f5265c76bde94944a779af7d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 57283,
            "upload_time": "2024-10-16T14:13:47",
            "upload_time_iso_8601": "2024-10-16T14:13:47.546333Z",
            "url": "https://files.pythonhosted.org/packages/6c/7c/4a36c2e35b84f3573d937cf16e7a4ad0c66d99ebeb67e8adde3aae30be9e/py_allspice-3.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-16 14:13:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AllSpiceIO",
    "github_project": "py-allspice",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "py-allspice"
}
        
Elapsed time: 0.43200s