projectal.dynamic_enum API documentation

# projectal.dynamic_enum

The base DynamicEnum class that all dynamic enums inherit from.

View Source

     1"""
     2The base DynamicEnum class that all dynamic enums inherit from.
     3"""
     4from projectal import api
     5
     6
     7class DynamicEnum:
     8    _name = None
     9
    10    @classmethod
    11    def get(cls):
    12        if not cls._name:
    13            raise NotImplementedError
    14        url = f"/api/system/schema?type=enum&object={cls._name}"
    15        return api.get(url)
    16
    17    @classmethod
    18    def set(cls, payload):
    19        if not cls._name:
    20            raise NotImplementedError
    21        url = (
    22            f"/api/system/schema?type=enum&object={cls._name}"
    23            "&opts=allowDisable,allowAdding,allowRename,allowDelete,allowCleanup"
    24        )
    25        return api.put(endpoint=url, payload=payload)

class DynamicEnum: View Source

     8class DynamicEnum:
     9    _name = None
    10
    11    @classmethod
    12    def get(cls):
    13        if not cls._name:
    14            raise NotImplementedError
    15        url = f"/api/system/schema?type=enum&object={cls._name}"
    16        return api.get(url)
    17
    18    @classmethod
    19    def set(cls, payload):
    20        if not cls._name:
    21            raise NotImplementedError
    22        url = (
    23            f"/api/system/schema?type=enum&object={cls._name}"
    24            "&opts=allowDisable,allowAdding,allowRename,allowDelete,allowCleanup"
    25        )
    26        return api.put(endpoint=url, payload=payload)

@classmethod
def get(cls): View Source

    11    @classmethod
    12    def get(cls):
    13        if not cls._name:
    14            raise NotImplementedError
    15        url = f"/api/system/schema?type=enum&object={cls._name}"
    16        return api.get(url)

@classmethod
def set(cls, payload): View Source

    18    @classmethod
    19    def set(cls, payload):
    20        if not cls._name:
    21            raise NotImplementedError
    22        url = (
    23            f"/api/system/schema?type=enum&object={cls._name}"
    24            "&opts=allowDisable,allowAdding,allowRename,allowDelete,allowCleanup"
    25        )
    26        return api.put(endpoint=url, payload=payload)