Skip to main content

Omni API

Simple REST API wrapper for the Omni infra-structure.

Configuration

Name Type Description
OMNI_BASE_URL str The base URL that is going to be used for API connections (defaults to http://localhost:8080/mvc/).
OMNI_OPEN_URL str The open URL for the Omni connection (defaults to OMNI_BASE_URL).
OMNI_PREFIX str The default prefix to be used for API requests (defaults to adm/).
OMNI_ID str The client id to be used for API connections (defaults to None).
OMNI_SECRET str The secret key to be used for API connections (defaults to None).
OMNI_REDIRECT_URL str The URL to be used for redirection OAuth based workflow (defaults to base,base.user,base.admin,foundation.store.list).
OMNI_USERNAME str The username to be used on direct workflow (defaults to None).
OMNI_PASSWORD str The password to be used on direct workflow (defaults to None).
OMNI_ACCESS_TOKEN str The access token to be used on token workflow, when no username and password are set (defaults to None).

Note that the OMNI_ACCESS_TOKEN is also used by an OAuth client (OMNI_ID and OMNI_SECRET) built with no access token of its own. A web app serving its users through OAuth should then always provide the user's access token to the client (even when None), so that it never acts with the permissions of the configured token.

Usage

Typical usage of the Omni client implies the providing of the username and the password inside the target omni instance (Direct Mode).

api = omni.API(
    base_url = "http://frontdoorhq.com",
    username = "YOUR_USERNAME",
    password = "YOUR_PASSWORD"
)

Alternatively it's possible to use the api throught an OAuth base approach using the provided client id and secret values.

api = omni.API(
    base_url = "http://frontdoorhq.com",
    client_id = "YOUR_OAUTH_ID",
    client_secret = "YOUR_OAUTH_SECRET"
)

For these type of handling the OAuthAccessError exception must be handled and then the user must be redirect to the url provided by api.oauth_authorize method call.

Running then the api.oauth_access call with the returned code from the server side that should be used to redeem the access_token required for session authentication.

It's also possible to use the api with an access token generated in Omni (eg: a never-expiring token of a service account), with no need for the OAuth flow, as the session is started (and renewed when it expires) with the token itself.

api = omni.API(
    base_url = "http://frontdoorhq.com",
    access_token = "YOUR_ACCESS_TOKEN"
)

Note that the username and the password, when also set, take precedence over the access token.

Documentation

See the documentation index.

Examples

Examples are located here.

Testing

The unit test suite runs using pytest and requires Python 3.10+, unlike the library itself the tests make full use of the provided type stubs (the library implementation remains Python 2.7+ compatible).

pip install pytest
pytest

The live integration tests run against a local Omni instance and are skipped unless the OMNI_TEST_LIVE environment variable is set, together with the usual OMNI_BASE_URL, OMNI_USERNAME and OMNI_PASSWORD configuration.

Such an instance can be provisioned with demo data using the hivesolutions/omni docker image (private, registry credentials required), the loader seeds the database with the demo dataset (including the root / Root@12345 credentials) and the server is then started, note that with COLONY_PREFIX=/mvc the client base URL should not include the /mvc prefix:

docker run -d --name omni -p 8080:8080 --entrypoint sh \
    -e RUN_MODE=development \
    -e COLONY_CONFIG_FILE=config/python/singleton.py \
    -e DB_ENGINE=sqlite \
    -e DB_FILE=ci.db \
    -e RESET_DB=1 \
    -e AT_TEST_MODE=1 \
    hivesolutions/omni:latest \
    -c "cd /omni && python3 scripts/load_demo_data.py && exec colony_wsgi"
OMNI_TEST_LIVE=1 OMNI_BASE_URL=http://localhost:8080/ OMNI_USERNAME=root OMNI_PASSWORD=Root@12345 pytest

The CI pipeline runs the same provisioning in the Build Live job whenever the Docker Hub credentials are available as repository secrets (DOCKERHUB_USERNAME and DOCKERHUB_TOKEN), skipping the live run otherwise.

Type checking of the stubs, examples and tests is done using Pyright:

pip install pyright
pyright src/omni/*.pyi src/examples src/omni/test

License

Omni API is currently licensed under the Apache License, Version 2.0.

Build Automation

Build Status Coverage Status PyPi Status License

Metadata

Release files for omni-api 0.19.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for omni-api 0.19.0
File Size Uploaded Provenance Actions
omni_api-0.19.0.tar.gz 41.2 kB Without provenance Details for omni_api-0.19.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for omni-api 0.19.0
File Interpreter ABI Platform Actions
omni_api-0.19.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for omni_api-0.19.0-py2.py3-none-any.whl

Total release size: 156.1 kB

Release files / omni_api-0.19.0.tar.gz

Download URL omni_api-0.19.0.tar.gz
Size 41.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e1936ffa712dc6762882e959b4758ff9e1a7d9f2b52131dd2b9f70037721405e
BLAKE2b-256 checksum
How to use checksums
4596ff49c8ab75e2fb8aece61bdbca0ef712cc579605b883771b3168e555cbdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / omni_api-0.19.0-py2.py3-none-any.whl

Download URL omni_api-0.19.0-py2.py3-none-any.whl
Size 114.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a2e0c1a083be28db56336d68fb2e550545325a817ea09e7d9702e21f29ce81cd
BLAKE2b-256 checksum
How to use checksums
8b7c30c524cff81c931235e2828c1aa8a9084f1d1d4e1b1de23ec651f6c8e0f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for omni-api 0.19.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.19.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page