magpie.api.management.resource.resource_formats¶
Functions¶
|
Formats a Resource information into JSON. |
|
Generates the formatted resource tree under the provided nested resources. |
|
Obtains the formatted Resource list with their applicable permissions. |
|
Obtains the formatted Resource tree with all its formatted children hierarchy. |
Module Contents¶
- magpie.api.management.resource.resource_formats.format_resource(resource: magpie.models.Resource, permissions: Collection[magpie.typedefs.AnyPermissionType] | None = None, permission_type: magpie.permissions.PermissionType | None = None, basic_info: bool = False, dotted: bool = False) magpie.typedefs.JSON [source]¶
Formats a Resource information into JSON.
- Parameters:
resource – Resource 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 additionalpermissions
detail, nor hierarchicalresource
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(nested_resources: magpie.typedefs.NestedResourceNodes, db_session: sqlalchemy.orm.session.Session, resources_perms_dict: magpie.typedefs.ResourcePermissionMap | None = None, permission_type: magpie.permissions.PermissionType | None = None, nesting_key: magpie.typedefs.NestingKeyType = 'children') magpie.typedefs.JSON [source]¶
Generates the formatted resource tree under the provided nested resources.
For all of the nested resources, formatting is applied by calling
format_resource()
recursively on them. Apply specific resource permissions as defined byresources_perms_dict
if provided.- Parameters:
nested_resources – Service or resource for which to generate the formatted resource tree.
db_session – Connection to database.
resources_perms_dict – Any pre-established Applied Permission 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.permission_type – Override Permission type to indicate its provenance. Type is applied recursively for all resources in the generated nested resource tree.
nesting_key – Key to employ for nesting the formatted sub-tree resources according to the provided nested resources.
- Returns:
Formatted nested resource tree with their details and permissions.
- magpie.api.management.resource.resource_formats.format_resources_listed(resources: List[magpie.typedefs.ServiceOrResourceType], db_session: sqlalchemy.orm.session.Session) List[magpie.typedefs.JSON] [source]¶
Obtains the formatted Resource list with their applicable permissions.
- magpie.api.management.resource.resource_formats.format_resources_nested(resource: magpie.typedefs.ServiceOrResourceType, nested_resources: magpie.typedefs.NestedResourceNodes, nesting_key: magpie.typedefs.NestingKeyType, db_session: sqlalchemy.orm.session.Session) magpie.typedefs.JSON [source]¶
Obtains the formatted Resource tree with all its formatted children hierarchy.