-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusage_with_dependencies_example.py
More file actions
38 lines (29 loc) · 1.72 KB
/
usage_with_dependencies_example.py
File metadata and controls
38 lines (29 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""Example of usage of Protection of RPSValues with Dependencies"""
from Client.context_source import ContextSource
from Client.instance.rps_instance import RPSInstance
from Client.engine.engine_factory import EngineFactory
from Client.value.rps_value import RPSValue
class UsageWithDependenciesExample:
"""Example of Protection of RPSValues with Dependencies,
and printing results from RPS Engine"""
__engine = EngineFactory.get_engine(context_source=ContextSource.JSON)
if __name__ == "__main__":
print('--- Example of protection with dependencies ---')
# Create RPS Value with dependency - see https://demo.rpsprod.ch/community/library/rps-value
payment_date = RPSValue(instance=RPSInstance(className='Payment', propertyName='Date'),
originalValue='02.11.2021',
dependencies={
"min": "01.10.2021",
"max": "02.11.2021"
})
# Create ordinary RPSValue
payment_amount = RPSValue(instance=RPSInstance(className='Payment', propertyName='Amount'), originalValue='999')
# This method will do REST API call to RPS Engine API.
__engine.transform_async_with_context_names(
rps_values=[payment_date, payment_amount],
rights_context_name="Admin",
processing_context_name="Protect")
print(f'{payment_date.instance.class_name}: {payment_date.instance.property_name}. \
Original: {payment_date.original}. Transformed: {payment_date.transformed}')
print(f'{payment_amount.instance.class_name}: {payment_amount.instance.property_name}. \
Original: {payment_amount.original}. Transformed: {payment_amount.transformed}')