magpie.api.management.service.service_views =========================================== .. py:module:: magpie.api.management.service.service_views Attributes ---------- .. autoapisummary:: magpie.api.management.service.service_views.SERVICES_PHOENIX_ALLOWED magpie.api.management.service.service_views.SERVICE_TYPE_DICT magpie.api.management.service.service_views.CONTENT_TYPE_JSON Classes ------- .. autoapisummary:: magpie.api.management.service.service_views.Permission magpie.api.management.service.service_views.PermissionType Functions --------- .. autoapisummary:: magpie.api.management.service.service_views.format_permissions magpie.api.management.service.service_views.sync_services_phoenix magpie.api.management.service.service_views.invalidate_service magpie.api.management.service.service_views.service_factory magpie.api.management.service.service_views.get_service_types_view magpie.api.management.service.service_views.get_services_by_type_view magpie.api.management.service.service_views.get_services_view magpie.api.management.service.service_views.get_services_runner magpie.api.management.service.service_views.register_service_view magpie.api.management.service.service_views.update_service_view magpie.api.management.service.service_views.get_service_view magpie.api.management.service.service_views.unregister_service_view magpie.api.management.service.service_views.get_service_permissions_view magpie.api.management.service.service_views.get_service_resource_view magpie.api.management.service.service_views.delete_service_resource_view magpie.api.management.service.service_views.get_service_resources_view magpie.api.management.service.service_views.create_service_resource_view magpie.api.management.service.service_views.get_service_type_resources_view magpie.api.management.service.service_views.get_service_type_resource_types_view Module Contents --------------- .. py:class:: Permission Bases: :py:obj:`magpie.utils.ExtendedEnum` Applicable :term:`Permission` values (names) under certain :term:`Service` and :term:`Resource`. .. py:attribute:: READ :value: 'read' .. py:attribute:: WRITE :value: 'write' .. py:attribute:: ACCESS :value: 'access' .. py:attribute:: BROWSE :value: 'browse' .. py:attribute:: GET_CAPABILITIES :value: 'getcapabilities' .. py:attribute:: GET_MAP :value: 'getmap' .. py:attribute:: GET_FEATURE_INFO :value: 'getfeatureinfo' .. py:attribute:: GET_LEGEND_GRAPHIC :value: 'getlegendgraphic' .. py:attribute:: GET_METADATA :value: 'getmetadata' .. py:attribute:: GET_PROPERTY_VALUE :value: 'getpropertyvalue' .. py:attribute:: GET_FEATURE :value: 'getfeature' .. py:attribute:: GET_FEATURE_WITH_LOCK :value: 'getfeaturewithlock' .. py:attribute:: GET_GML_OBJECT :value: 'getgmlobject' .. py:attribute:: DESCRIBE_FEATURE_TYPE :value: 'describefeaturetype' .. py:attribute:: DESCRIBE_LAYER :value: 'describelayer' .. py:attribute:: DESCRIBE_PROCESS :value: 'describeprocess' .. py:attribute:: EXECUTE :value: 'execute' .. py:attribute:: LOCK_FEATURE :value: 'lockfeature' .. py:attribute:: TRANSACTION :value: 'transaction' .. py:attribute:: CREATE_STORED_QUERY :value: 'createstoredquery' .. py:attribute:: DROP_STORED_QUERY :value: 'dropstoredquery' .. py:attribute:: LIST_STORED_QUERIES :value: 'liststoredqueries' .. py:attribute:: DESCRIBE_STORED_QUERIES :value: 'describestoredqueries' .. py:class:: PermissionType Bases: :py:obj:`magpie.utils.ExtendedEnum` Applicable types of :term:`Permission` according to context. .. py:attribute:: ACCESS :value: 'access' .. py:attribute:: ALLOWED :value: 'allowed' .. py:attribute:: APPLIED :value: 'applied' .. py:attribute:: DIRECT :value: 'direct' .. py:attribute:: INHERITED :value: 'inherited' .. py:attribute:: EFFECTIVE :value: 'effective' .. py:attribute:: OWNED :value: 'owned' .. py:function:: format_permissions(permissions: Optional[Collection[magpie.typedefs.AnyPermissionType]], permission_type: Optional[PermissionType] = None, force_unique: bool = True) -> Dict[magpie.typedefs.Str, Union[List[magpie.typedefs.Str], magpie.typedefs.PermissionDict, magpie.typedefs.Str]] Obtains the formatted permission representations after validation that each of their name is a known member of :class:`Permission` enum, and optionally with modifiers as defined by :class:`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 :paramref:`force_unique` is specified to allow it. If no or empty :paramref:`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 :attr:`Access.DENY` did not exist). Only detailed and explicit JSON representations are provided in the ``permissions`` list. When :paramref:`permission_type` is equal to :attr:`PermissionType.ALLOWED`, the collection of every applicable :class:`PermissionSet` is automatically generated by expanding all combinations of :class:`Access` and :class:`Scope` with every provided :class:`Permission` name in :paramref:`permissions`. This allows more concise definition of allowed permissions under :class:`magpie.services.Services` and their children :term:`Resource` by only defining :class:`Permission` names without manually listing all variations of :class:`PermissionSet`. For other :paramref:`permission_type` values, which represent :term:`Applied Permission` only explicitly provided :paramref:`permissions` are returned, to effectively return the collection of *active* permissions. :param permissions: multiple permissions of any implementation and type, to be rendered both as names and JSON. :param permission_type: indication of the represented permissions to be formatted, for informative indication. :param 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. .. py:data:: SERVICES_PHOENIX_ALLOWED .. py:function:: sync_services_phoenix(services: Union[Iterable[magpie.models.Service], magpie.typedefs.JSON], services_as_dicts: bool = False) -> bool Syncs Magpie services by pushing updates to Phoenix. Services must be one of types specified in :py:data:`magpie.register.SERVICES_PHOENIX_ALLOWED`. :param services: An iterable of :class:`models.Service` by default, or a dictionary of ``{svc-name: {}}`` JSON objects containing each service's information if :paramref:`services_ad_dicts` is ``True``. where ```` is defined as:: {"public_url": , "service_name": , "service_type": } :param services_as_dicts: indicate if services must be parsed as JSON definitions. .. py:data:: SERVICE_TYPE_DICT .. py:function:: invalidate_service(service_name: magpie.typedefs.Str) -> None Invalidates any caching reference to the specified service name. .. py:function:: service_factory(service: magpie.models.Service, request: pyramid.request.Request) -> ServiceInterface Retrieve the specific service class from the provided database service entry. .. py:data:: CONTENT_TYPE_JSON :value: 'application/json' .. py:function:: get_service_types_view(request: pyramid.request.Request) -> magpie.typedefs.AnyResponseType List all available service types. .. py:function:: get_services_by_type_view(request: pyramid.request.Request) -> magpie.typedefs.AnyResponseType List all registered services from a specific type. .. py:function:: get_services_view(request: pyramid.request.Request) -> magpie.typedefs.AnyResponseType List all registered services. .. py:function:: get_services_runner(request: pyramid.request.Request) -> magpie.typedefs.AnyResponseType 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. .. py:function:: register_service_view(request: pyramid.request.Request) -> magpie.typedefs.AnyResponseType Registers a new service. .. py:function:: update_service_view(request: pyramid.request.Request) -> magpie.typedefs.AnyResponseType Update service information. .. py:function:: get_service_view(request: pyramid.request.Request) -> magpie.typedefs.AnyResponseType Get service information. .. py:function:: unregister_service_view(request: pyramid.request.Request) -> magpie.typedefs.AnyResponseType Unregister a service. .. py:function:: get_service_permissions_view(request: pyramid.request.Request) -> magpie.typedefs.AnyResponseType List all applicable permissions for a service. .. py:function:: get_service_resource_view(request: pyramid.request.Request) -> magpie.typedefs.AnyResponseType Get resource information under a service. .. py:function:: delete_service_resource_view(request: pyramid.request.Request) -> magpie.typedefs.AnyResponseType Unregister a resource. .. py:function:: get_service_resources_view(request: pyramid.request.Request) -> magpie.typedefs.AnyResponseType List all resources registered under a service. .. py:function:: create_service_resource_view(request: pyramid.request.Request) -> magpie.typedefs.AnyResponseType Register a new resource directly under a service or under one of its children resources. .. py:function:: get_service_type_resources_view(request: pyramid.request.Request) -> magpie.typedefs.AnyResponseType List details of resource types supported under a specific service type. .. py:function:: get_service_type_resource_types_view(request: pyramid.request.Request) -> magpie.typedefs.AnyResponseType List all resource types supported under a specific service type.