This project is a Python Client library for integrating with RPS Engine API for the sake of performing transformation to your data.
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
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
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
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"
- Removing the configured file location, to use default location:
Remove-Item Env:RPS_CLIENT_CONFIG_DIR
Choose by setting the context_source
parameter when creating the engine
instance:
- To load from JSON files (the default behavior,
external_source_files
must be included in the configuration file) =ContextSource.JSON
. - From the configuration settings (inside
.env
orsettings.json
) =ContextSource.SETTINGS
.
Example:
engine = EngineFactory.get_engine(context_source=ContextSource.JSON)
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 -> `ContextSource.JSON`
// Or the "rights_contexts" & "processing_contexts" sections -> `ContextSource.SETTINGS`
"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
, andclientSecret
with 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
.
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, `ContextSource.JSON`
external_source_files__rightsContextsFilePath=path/to/rights_contexts.json
external_source_files__processingContextsFilePath=path/to/processing_contexts.json
// or `ContextSource.SETTINGS`
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"
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:
-
SimpleUsageExample
demonstrates 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. -
ContextsProvidedByResolverExample
shows how to use context names instead of full context objects. The example leverages the context resolver to fetch rights and processing contexts by their names, simplifying the request construction process. -
UsageWithDependenciesExample
illustrates 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. -
UsageWithRelatedObjectExample
demonstrates 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
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
See REGDATA RPS Community for further integrations and documentation.