Configuration

This document describes how to configure and set up the microesb backend to process Service Call Metadata.

Note

Refer to subsection example-test-execution to see how to use the configuration data and execute a working setup.

1. Class Reference

A Class Reference Config dictionary must be provided to describe the Hierarchical Implementation Class Setup and its dependencies.

1.1. Root Element

The root dictionary consists of elements “class_config_element” (recursive). See 1.2. Class Config Element.

class_reference = {
    '$class_name1': { ... "class_config_element" dict ... },
    '$class_name2': { ... "class_config_element" dict ... },
    '$class_name3': { ... "class_config_element" dict ... }
}

Note

The $class_name key must reference an existing Implementation Class.

1.2. Class Config Element

The class_config_element consists of two properties: property_ref and children.

Class Reference - “class_config_element” Properties

Property

Type

Description

property_ref

str

Maps the class to properties defined in the Service Property Config.

children

dict

“class_config_element” (recursive). See 1.3. Example.

class_config_element = {
    'property_ref': '$service_property_ref',
    'children': { ... "class_config_element" dict ... }
}

Warning

A class_config_element must only contain a single root element.

Note

A dictionary structure like { ‘root_element’: { … } } is valid. However, multiple root elements (e.g., { ‘root_element1’: { … }, ‘root_element2’: { … } }) will cause dependency issues.

1.3. Example

 1class_reference = {
 2    'Class1': {
 3        'property_ref': 'Class1',
 4        'children': {
 5            'Class2': {
 6                'property_ref': 'Class2',
 7                'children': {
 8                    'Class3': {
 9                        'property_ref': 'Class3'
10                    }
11                }
12            }
13        }
14    }
15}

Note

Section Examples provides detailed and working examples.

1.4. Property Reference

The property_ref defines which properties (defined in the Service Property Config) will be mapped to the dictionary key (class name).

2. Service Properties

The Service Property Config dictionary maps properties to Implementation Classes.

Only properties defined inside the Service Property Config are addressable and referenceable from the Service Call Metadata Config.

Note

If a property mentioned in the Service Call Metadata is not configured in the Service Property Config, it will be silently ignored.

2.1. Root Element

The root-level dictionary key must reference an existing Implementation Class.

service_properties = {
    '$class_name1': { },
    '$class_name2': { },
    '$class_name3': { },
}

The values are dictionaries with allowed keys properties and methods.

2.2. SYSBackendMethods

The SYSBackendMethods property is a system property that triggers Service Method Invocation from the backend. This is different from SYSServiceMethod(s), which is only defined in the Service Call Metadata.

The type is a list of 2-element tuples: [ (Element1, Element2) ].

  • Element1: A string that specifies the backend class method.

  • Element2: A string that specifies the trigger type.

Note

Currently, the only allowed trigger type for Element2 is ‘on_recursion_finish’.

Example:

properties_dict = {
    'SYSBackendMethods': [
        ('gen_cert', 'on_recursion_finish')
    ],
    'properties': { ... }
}

2.3. Property Element

The “property” element is of dict type.

Service Properties - “property” Element

DictKey

DictValue Type

DictValue Value

Opt

Description

type

enum(Python types)

[ ‘str’, ‘int’ ]

no

Usable internal Python types.

default

DictValue defined in “type”

Dynamic

no

Default value or None.

required

bool

True | False

no

Indicates whether the property is mandatory.

description

str

str

yes

Provides a description of the property.

Example:

'$property_name': {
    'type': 'str' || 'int',
    'default': '$value' || None,
    'required': True || False,
    'description': 'Internal property description for autodoc'
}

2.4. Methods List

The “methods” list contains methodname (str) items.

Each method name references a callable method of a defined Implementation Class.

Example:

'methods': [ 'method1', 'method2', 'method3' ]

Warning

This feature is currently unused. It will play a role in the Service Registry and Service Autodoc features, which are not yet implemented.

Note

Method Mapping occurs only if the “SYSServiceMethod” property exists in the Service Call Metadata Config.

2.5. Full Syntax

Example of the complete syntax for the Service Property Config:

service_properties = {
    '$class_name1': {
        'properties': {
            '$prop1': { ... "property" dict (1) ... },
            '$prop2': { ... "property" dict (2) ... },
            '$prop3': { ... "property" dict (3) ... }
        },
        'methods': [ ... "methodname" list ... ]
    },
    '$class_name2': {
        'properties': {
            '$prop1': { ... "property" dict (1) ... },
            '$prop2': { ... "property" dict (2) ... },
            '$prop3': { ... "property" dict (3) ... }
        },
        'methods': [ ... "methodname" list ... ]
    },
}

2.6. Example

Example configuration:

 1service_properties = {
 2    'User': {
 3        'properties': {
 4            'name': {
 5                'type': 'str',
 6                'default': None,
 7                'required': True,
 8                'description': 'Textual UserID'
 9            }
10        },
11        'methods': [ 'add', 'delete' ]
12    },
13    'Domain': {
14        'properties': {
15            'name': {
16                'type': 'str',
17                'default': None,
18                'required': True,
19                'description': 'Domain Name'
20            },
21            'ending': {
22                'type': 'str',
23                'default': 'de',
24                'required': False,
25                'description': 'Domain Ending'
26            }
27        },
28        'methods': [ 'add', 'update', 'delete' ]
29    }
30}

5.3. Test Execution

Before executing the configuration, ensure all referenced files are correctly provided:

  1. esbconfig.py (import module and classes)

  2. implementation_classes.py (referenced in esbconfig.py)

  3. class_reference.py (class reference configuration)

  4. service_properties.py (service properties configuration)

  5. class_mapping.py (class mapping configuration)

  6. service_metadata.py (service call metadata)

Example execution:

from microesb import microesb

from service_properties import service_properties
from class_reference import class_reference
from class_mapping import class_mapping
from service_call_metadata import service_metadata

class_mapper = microesb.ClassMapper(
    class_references=class_reference,
    class_mappings=class_mapping,
    class_properties=service_properties
)

res = microesb.ServiceMapper(
    class_mapper=class_mapper,
    service_data=service_metadata
)