projectal.entities.task_template API documentation

# projectal.entities.task_template

View Source

     1from projectal import api
     2from projectal.entity import Entity
     3from projectal.linkers import *
     4
     5
     6class TaskTemplate(Entity, ResourceLinker, SkillLinker, FileLinker, StaffLinker, RebateLinker,
     7                   NoteLinker, TagLinker):
     8    """
     9    Implementation of the
    10    [Task Template](https://projectal.com/docs/latest/#tag/Task-Template) API.
    11    """
    12    _path = 'template/task'
    13    _name = 'task_template'
    14    _links = [ResourceLinker, SkillLinker, FileLinker, StaffLinker, RebateLinker,
    15              NoteLinker, TagLinker]
    16
    17    def clone(self, holder, entity):
    18        url = '/api/template/task/clone?holder={}&reference={}'\
    19            .format(holder['uuId'], self['uuId'])
    20        response = api.post(url, entity)
    21        return response['jobClue']['uuId']
    22
    23    @classmethod
    24    def create(cls, holder, entity):
    25        """Create a Task Template
    26
    27        `holder`: `uuId` of the owner
    28
    29        `entity`: The fields of the entity to be created
    30        """
    31        holder = holder['uuId'] if isinstance(holder, dict) else holder
    32        params = "?holder=" + holder
    33        return super().create(entity, params)
    34
    35    @classmethod
    36    def link_predecessor_task(cls, task, predecessor_task):
    37        return cls.__plan(task, predecessor_task, 'add')
    38
    39    @classmethod
    40    def relink_predecessor_task(cls, task, predecessor_task):
    41        return cls.__plan(task, predecessor_task, 'update')
    42
    43    @classmethod
    44    def unlink_predecessor_task(cls, task, predecessor_task):
    45        return cls.__plan(task, predecessor_task, 'delete')
    46
    47    @classmethod
    48    def __plan(cls, from_task, to_task, operation):
    49        url = '/api/template/task/plan/task/{}'.format(operation)
    50        payload = {
    51            'uuId': from_task['uuId'],
    52            'taskList': [to_task]
    53        }
    54        api.post(url, payload=payload)
    55        return True

class TaskTemplate(projectal.entity.Entity, projectal.linkers.ResourceLinker, projectal.linkers.SkillLinker, projectal.linkers.FileLinker, projectal.linkers.StaffLinker, projectal.linkers.RebateLinker, projectal.linkers.NoteLinker, projectal.linkers.TagLinker): View Source

     7class TaskTemplate(Entity, ResourceLinker, SkillLinker, FileLinker, StaffLinker, RebateLinker,
     8                   NoteLinker, TagLinker):
     9    """
    10    Implementation of the
    11    [Task Template](https://projectal.com/docs/latest/#tag/Task-Template) API.
    12    """
    13    _path = 'template/task'
    14    _name = 'task_template'
    15    _links = [ResourceLinker, SkillLinker, FileLinker, StaffLinker, RebateLinker,
    16              NoteLinker, TagLinker]
    17
    18    def clone(self, holder, entity):
    19        url = '/api/template/task/clone?holder={}&reference={}'\
    20            .format(holder['uuId'], self['uuId'])
    21        response = api.post(url, entity)
    22        return response['jobClue']['uuId']
    23
    24    @classmethod
    25    def create(cls, holder, entity):
    26        """Create a Task Template
    27
    28        `holder`: `uuId` of the owner
    29
    30        `entity`: The fields of the entity to be created
    31        """
    32        holder = holder['uuId'] if isinstance(holder, dict) else holder
    33        params = "?holder=" + holder
    34        return super().create(entity, params)
    35
    36    @classmethod
    37    def link_predecessor_task(cls, task, predecessor_task):
    38        return cls.__plan(task, predecessor_task, 'add')
    39
    40    @classmethod
    41    def relink_predecessor_task(cls, task, predecessor_task):
    42        return cls.__plan(task, predecessor_task, 'update')
    43
    44    @classmethod
    45    def unlink_predecessor_task(cls, task, predecessor_task):
    46        return cls.__plan(task, predecessor_task, 'delete')
    47
    48    @classmethod
    49    def __plan(cls, from_task, to_task, operation):
    50        url = '/api/template/task/plan/task/{}'.format(operation)
    51        payload = {
    52            'uuId': from_task['uuId'],
    53            'taskList': [to_task]
    54        }
    55        api.post(url, payload=payload)
    56        return True

Implementation of the Task Template API.

def clone(self, holder, entity): View Source

    18    def clone(self, holder, entity):
    19        url = '/api/template/task/clone?holder={}&reference={}'\
    20            .format(holder['uuId'], self['uuId'])
    21        response = api.post(url, entity)
    22        return response['jobClue']['uuId']

Clones an entity and returns its `uuId`.

Each entity has its own set of required values when cloning. Check the API documentation of that entity for details.

@classmethod
def create(cls, holder, entity): View Source

    24    @classmethod
    25    def create(cls, holder, entity):
    26        """Create a Task Template
    27
    28        `holder`: `uuId` of the owner
    29
    30        `entity`: The fields of the entity to be created
    31        """
    32        holder = holder['uuId'] if isinstance(holder, dict) else holder
    33        params = "?holder=" + holder
    34        return super().create(entity, params)

Create a Task Template

`holder`: `uuId` of the owner

`entity`: The fields of the entity to be created

@classmethod
def link_predecessor_task(cls, task, predecessor_task): View Source

    36    @classmethod
    37    def link_predecessor_task(cls, task, predecessor_task):
    38        return cls.__plan(task, predecessor_task, 'add')

@classmethod
def relink_predecessor_task(cls, task, predecessor_task): View Source

    40    @classmethod
    41    def relink_predecessor_task(cls, task, predecessor_task):
    42        return cls.__plan(task, predecessor_task, 'update')

@classmethod
def unlink_predecessor_task(cls, task, predecessor_task): View Source

    44    @classmethod
    45    def unlink_predecessor_task(cls, task, predecessor_task):
    46        return cls.__plan(task, predecessor_task, 'delete')

##### Inherited Members

projectal.entity.Entity
  get
  update
  delete
  history
  save
  list
  match
  match_startswith
  match_endswith
  match_one
  match_startswith_one
  match_endswith_one
  search
  query
  profile_get
  profile_set
  changes
  set_readonly
  get_link_definitions
  entity_name
projectal.linkers.ResourceLinker
  link_resource
  relink_resource
  unlink_resource
projectal.linkers.SkillLinker
  link_skill
  relink_skill
  unlink_skill
projectal.linkers.FileLinker
  link_file
  unlink_file
projectal.linkers.StaffLinker
  link_staff
  relink_staff
  unlink_staff
projectal.linkers.RebateLinker
  link_rebate
  unlink_rebate
projectal.linkers.TagLinker
  link_tag
  unlink_tag
builtins.dict
  setdefault
  pop
  popitem
  keys
  items
  values
  fromkeys
  clear
  copy