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-0.0.0.tar.gz (21.0 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-0.0.0-py3-none-any.whl (42.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rps_engine_client_python-0.0.0.tar.gz
  • Upload date:
  • Size: 21.0 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-0.0.0.tar.gz
Algorithm Hash digest
SHA256 2da6d028c37ac4a850cb8c2aa728e738b3b94896c6e981d02655aecb1eaaa0be
MD5 5527263af77dbaeed220b7294f7dbe4a
BLAKE2b-256 caee668b0c39cef74d21e376ebe490a6ce9208a3bfe7c77115fee8ef7f426108

See more details on using hashes here.

Provenance

The following attestation bundles were made for rps_engine_client_python-0.0.0.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-0.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rps_engine_client_python-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 790e9f3708ddd6c80ad9777a756d5664d6f4b1c0f6d89b81735f395bac9c261a
MD5 5ee318c71af5b28f7f520607428fff58
BLAKE2b-256 8460cecfc9bf010beec07fa5903aecc21c2339f4619535320d42085d0a8981fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for rps_engine_client_python-0.0.0-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