Skip to main content

Python client library for REGDATA RPS Engine.

Project description

Quick Start Guide rps-engine-client-python

This guide explains how to install and use the rps-engine-client-python library from PyPI to interact with the REGDATA's RPS Engine API.


Install the Library

Install the latest version from PyPI using pip:

pip install rps-engine-client-python

Configure Your Environment

The library requires configuration for authentication and engine connection. You can provide this information via a settings.json file or .env file.

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

2. Choosing source to load Rights Contexts and Processing Contexts

Choose by setting the context_source parameter when creating the engine instance:

  1. To load from JSON files (the default behavior, external_source_files must be included in the configuration file) = ContextSource.JSON.
  2. From the configuration settings (inside .env or settings.json) = ContextSource.SETTINGS.

Example:

engine = EngineFactory.get_engine(context_source=ContextSource.JSON)

3. Create the configuration file

Option A - Create a settings.json file

{
  "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, and clientSecret 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.

Option B - Using .Env file with Environment 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

Create a Python Script

Write a python script that uses the library.

Below is a minimal example which uses the EngineFactory class for the engine connection, getting the contexts from a JSON file.

from Client.engine.engine_factory import EngineFactory
from Client.context_source import ContextSource
from Client.instance.rps_instance import RPSInstance
from Client.engine_context.processing_context import ProcessingContext
from Client.engine_context.rights_context import RightsContext
from Client.evidence import Evidence
from Client.value.rps_value import RPSValue

engine = EngineFactory.get_engine(context_source=ContextSource.JSON)

# Example usage
admin_rights_context = RightsContext(evidences=[Evidence(name='Role', value='Admin')])
protect_processing_context = ProcessingContext(evidences=[Evidence(name='Action', value='Protect')])

raw_first_name = RPSValue(instance=RPSInstance(className='User', propertyName='Name'), originalValue='Jonny')

request_context = engine.create_context().with_request(
    rps_values=[raw_first_name],
    rights_context=admin_rights_context,
    processing_context=protect_processing_context
)

request_context.transform_async()

print(f'Original: {raw_first_name.original}, Transformed: {raw_first_name.transformed}')
  • See the examples folder in the source repository for more advanced usage patterns.

Run Your Script

python your_script.py

Project details


Download files

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

Source Distribution

rps_engine_client_python-1.0.6.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

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

rps_engine_client_python-1.0.6-py3-none-any.whl (42.0 kB view details)

Uploaded Python 3

File details

Details for the file rps_engine_client_python-1.0.6.tar.gz.

File metadata

  • Download URL: rps_engine_client_python-1.0.6.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rps_engine_client_python-1.0.6.tar.gz
Algorithm Hash digest
SHA256 f88eaa6e901fc8b2a5cb16a3d2ac94e7a492c11c328794b9b9de4f4e66c06752
MD5 57e902e9696f31e359dba617c7afab58
BLAKE2b-256 edefe29effe9ae1cce868aa3eecfd961eb0c5ed51dceda35209e4bdbb57661d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for rps_engine_client_python-1.0.6.tar.gz:

Publisher: python-publish.yml on RegdataSA/rps-engine-client-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rps_engine_client_python-1.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for rps_engine_client_python-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e99106982c24cff7ec24136b9c9dfe09595b3982ed4f5869d2284440ea0950d8
MD5 0014ce14ff0b8e3269344f100a250a10
BLAKE2b-256 490060b9e43cd728af9f057773d7ada7c04411a1f953785fa19e2962d35eda17

See more details on using hashes here.

Provenance

The following attestation bundles were made for rps_engine_client_python-1.0.6-py3-none-any.whl:

Publisher: python-publish.yml on RegdataSA/rps-engine-client-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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