magpie.api.management.resource.resource_formats

Module Contents

Functions

format_resource(resource: Resource, permissions: Optional[Iterable[AnyPermissionType]] = None, basic_info: bool = False) → JSON

Formats the resource information into JSON.

format_resource_tree(children: ChildrenResourceNodes, db_session: Session, resources_perms_dict: Optional[ResourcePermissionMap] = None) → JSON

Generates the formatted resource tree under the provided children resources, with all of their children resources by

format_resource_with_children(resource: ServiceOrResourceType, db_session: Session) → JSON

Obtains the formatted Resource tree with all its formatted children hierarchy.

magpie.api.management.resource.resource_formats.format_resource(resource: Resource, permissions: Optional[Iterable[AnyPermissionType]] = None, basic_info: bool = False) → JSON[source]

Formats the resource information into JSON.

magpie.api.management.resource.resource_formats.format_resource_tree(children: ChildrenResourceNodes, db_session: Session, resources_perms_dict: Optional[ResourcePermissionMap] = None) → JSON[source]

Generates the formatted resource tree under the provided children resources, with all of their children resources by calling format_resource() recursively on them.

Apply specific resource permissions as defined by resources_perms_dict if provided.

Parameters
  • children – service or resource for which to generate the formatted resource tree

  • db_session – connection to db

  • resources_perms_dict – Any pre-established Applied Permissions to set to corresponding resources by ID. When provided, these will define the User, Group or both (i.e.: Inherited Permissions) actual permissions, or even the Effective Permissions, according to parent caller function’s context. Otherwise (None), defaults to extracting Allowed Permissions for the given Resource scoped under the corresponding root Service.

Returns

formatted resource tree

magpie.api.management.resource.resource_formats.format_resource_with_children(resource: ServiceOrResourceType, db_session: Session) → JSON[source]

Obtains the formatted Resource tree with all its formatted children hierarchy.