assets_guardian.plugins.dolibarr.mapper

Classes

DolibarrMapper(instance_id[,Β base_url])

Mapper for Dolibarr.

class assets_guardian.plugins.dolibarr.mapper.DolibarrMapper(instance_id: str, base_url: str | None = None)[source]

Bases: IMapper

Mapper 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:

Access

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:

Asset

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 the GenericSheetBuilder can filter using filter_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:

Access

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:

Identity

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:

Access

property instance_id: str

The specific instance identifier (e.g., β€˜main’, β€˜prod’).

property source_name: str

Unique source name (must match config.yml).