magpie.api.management.service.service_formats
¶
Module Contents¶
Functions¶
|
Formats a Service information into JSON. |
|
Formats the service and its children resource tree as a JSON body. |
|
-
magpie.api.management.service.service_formats.
format_service
(service: magpie.models.Service, permissions: Optional[List[magpie.permissions.PermissionSet]] = None, permission_type: Optional[magpie.permissions.PermissionType] = None, show_private_url: bool = False, show_public_url: bool = True, show_resources_allowed: bool = False, show_configuration: bool = False, basic_info: bool = False, dotted: bool = False) → magpie.typedefs.JSON[source]¶ Formats a Service information into JSON.
Note
Automatically finds
permissions
of theservice
if not specified. To preserve empty permissions such as during listing of user/group resource permissions, an emptylist
should be specified.- Parameters
service – Service 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.show_private_url – Display the protected and private URL employed at service registration.
show_public_url – Display the generated public URL from configured Twitcher Settings.
show_resources_allowed – Display children resource details.
show_configuration – Display the applicable configuration of the Service if it supports it.
basic_info – If
True
, return only sufficient details to identify the service, without any additional details aboutpermissions
, children resources or configuration information is returned.dotted – Employ a dot (
.
) instead of underscore (_
) to separate Service from its basic information.
-
magpie.api.management.service.service_formats.
format_service_resources
(service: magpie.models.Service, db_session: sqlalchemy.orm.session.Session, service_perms: Optional[List[magpie.permissions.PermissionSet]] = None, resources_perms_dict: Optional[magpie.typedefs.ResourcePermissionMap] = None, permission_type: Optional[magpie.permissions.PermissionType] = None, show_all_children: bool = False, show_private_url: bool = True) → magpie.typedefs.JSON[source]¶ Formats the service and its children resource tree as a JSON body.
- Parameters
service – service for which to display details with sub-resources
db_session – database session
service_perms – If provided, sets Applied Permissions to display on the formatted
service
. Otherwise, sets the Allowed Permissions specific to theservice
’s type.resources_perms_dict – If provided (not
None
), set the Applied Permissions on each specified resource matched by ID. IfNone
, retrieve and set Allowed Permissions for the corresponding resources under the service. To set empty Applied Permissions (e.g.: User doesn’t have permissions on that resource), provide an explicit empty dictionary instead.permission_type – Provide permission type being rendered.
show_all_children – Display all children resources recursively, or only ones specified by ID with
resources_perms_dict
.show_private_url – displays the
- Returns
JSON body representation of the service resource tree
-
magpie.api.management.service.service_formats.
format_service_resource_type
(resource_class: Type[magpie.models.Resource], service_class: Type[magpie.services.ServiceInterface]) → magpie.typedefs.JSON[source]¶