Python client library for REGDATA RPS Engine.
Project description
Introduction
This project is a Python Client library for integrating with RPS Engine API for the sake of performing transformation to your data.
Getting Started
Pre requisites
- Python version : >=3.10,<=3.11.9
- Install poetry for dependency management : https://python-poetry.org/docs/#installing-with-pipx
- Enabled configuration in RPS Core Admin website, filled with Transformation sequences, instances, rights and processing contexts.
Disclaimer : This project was only tested with python 3.11
Starting the Application
The project uses poetry for dependency management and a pyproject.toml
To get started with poetry and you have pipx installed run
pipx install poetry
Install the project dependencies (under the folder which contains the pyproject.toml)
poetry install
Configuring the environment
The RPS Platform client supports flexible configuration through both .env file, a settings.json file and environment variables. You can choose the method that best fits your deployment and development workflow.
The precedence order for loading configuration is : env -> settings.json
a. Location of the configuration file
The default location of the configuration file is the root project folder. If a dedicated folder or location is necessary, it could be applied by setting the environment variable RPS_CLIENT_CONFIG_DIR.
- Set configuration file location:
$env:RPS_CLIENT_CONFIG_DIR = "path/to/config_folder"
- Remove file location:
Remove-Item Env:RPS_CLIENT_CONFIG_DIR
b. Choosing source to load Rights Contexts and Processing Contexts
Choose by setting the context_source parameter when creating the engine instance:
- To load from JSON files (the default behavior,
external_source_filesmust be included in the configuration file) =ContextSource.JSON. - From the configuration settings (inside
.envorsettings.json) =ContextSource.SETTINGS.
Example:
engine = EngineFactory.get_engine(context_source=ContextSource.JSON)
Option A - Create a settings.json file
Must be a valid JSON syntax for more complex or nested configuration. Using double quotes for all keys and string values, and proper nesting for objects and arrays. This is the recommended approach for most use cases.
{
"rps": {
"engineHostName": "https://your-rps-engine-url",
"identityServiceHostName": "https://your-identity-url",
"clientId": "YOUR_CLIENT_ID",
"clientSecret": "YOUR_CLIENT_SECRET",
"timeout": 30
},
// Specify either the "external_source_files" section or the "rights_contexts" & "processing_contexts", according to the contexts source
"external_source_files": {
"rightsContextsFilePath": "path/to/rights_contexts.json",
"processingContextsFilePath": "path/to/processing_contexts.json"
},
"rights_contexts": {
"Admin": {
"evidences": [
{ "name": "Role", "value": "Admin" }
]
}
},
"processing_contexts": {
"Protect": {
"evidences": [
{ "name": "Action", "value": "Protect" }
]
},
"Deprotect": {
"evidences": [
{ "name": "Action", "value": "Deprotect" }
]
}
}
}
- Replace the URLs,
clientId, andclientSecretwith your actual values which are relevant to the Configuration in RPS CoreAdmin platform. - If you want to load rights and processing contexts from JSON files, provide the correct file paths in
external_source_files.
Option B - Using .Env file with Environment Variables
Use standard key-value pairs, one per line, with no quotes or commas, (e.g., KEY=value) for environment-based configuration (with __ as a nesting separator for env variables)
rps__engineHostName="https://your-rps-engine-url"
rps__identityServiceHostName="https://your-identity-url"
rps__clientId="YOUR_CLIENT_ID"
rps__clientSecret="YOUR_CLIENT_SECRET"
rps__timeout=30
// One of the followings:
external_source_files__rightsContextsFilePath=path/to/rights_contexts.json
external_source_files__processingContextsFilePath=path/to/processing_contexts.json
// OR
rights_contexts__Admin__evidences__0__name="Role"
rights_contexts__Admin__evidences__0__value="Admin"
processing_contexts__Protect__evidences__0__name=Action
processing_contexts__Protect__evidences__0__value=Protect
processing_contexts__Deprotect__evidences__0__name=Action
processing_contexts__Deprotect__evidences__0__value=Deprotect
Examples of usage
The examples folder contains several ready-to-run scripts that demonstrate different usage scenarios of the RPS Engine client. Each example is designed to help you understand how to configure, invoke, and extend the client for your own use cases. Below is a brief explanation of each example:
-
SimpleUsageExampleDemonstrates the most basic workflow: manually creating rights and processing contexts, constructing RPSValue objects, and performing protection and deprotection operations. This is a good starting point for understanding the core API and data flow. -
ContextsProvidedByResolverExampleshows how to use context names instead of full context objects. The example leverages the context resolver to fetch rights and processing contexts by name, simplifying the request construction process. -
UsageWithDependenciesExampleIllustrates how to handle RPSValue objects that have dependencies (such as minimum or maximum values). This is useful for scenarios where the transformation logic depends on related data fields. -
UsageWithRelatedObjectExampleDemonstrates how to load data from an external JSON file, convert it into RPSValue objects, and perform protection operations. This example is ideal for batch processing or integrating with external data sources.
Each example is self-contained and can be run directly. Review and adapt these scripts to accelerate your own integration with the RPS Platform.
poetry run python client/examples/usage_with_related_object_example.py
Contribute
To add libraries update the dependencies section in the pyproject.toml
It is mandatory to use version pins for the dependency to ensure reproducible builds
dependencies = [
"pydantic (>=2.10.6,<3.0.0)",
"pydantic-settings (>=2.8.1,<3.0.0)",
"dotenv (>=0.9.9,<0.10.0)" ,
"python-dotenv==1.0.0",
"certifi==2023.7.22",
"<INSERT YOUR DEPENDENCY>"
]
To install the dependencies update the peotry.lock with poetry
poetry lock
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 Distribution
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 rps_engine_client_python-1.0.4.tar.gz.
File metadata
- Download URL: rps_engine_client_python-1.0.4.tar.gz
- Upload date:
- Size: 24.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f3a2b0636aed8b56b064eb970001c711c7548212fffd4a6aa1a7633184d5257
|
|
| MD5 |
ba6986b4b4b5e12dca8632e5f1db4b9f
|
|
| BLAKE2b-256 |
12049710078804f2c219c15eda470fbaef5808f2e0e7e3d61595fe28819a2f62
|
Provenance
The following attestation bundles were made for rps_engine_client_python-1.0.4.tar.gz:
Publisher:
python-publish.yml on RegdataSA/rps-engine-client-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rps_engine_client_python-1.0.4.tar.gz -
Subject digest:
3f3a2b0636aed8b56b064eb970001c711c7548212fffd4a6aa1a7633184d5257 - Sigstore transparency entry: 384433981
- Sigstore integration time:
-
Permalink:
RegdataSA/rps-engine-client-python@fa222586cc100cdaf8fb0ce23e1635ffa43881a0 -
Branch / Tag:
refs/tags/v1.0.4 - Owner: https://github.com/RegdataSA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@fa222586cc100cdaf8fb0ce23e1635ffa43881a0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rps_engine_client_python-1.0.4-py3-none-any.whl.
File metadata
- Download URL: rps_engine_client_python-1.0.4-py3-none-any.whl
- Upload date:
- Size: 46.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5f918769caa0cc9868a34ae5a6877c20a8762b3f86754bb52b492aee7d7ed90
|
|
| MD5 |
fdd7e9cd78d6716e15d310a03c70e922
|
|
| BLAKE2b-256 |
1e3f6cd76a6ae4ab0bc83b186506fee9fd622d905dfc90c07e9003f72ca50f87
|
Provenance
The following attestation bundles were made for rps_engine_client_python-1.0.4-py3-none-any.whl:
Publisher:
python-publish.yml on RegdataSA/rps-engine-client-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rps_engine_client_python-1.0.4-py3-none-any.whl -
Subject digest:
f5f918769caa0cc9868a34ae5a6877c20a8762b3f86754bb52b492aee7d7ed90 - Sigstore transparency entry: 384433996
- Sigstore integration time:
-
Permalink:
RegdataSA/rps-engine-client-python@fa222586cc100cdaf8fb0ce23e1635ffa43881a0 -
Branch / Tag:
refs/tags/v1.0.4 - Owner: https://github.com/RegdataSA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@fa222586cc100cdaf8fb0ce23e1635ffa43881a0 -
Trigger Event:
release
-
Statement type: