magpie.api.management.service.service_views

Attributes

SERVICES_PHOENIX_ALLOWED

SERVICE_TYPE_DICT

CONTENT_TYPE_JSON

Classes

Permission

Applicable Permission values (names) under certain Service and Resource.

PermissionType

Applicable types of Permission according to context.

Functions

format_permissions(→ Dict[magpie.typedefs.Str, ...)

Obtains the formatted permission representations after validation that each of their name is a known member of

sync_services_phoenix(→ bool)

Syncs Magpie services by pushing updates to Phoenix.

invalidate_service(→ None)

Invalidates any caching reference to the specified service name.

service_factory(→ ServiceInterface)

Retrieve the specific service class from the provided database service entry.

get_service_types_view(→ magpie.typedefs.AnyResponseType)

List all available service types.

get_services_by_type_view(...)

List all registered services from a specific type.

get_services_view(→ magpie.typedefs.AnyResponseType)

List all registered services.

get_services_runner(→ magpie.typedefs.AnyResponseType)

Generates services response format from request conditions.

register_service_view(→ magpie.typedefs.AnyResponseType)

Registers a new service.

update_service_view(→ magpie.typedefs.AnyResponseType)

Update service information.

get_service_view(→ magpie.typedefs.AnyResponseType)

Get service information.

unregister_service_view(→ magpie.typedefs.AnyResponseType)

Unregister a service.

get_service_permissions_view(...)

List all applicable permissions for a service.

get_service_resource_view(...)

Get resource information under a service.

delete_service_resource_view(...)

Unregister a resource.

get_service_resources_view(...)

List all resources registered under a service.

create_service_resource_view(...)

Register a new resource directly under a service or under one of its children resources.

get_service_type_resources_view(...)

List details of resource types supported under a specific service type.

get_service_type_resource_types_view(...)

List all resource types supported under a specific service type.

Module Contents

class magpie.api.management.service.service_views.Permission[source]

Bases: magpie.utils.ExtendedEnum

Applicable Permission values (names) under certain Service and Resource.

READ = 'read'
WRITE = 'write'
ACCESS = 'access'
BROWSE = 'browse'
GET_CAPABILITIES = 'getcapabilities'
GET_MAP = 'getmap'
GET_FEATURE_INFO = 'getfeatureinfo'
GET_LEGEND_GRAPHIC = 'getlegendgraphic'
GET_METADATA = 'getmetadata'
GET_PROPERTY_VALUE = 'getpropertyvalue'
GET_FEATURE = 'getfeature'
GET_FEATURE_WITH_LOCK = 'getfeaturewithlock'
GET_GML_OBJECT = 'getgmlobject'
DESCRIBE_FEATURE_TYPE = 'describefeaturetype'
DESCRIBE_LAYER = 'describelayer'
DESCRIBE_PROCESS = 'describeprocess'
EXECUTE = 'execute'
LOCK_FEATURE = 'lockfeature'
TRANSACTION = 'transaction'
CREATE_STORED_QUERY = 'createstoredquery'
DROP_STORED_QUERY = 'dropstoredquery'
LIST_STORED_QUERIES = 'liststoredqueries'
DESCRIBE_STORED_QUERIES = 'describestoredqueries'
class magpie.api.management.service.service_views.PermissionType[source]

Bases: magpie.utils.ExtendedEnum

Applicable types of Permission according to context.

ACCESS = 'access'
ALLOWED = 'allowed'
APPLIED = 'applied'
DIRECT = 'direct'
INHERITED = 'inherited'
EFFECTIVE = 'effective'
OWNED = 'owned'
magpie.api.management.service.service_views.format_permissions(permissions: Collection[magpie.typedefs.AnyPermissionType] | None, permission_type: PermissionType | None = None, force_unique: bool = True) Dict[magpie.typedefs.Str, List[magpie.typedefs.Str] | magpie.typedefs.PermissionDict | magpie.typedefs.Str][source]

Obtains the formatted permission representations after validation that each of their name is a known member of Permission enum, and optionally with modifiers as defined by PermissionSet.

The returned lists are sorted alphabetically by permission name, and then in order of resolution priority (from highest to lowest) for each subset or corresponding name.

The permissions are cleaned from any duplicate entries, unless force_unique is specified to allow it. If no or empty permissions is provided, empty lists are returned.

Note

Field permission_names provides both the older implicit permission names and the newer explicit name representation. For this reason, there will be semantically “duplicate” permissions in that list, but there will not be any literal string duplicates. Implicit names are immediately followed by their explicit name, unless implicit names do not apply for the given permission (e.g.: when Access.DENY did not exist). Only detailed and explicit JSON representations are provided in the permissions list.

When permission_type is equal to PermissionType.ALLOWED, the collection of every applicable PermissionSet is automatically generated by expanding all combinations of Access and Scope with every provided Permission name in permissions. This allows more concise definition of allowed permissions under magpie.services.Services and their children Resource by only defining Permission names without manually listing all variations of PermissionSet.

For other permission_type values, which represent Applied Permission only explicitly provided permissions are returned, to effectively return the collection of active permissions.

Parameters:
  • permissions – multiple permissions of any implementation and type, to be rendered both as names and JSON.

  • permission_type – indication of the represented permissions to be formatted, for informative indication.

  • force_unique – whether to remove duplicate entries by association of name, access and scope or not.

Returns:

JSON with the permissions listed as implicit+explicit names, as permission set objects, and their type.

magpie.api.management.service.service_views.SERVICES_PHOENIX_ALLOWED[source]
magpie.api.management.service.service_views.sync_services_phoenix(services: Iterable[magpie.models.Service] | magpie.typedefs.JSON, services_as_dicts: bool = False) bool[source]

Syncs Magpie services by pushing updates to Phoenix.

Services must be one of types specified in magpie.register.SERVICES_PHOENIX_ALLOWED.

Parameters:
  • services

    An iterable of models.Service by default, or a dictionary of {svc-name: {<service-info>}} JSON objects containing each service’s information if services_ad_dicts is True.

    where <service-info> is defined as:

    {"public_url": <url>, "service_name": <name>, "service_type": <type>}
    

  • services_as_dicts – indicate if services must be parsed as JSON definitions.

magpie.api.management.service.service_views.SERVICE_TYPE_DICT[source]
magpie.api.management.service.service_views.invalidate_service(service_name: magpie.typedefs.Str) None[source]

Invalidates any caching reference to the specified service name.

magpie.api.management.service.service_views.service_factory(service: magpie.models.Service, request: pyramid.request.Request) ServiceInterface[source]

Retrieve the specific service class from the provided database service entry.

magpie.api.management.service.service_views.CONTENT_TYPE_JSON = 'application/json'[source]
magpie.api.management.service.service_views.get_service_types_view(request: pyramid.request.Request) magpie.typedefs.AnyResponseType[source]

List all available service types.

magpie.api.management.service.service_views.get_services_by_type_view(request: pyramid.request.Request) magpie.typedefs.AnyResponseType[source]

List all registered services from a specific type.

magpie.api.management.service.service_views.get_services_view(request: pyramid.request.Request) magpie.typedefs.AnyResponseType[source]

List all registered services.

magpie.api.management.service.service_views.get_services_runner(request: pyramid.request.Request) magpie.typedefs.AnyResponseType[source]

Generates services response format from request conditions.

Obtains the full or filtered list of services categorized by type, or listed as flat list according to request path and query parameters.

magpie.api.management.service.service_views.register_service_view(request: pyramid.request.Request) magpie.typedefs.AnyResponseType[source]

Registers a new service.

magpie.api.management.service.service_views.update_service_view(request: pyramid.request.Request) magpie.typedefs.AnyResponseType[source]

Update service information.

magpie.api.management.service.service_views.get_service_view(request: pyramid.request.Request) magpie.typedefs.AnyResponseType[source]

Get service information.

magpie.api.management.service.service_views.unregister_service_view(request: pyramid.request.Request) magpie.typedefs.AnyResponseType[source]

Unregister a service.

magpie.api.management.service.service_views.get_service_permissions_view(request: pyramid.request.Request) magpie.typedefs.AnyResponseType[source]

List all applicable permissions for a service.

magpie.api.management.service.service_views.get_service_resource_view(request: pyramid.request.Request) magpie.typedefs.AnyResponseType[source]

Get resource information under a service.

magpie.api.management.service.service_views.delete_service_resource_view(request: pyramid.request.Request) magpie.typedefs.AnyResponseType[source]

Unregister a resource.

magpie.api.management.service.service_views.get_service_resources_view(request: pyramid.request.Request) magpie.typedefs.AnyResponseType[source]

List all resources registered under a service.

magpie.api.management.service.service_views.create_service_resource_view(request: pyramid.request.Request) magpie.typedefs.AnyResponseType[source]

Register a new resource directly under a service or under one of its children resources.

magpie.api.management.service.service_views.get_service_type_resources_view(request: pyramid.request.Request) magpie.typedefs.AnyResponseType[source]

List details of resource types supported under a specific service type.

magpie.api.management.service.service_views.get_service_type_resource_types_view(request: pyramid.request.Request) magpie.typedefs.AnyResponseType[source]

List all resource types supported under a specific service type.