Source code for magpie.permissions
from enum import Enum
from typing import TYPE_CHECKING
from six import with_metaclass
from magpie.utils import ExtendedEnumMeta
if TYPE_CHECKING:
# pylint: disable=W0611,unused-import
from magpie.typedefs import Iterable, List, Optional, Str, AnyPermissionType # noqa: F401
[docs]class Permission(with_metaclass(ExtendedEnumMeta, Enum)):
"""
Applicable :term:`Permission` values under certain :term:`Service` and :term:`Resource`.
"""
# file/dir permissions
[docs] READ_MATCH = "read-match"
[docs] WRITE_MATCH = "write-match"
# WPS permissions
[docs] GET_CAPABILITIES = "getcapabilities"
[docs] GET_FEATURE_INFO = "getfeatureinfo"
[docs] GET_LEGEND_GRAPHIC = "getlegendgraphic"
[docs] GET_FEATURE = "getfeature"
[docs] DESCRIBE_FEATURE_TYPE = "describefeaturetype"
[docs] DESCRIBE_PROCESS = "describeprocess"
[docs] LOCK_FEATURE = "lockfeature"
[docs] TRANSACTION = "transaction"
[docs]def convert_permission(permission):
# type: (AnyPermissionType) -> Optional[Permission]
"""
Converts any permission representation to the :class:`Permission` enum.
If the permission cannot be matched to one of the enum's value, ``None`` is returned instead.
"""
perm = Permission.get(permission)
if perm is not None:
return perm
return Permission.get(getattr(permission, "perm_name", None) or permission)