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).

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_autorize 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.

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

omni_api-0.12.0.tar.gz (32.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

omni_api-0.12.0-py2.py3-none-any.whl (93.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file omni_api-0.12.0.tar.gz.

File metadata

  • Download URL: omni_api-0.12.0.tar.gz
  • Upload date:
  • Size: 32.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for omni_api-0.12.0.tar.gz
Algorithm Hash digest
SHA256 abc16555eb61495654aa5eaf36ee67a1361ad6257cc9935fc512900829fd0192
MD5 446751bfee4864b012ed20c66bea9ff7
BLAKE2b-256 abbc0304d03e8d489f507f26b95d36e79b68fcf653283eebf1a8ce76f0ecf495

See more details on using hashes here.

File details

Details for the file omni_api-0.12.0-py2.py3-none-any.whl.

File metadata

  • Download URL: omni_api-0.12.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 93.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for omni_api-0.12.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 96b50ad112cd25df9bed6dc0cb6f2ba115765ba36c4ff3f0ce9bf7e92c200733
MD5 5a2b79f4d415e62f9b530fe9139f5795
BLAKE2b-256 7f5feaf6230a0310ba0438db5125130774c6b8a802b2e62fca9a425f873a95c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page