magpie.api.management.group.group_utils ======================================= .. py:module:: magpie.api.management.group.group_utils Functions --------- .. autoapisummary:: magpie.api.management.group.group_utils.get_all_group_names magpie.api.management.group.group_utils.get_group_resources magpie.api.management.group.group_utils.create_group magpie.api.management.group.group_utils.get_similar_group_resource_permission magpie.api.management.group.group_utils.create_group_resource_permission_response magpie.api.management.group.group_utils.get_group_resources_permissions_dict magpie.api.management.group.group_utils.get_group_resource_permissions_response magpie.api.management.group.group_utils.delete_group_resource_permission_response magpie.api.management.group.group_utils.get_group_services magpie.api.management.group.group_utils.get_group_services_response magpie.api.management.group.group_utils.get_group_service_permissions magpie.api.management.group.group_utils.get_group_service_permissions_response magpie.api.management.group.group_utils.get_group_service_resources_permissions_dict magpie.api.management.group.group_utils.get_group_service_resources_response Module Contents --------------- .. py:function:: get_all_group_names(db_session: sqlalchemy.orm.session.Session) -> List[magpie.typedefs.Str] Get all existing group names from the database. .. py:function:: get_group_resources(group: magpie.models.Group, db_session: sqlalchemy.orm.session.Session, service_types: Optional[List[magpie.typedefs.Str]] = None) -> magpie.typedefs.JSON Get formatted JSON body describing all service resources the ``group`` as permissions on. .. py:function:: create_group(group_name: magpie.typedefs.Str, description: magpie.typedefs.Str, discoverable: bool, terms: magpie.typedefs.Str, db_session: sqlalchemy.orm.session.Session) -> pyramid.httpexceptions.HTTPException Creates a group if it is permitted and not conflicting. :returns: valid HTTP response on successful operations. :raises HTTPException: error HTTP response of corresponding situation. .. py:function:: get_similar_group_resource_permission(group: magpie.models.Group, resource: magpie.typedefs.ServiceOrResourceType, permission: magpie.permissions.PermissionSet, db_session: sqlalchemy.orm.session.Session) -> Optional[magpie.permissions.PermissionSet] Obtains the group service/resource permission that corresponds to the provided one. Lookup considers only *similar* applied permission such that other permission modifiers don't affect comparison. .. py:function:: create_group_resource_permission_response(group: magpie.models.Group, resource: magpie.typedefs.ServiceOrResourceType, permission: magpie.permissions.PermissionSet, db_session: sqlalchemy.orm.session.Session, overwrite: bool = False) -> pyramid.httpexceptions.HTTPException Creates a permission on a group/resource combination if it is permitted and not conflicting. :param group: group for which to create/update the permission. :param resource: service or resource for which to create the permission. :param permission: permission with modifiers to be applied. :param db_session: database connection. :param overwrite: If the corresponding `(group, resource, permission[name])` exists, there is a conflict. Conflict is considered only by permission-name regardless of other modifiers. If overwrite is ``False``, the conflict will be raised and not be applied. If overwrite is ``True``, the permission modifiers will be replaced by the new ones, or created if missing. :returns: valid HTTP response on successful operations. :raises HTTPException: error HTTP response of corresponding situation. .. py:function:: get_group_resources_permissions_dict(group: magpie.models.Group, db_session: sqlalchemy.orm.session.Session, resource_ids: Optional[Iterable[int]] = None, resource_types: Optional[Iterable[magpie.typedefs.Str]] = None) -> magpie.typedefs.ResourcePermissionMap Get a dictionary of resources and corresponding permissions that a group has on the resources. Filter search by ``resource_ids`` and/or ``resource_types`` if specified. .. py:function:: get_group_resource_permissions_response(group: magpie.models.Group, resource: magpie.models.Resource, db_session: sqlalchemy.orm.session.Session) -> pyramid.httpexceptions.HTTPException Get validated response with group resource permissions as content. :returns: valid HTTP response on successful operations. :raises HTTPException: error HTTP response of corresponding situation. .. py:function:: delete_group_resource_permission_response(group: magpie.models.Group, resource: magpie.typedefs.ServiceOrResourceType, permission: magpie.permissions.PermissionSet, db_session: sqlalchemy.orm.session.Session, similar: bool = True) -> pyramid.httpexceptions.HTTPException Get validated response on deleted group resource permission. :param group: group for which to delete the permission. :param resource: service or resource for which to delete the permission. :param permission: permission with modifiers to be deleted. :param db_session: database connection. :param similar: Allow matching provided permission against any similar database permission. Otherwise, must match exactly. :returns: valid HTTP response on successful operations. :raises HTTPException: error HTTP response of corresponding situation. .. py:function:: get_group_services(resources_permissions_dict: magpie.typedefs.JSON, db_session: sqlalchemy.orm.session.Session, service_types: Optional[List[magpie.typedefs.Str]] = None) -> magpie.typedefs.JSON Nest and regroup the resource permissions under corresponding root service types. .. py:function:: get_group_services_response(group: magpie.models.Group, db_session: sqlalchemy.orm.session.Session, service_types: Optional[List[magpie.typedefs.Str]] = None) -> pyramid.httpexceptions.HTTPException Get validated response of services the group has permissions on. :returns: valid HTTP response on successful operations. :raises HTTPException: error HTTP response of corresponding situation. .. py:function:: get_group_service_permissions(group: magpie.models.Group, service: magpie.models.Service, db_session: sqlalchemy.orm.session.Session) -> List[magpie.permissions.PermissionSet] Get all permissions the group has on a specific service. .. py:function:: get_group_service_permissions_response(group: magpie.models.Group, service: magpie.models.Service, db_session: sqlalchemy.orm.session.Session) -> pyramid.httpexceptions.HTTPException Get validated response of found group service permissions. :returns: valid HTTP response on successful operations. :raises HTTPException: error HTTP response of corresponding situation. .. py:function:: get_group_service_resources_permissions_dict(group: magpie.models.Group, service: magpie.models.Service, db_session: sqlalchemy.orm.session.Session) -> magpie.typedefs.ResourcePermissionMap Get all permissions the group has on a specific service's children resources. .. py:function:: get_group_service_resources_response(group: magpie.models.Group, service: magpie.models.Service, db_session: sqlalchemy.orm.session.Session) -> pyramid.httpexceptions.HTTPException Get validated response of all found service resources which the group has permissions on. :returns: valid HTTP response on successful operations. :raises HTTPException: error HTTP response of corresponding situation.