A collection of Python connection clients for E360 Microservices
Project description
E360 Clients Core
Installation
Use the E360 Artifactory package manager e360-pypi-local to install clients_core.
Requires Python 3.12 or newer.
pip install clients_core --index-url=https://rwes-artifactory01.internal.imsglobal.com/artifactory/api/pypi/e360-pypi-local/simple
Usage with Service Directory
- Create a TokenHandler, with the right configuration for identity.
from clients_core.authentication.token_handler import OIDCTokenHandler
token_handler = OIDCTokenHandler("<oidc_token_endpoint>", "<oidc_client_id>", "<oidc_client_secret>")
- Create a SecureRestClient for ServiceDirectory, and pass the token handler
from clients_core.secured_rest_client import SecuredRestClient
rest_client = SecuredRestClient("<url-to-service-directory", ["service-dir-scopes"], token_handler)
- Create a ServiceDirectoryClient using the rest client
from sd_clients.service_directory_client import ServiceDirectoryClient
sd_client = ServiceDirectoryClient(rest_client)
- The SD client can now be passed to ApiMatchClient which will allow lookups of services
from clients_core.api_match_client import ApiMatchClient, MatchSpec
match_client = ApiMatchClient(sd_client)
match_spec = MatchSpec("service-name", "endpoint-name",1 ,0, 1, ["service-scopes"])
service_rest_client = match_client.get_secured_client(match_spec, token_handler)
The service rest client can now be passed to a microservice client, or used directly to make REST calls to the target service
Usage with cache
If it is desired to use a cache, we need to wrap our TokenHandler with TokenCache. There are currently two Cache implementations, RedisCache and DictCache.
RedisCache requires a connection URL when instantiated:
from clients_core.authentication.cache import RedisCache
from clients_core.authentication.token_cache import TokenCache
cache = RedisCache("<redis-connection-url>")
token_cache = TokenCache(cache, token_handler) # token handler as created in step .1
token_cache can now be used in place of token_handler.
Development and Testing
Install uv (Python 3.12+ recommended).
uv sync --group dev
Run checks and tests:
uv run ruff check clients_core tests
uv run ruff format --check clients_core tests
uv run pytest
Run a single test file or test:
uv run pytest tests/test_secured_rest_client.py
uv run pytest tests/test_secured_rest_client.py::test_simple_post
Optional type check:
uv run mypy clients_core
Build a wheel locally:
uv build --out-dir dist
On the corporate network, you can point resolution at Artifactory, for example:
export UV_INDEX_URL=https://rwes-artifactory01.internal.imsglobal.com/artifactory/api/pypi/e360-pypi-local/simple
uv sync --group dev
See pyproject.toml for optional explicit e360-pypi indexes when adding internal-only dependencies.
Deployments
Auto CI enabled.
A deployment will happen every time a merge request is merged into master AND the version number is incremented in the clients_core/__init__.py file.
Development
After cloning this repository:
uv sync --group dev
Install pre-commit hooks:
uv run pre-commit install --install-hooks --overwrite
UML
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clients_core-4.0.3-py3-none-any.whl.
File metadata
- Download URL: clients_core-4.0.3-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4998a8b8d9b6cb35eedb49e5009e2fc8025a5710cdcb694b705db4bcbc03ca4d
|
|
| MD5 |
f3339d2e0edf3052832a86376cb75eaf
|
|
| BLAKE2b-256 |
419fbcd26554437a72da5301bbf00ca5c4334e7609fe2de42560ecee87df4140
|