magpie.api.management.resource.resource_utils¶
Module Contents¶
-
magpie.api.management.resource.resource_utils.check_valid_service_or_resource_permission(permission_name, service_or_resource, db_session) → Optional[Permission][source]¶ Checks if a permission is valid to be applied to a specific service or a resource under a root service.
Parameters: - permission_name – permission name to be validated
- service_or_resource – resource item corresponding to either a Service or a Resource
- db_session – db connection
Returns: valid Permission if allowed by the service/resource
-
magpie.api.management.resource.resource_utils.check_valid_service_resource(parent_resource, resource_type, db_session)[source]¶ Checks if a new Resource can be contained under a parent Resource given the requested type and the corresponding Service under which the parent Resource is already assigned.
Parameters: - parent_resource – Resource under which the new resource of resource_type must be placed
- resource_type – desired resource type
- db_session –
Returns: root Service if all checks were successful
-
magpie.api.management.resource.resource_utils.crop_tree_with_permission(children, resource_id_list)[source]¶
-
magpie.api.management.resource.resource_utils.get_service_or_resource_types(service_or_resource) → Tuple[Type[ServiceInterface], Str][source]¶ Obtain the service or resource class and a corresponding
"service"or"resource"type identifier.
-
magpie.api.management.resource.resource_utils.get_resource_permissions(resource, db_session) → List[Permission][source]¶
-
magpie.api.management.resource.resource_utils.get_resource_root_service(resource, db_session) → Optional[models.Resource][source]¶ Recursively rewinds back through the top of the resource tree up to the top-level service-resource.
Parameters: - resource – initial resource where to start searching upwards the tree
- db_session –
Returns: resource-tree root service as a resource object