magpie.api.management.service.service_formats

Functions

format_service(→ magpie.typedefs.JSON)

Formats a Service information into JSON.

format_service_resources(→ magpie.typedefs.JSON)

Formats the service and its children resource tree as a JSON body.

format_service_resource_type(→ magpie.typedefs.JSON)

Module Contents

magpie.api.management.service.service_formats.format_service(service: magpie.models.Service, permissions: List[magpie.permissions.PermissionSet] | None = None, permission_type: magpie.permissions.PermissionType | None = 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 the service if not specified. To preserve empty permissions such as during listing of user/group resource permissions, an empty list should be specified.

Parameters:
  • serviceService 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 about permissions, 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: List[magpie.permissions.PermissionSet] | None = None, resources_perms_dict: magpie.typedefs.ResourcePermissionMap | None = None, permission_type: magpie.permissions.PermissionType | None = 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 all Applied Permission to display on the formatted service. Otherwise, sets Allowed Permissions specific to the service’s type.

  • resources_perms_dict – If provided (not None), set the Applied Permission on each specified resource matched by ID. If None, retrieve and set Allowed Permissions for the corresponding Resources under the Service. To set empty Applied Permission (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]