Skip to content

Commit 38b985a

Browse files
committed
fix: update Readme files for dedicate purpose
1 parent 93e70eb commit 38b985a

2 files changed

Lines changed: 50 additions & 97 deletions

File tree

Client/README.md

Lines changed: 49 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
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.
44

5-
---
5+
66

77
## Install the Library
88

@@ -12,111 +12,68 @@ Install the latest version from PyPI using pip:
1212
pip install rps-engine-client-python
1313
```
1414

15-
---
1615

1716
## Configure Your Environment
1817

19-
The library requires configuration for authentication and engine connection. You can provide this information via a `settings.json` file or `.env` file.
20-
21-
### 1. Location of the configuration file
22-
23-
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`.
24-
- Set configuration file location:
25-
```powershell
26-
$env:RPS_CLIENT_CONFIG_DIR = "path/to/config_folder"
27-
```
28-
- Remove file location:
29-
```powershell
30-
Remove-Item Env:RPS_CLIENT_CONFIG_DIR
31-
```
32-
33-
### 2. Choosing source to load Rights Contexts and Processing Contexts
34-
35-
Choose by setting the `context_source` parameter when creating the `engine` instance:
18+
The library requires configuration for authentication and engine connection.
3619

37-
1. To load from JSON files (the default behavior, `external_source_files` must be included in the configuration file) = `ContextSource.JSON`.
38-
2. From the configuration settings (inside `.env` or `settings.json`) = `ContextSource.SETTINGS`.
20+
The default location of the configuration file is the root project folder.
3921

40-
Example:
22+
#### Using .Env file with Environment Variables
4123

4224
```python
43-
engine = EngineFactory.get_engine(context_source=ContextSource.JSON)
44-
```
45-
46-
### 3. Create the configuration file
47-
48-
#### Option A - Create a `settings.json` file
49-
50-
```json
51-
{
52-
"rps": {
53-
"engineHostName": "https://your-rps-engine-url",
54-
"identityServiceHostName": "https://your-identity-url",
55-
"clientId": "YOUR_CLIENT_ID",
56-
"clientSecret": "YOUR_CLIENT_SECRET",
57-
"timeout": 30
58-
},
59-
// Specify either the "external_source_files" section or the "rights_contexts" & "processing_contexts", according to the contexts source
60-
"external_source_files": {
61-
"rightsContextsFilePath": "path/to/rights_contexts.json",
62-
"processingContextsFilePath": "path/to/processing_contexts.json"
63-
},
64-
"rights_contexts": {
65-
"Admin": {
66-
"evidences": [
67-
{ "name": "Role", "value": "Admin" }
68-
]
69-
}
70-
},
71-
"processing_contexts": {
72-
"Protect": {
73-
"evidences": [
74-
{ "name": "Action", "value": "Protect" }
75-
]
76-
},
77-
"Deprotect": {
78-
"evidences": [
79-
{ "name": "Action", "value": "Deprotect" }
80-
]
81-
}
82-
}
83-
}
84-
```
85-
86-
- Replace the URLs, `clientId`, and `clientSecret` with your actual values which are relevant to the Configuration in RPS CoreAdmin platform.
87-
- If you want to load rights and processing contexts from JSON files, provide the correct file paths in `external_source_files`.
88-
89-
#### Option B - Using .Env file with Environment Variables
90-
91-
```bash
9225
rps__engineHostName="https://your-rps-engine-url"
9326
rps__identityServiceHostName="https://your-identity-url"
9427
rps__clientId="YOUR_CLIENT_ID"
9528
rps__clientSecret="YOUR_CLIENT_SECRET"
9629
rps__timeout=30
9730

98-
// One of the followings:
9931
external_source_files__rightsContextsFilePath=path/to/rights_contexts.json
10032
external_source_files__processingContextsFilePath=path/to/processing_contexts.json
33+
```
10134

102-
// OR
103-
rights_contexts__Admin__evidences__0__name="Role"
104-
rights_contexts__Admin__evidences__0__value="Admin"
35+
#### rights_contexts.json
36+
```JSON
37+
{
38+
"Admin": {
39+
"evidences": [
40+
{
41+
"name": "Role",
42+
"value": "Admin"
43+
}
44+
]
45+
}
46+
}
47+
```
48+
#### processing_contexts.json
10549

106-
processing_contexts__Protect__evidences__0__name=Action
107-
processing_contexts__Protect__evidences__0__value=Protect
108-
processing_contexts__Deprotect__evidences__0__name=Action
109-
processing_contexts__Deprotect__evidences__0__value=Deprotect
50+
```JSON
51+
{
52+
"Protect": {
53+
"evidences": [
54+
{
55+
"name": "Action",
56+
"value": "Protect"
57+
}
58+
]
59+
},
60+
"Deprotect": {
61+
"evidences": [
62+
{
63+
"name": "Action",
64+
"value": "Deprotect"
65+
}
66+
]
67+
}
68+
}
11069
```
111-
---
11270

11371
## Create a Python Script
11472

115-
Write a python script that uses the library.
116-
117-
Below is a minimal example which uses the [`EngineFactory`](Client/engine/engine_factory.py) class for the engine connection, getting the contexts from a JSON file.
11873

74+
Below is an example which uses the [`EngineFactory`](Client/engine/engine_factory.py) class for the engine connection, getting the contexts from a JSON file.
11975

76+
- Pay attention that the given arguments for the `rights_context_name` and `processing_context_name` parameters are the names of keys from the *rights_contexts.json* and *processing_contexts.json* files above.
12077
```python
12178
from Client.engine.engine_factory import EngineFactory
12279
from Client.context_source import ContextSource
@@ -128,33 +85,29 @@ from Client.value.rps_value import RPSValue
12885

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

131-
# Example usage
132-
admin_rights_context = RightsContext(evidences=[Evidence(name='Role', value='Admin')])
133-
protect_processing_context = ProcessingContext(evidences=[Evidence(name='Action', value='Protect')])
134-
13588
raw_first_name = RPSValue(instance=RPSInstance(className='User', propertyName='Name'), originalValue='Jonny')
13689

137-
request_context = engine.create_context().with_request(
90+
request_context = engine.create_context().with_request_by_context_names(
13891
rps_values=[raw_first_name],
139-
rights_context=admin_rights_context,
140-
processing_context=protect_processing_context
141-
)
92+
rights_context_name='Admin',
93+
processing_context_name='Protect')
14294

14395
request_context.transform_async()
14496

14597
print(f'Original: {raw_first_name.original}, Transformed: {raw_first_name.transformed}')
14698
```
14799

148100

149-
- See the [examples folder](https://github.com/your-org/rps-engine-client-python/tree/main/Client/Client/examples) in the source repository for more advanced usage patterns.
150-
151-
---
152-
153101
## Run Your Script
154102

155103

156104
```bash
157105
python your_script.py
158106
```
159107

160-
---
108+
109+
## Additional Resources
110+
111+
For advanced usage, examples, and contribution guidelines, see the [full documentation on GitHub](https://github.com/RegdataSA/rps-engine-client-python/).
112+
113+
For REGDATA Community Page see [RPS Community](https://demo.rpsprod.ch/community/).

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The default location of the configuration file is the root project folder. If a
3636
```powershell
3737
$env:RPS_CLIENT_CONFIG_DIR = "path/to/config_folder"
3838
```
39-
- Remove file location:
39+
- Removing the configured file location, to use default location:
4040
```powershell
4141
Remove-Item Env:RPS_CLIENT_CONFIG_DIR
4242
```

0 commit comments

Comments
 (0)