magpie.api.management.group.group_utils¶
Functions¶
|
Get all existing group names from the database. |
|
Get formatted JSON body describing all service resources the |
|
Creates a group if it is permitted and not conflicting. |
Obtains the group service/resource permission that corresponds to the provided one. |
|
Creates a permission on a group/resource combination if it is permitted and not conflicting. |
|
Get a dictionary of resources and corresponding permissions that a group has on the resources. |
|
Get validated response with group resource permissions as content. |
|
Get validated response on deleted group resource permission. |
|
|
Nest and regroup the resource permissions under corresponding root service types. |
Get validated response of services the group has permissions on. |
|
Get all permissions the group has on a specific service. |
|
Get validated response of found group service permissions. |
|
Get all permissions the group has on a specific service's children resources. |
|
Get validated response of all found service resources which the group has permissions on. |
Module Contents¶
- magpie.api.management.group.group_utils.get_all_group_names(db_session: sqlalchemy.orm.session.Session) List[magpie.typedefs.Str] [source]¶
Get all existing group names from the database.
- magpie.api.management.group.group_utils.get_group_resources(group: magpie.models.Group, db_session: sqlalchemy.orm.session.Session, service_types: List[magpie.typedefs.Str] | None = None) magpie.typedefs.JSON [source]¶
Get formatted JSON body describing all service resources the
group
as permissions on.
- magpie.api.management.group.group_utils.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 [source]¶
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.
- magpie.api.management.group.group_utils.get_similar_group_resource_permission(group: magpie.models.Group, resource: magpie.typedefs.ServiceOrResourceType, permission: magpie.permissions.PermissionSet, db_session: sqlalchemy.orm.session.Session) magpie.permissions.PermissionSet | None [source]¶
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.
- magpie.api.management.group.group_utils.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 [source]¶
Creates a permission on a group/resource combination if it is permitted and not conflicting.
- Parameters:
group – group for which to create/update the permission.
resource – service or resource for which to create the permission.
permission – permission with modifiers to be applied.
db_session – database connection.
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 isTrue
, 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.
- magpie.api.management.group.group_utils.get_group_resources_permissions_dict(group: magpie.models.Group, db_session: sqlalchemy.orm.session.Session, resource_ids: Iterable[int] | None = None, resource_types: Iterable[magpie.typedefs.Str] | None = None) magpie.typedefs.ResourcePermissionMap [source]¶
Get a dictionary of resources and corresponding permissions that a group has on the resources.
Filter search by
resource_ids
and/orresource_types
if specified.
- magpie.api.management.group.group_utils.get_group_resource_permissions_response(group: magpie.models.Group, resource: magpie.models.Resource, db_session: sqlalchemy.orm.session.Session) pyramid.httpexceptions.HTTPException [source]¶
Get validated response with group resource permissions as content.
- Returns:
valid HTTP response on successful operations.
- Raises:
HTTPException – error HTTP response of corresponding situation.
- magpie.api.management.group.group_utils.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 [source]¶
Get validated response on deleted group resource permission.
- Parameters:
group – group for which to delete the permission.
resource – service or resource for which to delete the permission.
permission – permission with modifiers to be deleted.
db_session – database connection.
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.
- magpie.api.management.group.group_utils.get_group_services(resources_permissions_dict: magpie.typedefs.JSON, db_session: sqlalchemy.orm.session.Session, service_types: List[magpie.typedefs.Str] | None = None) magpie.typedefs.JSON [source]¶
Nest and regroup the resource permissions under corresponding root service types.
- magpie.api.management.group.group_utils.get_group_services_response(group: magpie.models.Group, db_session: sqlalchemy.orm.session.Session, service_types: List[magpie.typedefs.Str] | None = None) pyramid.httpexceptions.HTTPException [source]¶
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.
- magpie.api.management.group.group_utils.get_group_service_permissions(group: magpie.models.Group, service: magpie.models.Service, db_session: sqlalchemy.orm.session.Session) List[magpie.permissions.PermissionSet] [source]¶
Get all permissions the group has on a specific service.
- magpie.api.management.group.group_utils.get_group_service_permissions_response(group: magpie.models.Group, service: magpie.models.Service, db_session: sqlalchemy.orm.session.Session) pyramid.httpexceptions.HTTPException [source]¶
Get validated response of found group service permissions.
- Returns:
valid HTTP response on successful operations.
- Raises:
HTTPException – error HTTP response of corresponding situation.
- magpie.api.management.group.group_utils.get_group_service_resources_permissions_dict(group: magpie.models.Group, service: magpie.models.Service, db_session: sqlalchemy.orm.session.Session) magpie.typedefs.ResourcePermissionMap [source]¶
Get all permissions the group has on a specific service’s children resources.
- magpie.api.management.group.group_utils.get_group_service_resources_response(group: magpie.models.Group, service: magpie.models.Service, db_session: sqlalchemy.orm.session.Session) pyramid.httpexceptions.HTTPException [source]¶
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.