assets_guardian.plugins.dolibarr.mapperο
Classes
|
Mapper for Dolibarr. |
- class assets_guardian.plugins.dolibarr.mapper.DolibarrMapper(instance_id: str, base_url: str | None = None)[source]ο
Bases:
IMapperMapper for Dolibarr.
Transforms raw data from the Dolibarr REST API into normalized models of the Assets Guardian domain.
Architectural choices: - Dolibarr groups -> Asset(asset_type=βgroupβ) - Group membership -> Access(access_type=βgroupβ, asset=<group>) - User rights on critical modules -> Access(access_type=βmodule_permissionβ, asset=<module>) - Rights granted by a group -> Access(access_type=βgroup_permissionβ, asset=<group>)
- to_access(raw_data: Any, asset: Asset | None = None, user_info: dict[str, Any] | None = None) Access[source]ο
Converts a Dolibarr group membership into an Access.
The access represents the fact that a user belongs to a group. The group is the target asset.
- Parameters:
raw_data β Raw group dictionary returned by the Dolibarr API.
asset β Asset associated with the group, if available.
user_info β Full data of the user who is a member of the group.
- Returns:
Normalized access representing group membership.
- Return type:
- to_asset(raw_data: Any, asset_type: str = 'group') Asset[source]ο
Converts a Dolibarr group into an Asset.
- Parameters:
raw_data β Raw dictionary from the Dolibarr API representing a group.
asset_type β Type of asset to use (default:
"group").
- Returns:
The normalized asset.
- Return type:
- to_group_permission_access(group_info: dict[str, Any], module: str, permission_key: str, asset: Asset | None = None, api_label: str = '') Access[source]ο
Creates an Access representing a permission granted by a Dolibarr group.
A virtual asset of type
"group_permission"is created so that theGenericSheetBuildercan filter usingfilter_by_asset_type.- Parameters:
group_info β Raw group dictionary returned by the Dolibarr API.
module β Dolibarr module name (e.g.
"banque","facture").permission_key β Permission key (e.g.
"lire","creer").asset β Asset of the group granting the permission (ignored, kept for compatibility).
api_label β Label provided by the Dolibarr API (prioritized over local dictionary).
- Returns:
Normalized access of type
group_permission.- Return type:
- to_identity(raw_data: Any, accesses: list[Access] | None = None) Identity[source]ο
Converts a Dolibarr user into an Identity.
The statut field indicates the state (β1β = active, β0β = inactive). The admin field indicates the superadmin status (1 = yes, 0 = no).
- Parameters:
raw_data β Raw dictionary from the Dolibarr API representing a user.
accesses β List of accesses already built for this user.
- Returns:
The normalized identity.
- Return type:
- to_module_permission_access(module: str, permission_key: str, user_info: dict[str, Any], asset: Asset | None = None) Access[source]ο
Creates an Access representing a user right on a Dolibarr module.
The access is linked to the virtual Asset of the corresponding module.
- Parameters:
module β Dolibarr module name (e.g.
"banque","user.user").permission_key β Permission key (e.g.
"lire","creer").user_info β Full user data.
asset β Virtual module Asset, if available.
- Returns:
Normalized access of type
module_permission.- Return type:
- property instance_id: strο
The specific instance identifier (e.g., βmainβ, βprodβ).
- property source_name: strο
Unique source name (must match config.yml).