magpie.api.management.resource.resource_formats

Module Contents

Functions

format_resource(resource: magpie.models.Resource, permissions: Optional[Collection[magpie.typedefs.AnyPermissionType]] = None, permission_type: Optional[magpie.permissions.PermissionType] = None, basic_info: bool = False, dotted: bool = False) → magpie.typedefs.JSON

Formats a Resource information into JSON.

format_resource_tree(children: magpie.typedefs.ChildrenResourceNodes, db_session: sqlalchemy.orm.session.Session, resources_perms_dict: Optional[magpie.typedefs.ResourcePermissionMap] = None, permission_type: Optional[magpie.permissions.PermissionType] = None) → magpie.typedefs.JSON

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

format_resource_with_children(resource: magpie.typedefs.ServiceOrResourceType, db_session: sqlalchemy.orm.session.Session) → magpie.typedefs.JSON

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

magpie.api.management.resource.resource_formats.format_resource(resource: magpie.models.Resource, permissions: Optional[Collection[magpie.typedefs.AnyPermissionType]] = None, permission_type: Optional[magpie.permissions.PermissionType] = None, basic_info: bool = False, dotted: bool = False)magpie.typedefs.JSON[source]

Formats a Resource information into JSON.

Parameters
  • resourceResource to be formatted.

  • permissions – Permissions to list along with the resource. By default, these are the applicable permissions for that corresponding resource type.

  • permission_type – Override indication of provenance to apply to permissions. Only applicable when they are provided.

  • basic_info – If True, return only sufficient details to identify the resource, without any additional permissions detail, nor hierarchical resource information is returned.

  • dotted – Employ a dot (.) instead of underscore (_) to separate Resource from its basic information.

magpie.api.management.resource.resource_formats.format_resource_tree(children: magpie.typedefs.ChildrenResourceNodes, db_session: sqlalchemy.orm.session.Session, resources_perms_dict: Optional[magpie.typedefs.ResourcePermissionMap] = None, permission_type: Optional[magpie.permissions.PermissionType] = None)magpie.typedefs.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: magpie.typedefs.ServiceOrResourceType, db_session: sqlalchemy.orm.session.Session)magpie.typedefs.JSON[source]

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