projectal.entities.staff API documentation

# projectal.entities.staff

View Source

      1from datetime import datetime
      2
      3import projectal
      4from projectal.entity import Entity
      5from projectal.linkers import *
      6
      7
      8class Staff(Entity, LocationLinker, ResourceLinker, SkillLinker, FileLinker,
      9            CompanyLinker, DepartmentLinker, TaskLinker, TaskTemplateLinker,
     10            NoteLinker, CalendarLinker, TagLinker):
     11    """
     12    Implementation of the [Staff](https://projectal.com/docs/latest/#tag/Staff) API.
     13    """
     14    _path = 'staff'
     15    _name = 'staff'
     16    _links = [LocationLinker, ResourceLinker, SkillLinker, FileLinker, NoteLinker,
     17              CalendarLinker, TagLinker]
     18    _links_reverse = [CompanyLinker, DepartmentLinker, TaskLinker, TaskTemplateLinker]
     19
     20    @classmethod
     21    def calendar(cls, uuId, begin=None, until=None):
     22        """
     23        Returns the calendar of the staff with `uuId`.
     24
     25        `begin`: Start date in `yyyy-MM-dd`.
     26
     27        `until`: End date in `yyyy-MM-dd`.
     28
     29
     30        Optionally specify a date range. If no range specified, the
     31        minimum and maximum dates are used (see projectal.enums.DateLimit).
     32        """
     33        if begin:
     34            begin = datetime.strptime(begin, '%Y-%m-%d').date()
     35        if until:
     36            until = datetime.strptime(until, '%Y-%m-%d').date()
     37
     38        url = '/api/staff/{}/calendar?'.format(uuId)
     39        params = []
     40        params.append('begin={}'.format(begin)) if begin else None
     41        params.append('until={}'.format(until)) if until else None
     42        url += '&'.join(params)
     43
     44        cals = api.get(url)
     45        cals = [projectal.Calendar(c) for c in cals]
     46        return cals
     47
     48    @classmethod
     49    def calendar_availability(cls, uuId, begin=None, until=None):
     50        """
     51        Returns the availability (in hours) of the staff in `uuId`
     52        for each day within the specified date range.
     53
     54        `begin`: Start date in `yyyy-MM-dd`.
     55
     56        `until`: End date in `yyyy-MM-dd`.
     57
     58        If no range specified, the minimum and maximum dates are
     59        used (see projectal.enums.DateLimit).
     60        """
     61        if begin:
     62            begin = datetime.strptime(begin, '%Y-%m-%d').date()
     63        if until:
     64            until = datetime.strptime(until, '%Y-%m-%d').date()
     65
     66        url = '/api/staff/{}/calendar/availability?'.format(uuId)
     67        params = []
     68        params.append('begin={}'.format(begin)) if begin else None
     69        params.append('until={}'.format(until)) if until else None
     70        url += '&'.join(params)
     71
     72        return api.get(url)
     73
     74    @classmethod
     75    def usage(cls, begin, until, holder=None, start=None, limit=None, span=None,
     76              ksort=None, order=None, staff=None):
     77        """
     78        Returns the staff-to-task allocations for all staff within the `holder`.
     79
     80        See [Usage API](https://projectal.com/docs/latest/#tag/Staff/paths/~1api~1staff~1usage/post)
     81        for full details.
     82        """
     83        url = '/api/staff/usage?begin={}&until={}'.format(begin, until)
     84        params = []
     85        params.append('holder={}'.format(holder)) if holder else None
     86        params.append('start={}'.format(start)) if start else None
     87        params.append('limit={}'.format(limit)) if limit else None
     88        params.append('span={}'.format(span)) if span else None
     89        params.append('ksort={}'.format(ksort)) if ksort else None
     90        params.append('order={}'.format(order)) if order else None
     91        if len(params) > 0:
     92            url += '&' + '&'.join(params)
     93        payload = staff if staff and not holder else None
     94        response = api.post(url, payload)
     95        # Do some extra checks for empty list case
     96        if 'status' in response:
     97            # We didn't have a 'jobCase' key and returned the outer dict.
     98            return []
     99        return response
    100
    101    @classmethod
    102    def auto_assign(cls, type="Recommend", over_allocate_staff=False,
    103                    include_assigned_task=False, include_started_task=False,
    104                    skills=None, tasks=None, staffs=None):
    105        """
    106        Automatically assign a set of staff (real or generic) to a set of tasks
    107        using various skill and allocation criteria.
    108
    109        See [Staff Assign API](https://projectal.com/docs/latest/#tag/Staff-Assign/paths/~1api~1allocation~1staff/post)
    110        for full details.
    111        """
    112        url = '/api/allocation/staff'
    113        payload = {
    114            "type": type,
    115            "overAllocateStaff": over_allocate_staff,
    116            "includeAssignedTask": include_assigned_task,
    117            "includeStartedTask": include_started_task,
    118            "skillMatchList": skills if skills else [],
    119            "staffList": staffs if staffs else [],
    120            "taskList": tasks if tasks else []
    121        }
    122        return api.post(url, payload)

class Staff(projectal.entity.Entity, projectal.linkers.LocationLinker, projectal.linkers.ResourceLinker, projectal.linkers.SkillLinker, projectal.linkers.FileLinker, projectal.linkers.CompanyLinker, projectal.linkers.DepartmentLinker, projectal.linkers.TaskLinker, projectal.linkers.TaskTemplateLinker, projectal.linkers.NoteLinker, projectal.linkers.CalendarLinker, projectal.linkers.TagLinker): View Source

      9class Staff(Entity, LocationLinker, ResourceLinker, SkillLinker, FileLinker,
     10            CompanyLinker, DepartmentLinker, TaskLinker, TaskTemplateLinker,
     11            NoteLinker, CalendarLinker, TagLinker):
     12    """
     13    Implementation of the [Staff](https://projectal.com/docs/latest/#tag/Staff) API.
     14    """
     15    _path = 'staff'
     16    _name = 'staff'
     17    _links = [LocationLinker, ResourceLinker, SkillLinker, FileLinker, NoteLinker,
     18              CalendarLinker, TagLinker]
     19    _links_reverse = [CompanyLinker, DepartmentLinker, TaskLinker, TaskTemplateLinker]
     20
     21    @classmethod
     22    def calendar(cls, uuId, begin=None, until=None):
     23        """
     24        Returns the calendar of the staff with `uuId`.
     25
     26        `begin`: Start date in `yyyy-MM-dd`.
     27
     28        `until`: End date in `yyyy-MM-dd`.
     29
     30
     31        Optionally specify a date range. If no range specified, the
     32        minimum and maximum dates are used (see projectal.enums.DateLimit).
     33        """
     34        if begin:
     35            begin = datetime.strptime(begin, '%Y-%m-%d').date()
     36        if until:
     37            until = datetime.strptime(until, '%Y-%m-%d').date()
     38
     39        url = '/api/staff/{}/calendar?'.format(uuId)
     40        params = []
     41        params.append('begin={}'.format(begin)) if begin else None
     42        params.append('until={}'.format(until)) if until else None
     43        url += '&'.join(params)
     44
     45        cals = api.get(url)
     46        cals = [projectal.Calendar(c) for c in cals]
     47        return cals
     48
     49    @classmethod
     50    def calendar_availability(cls, uuId, begin=None, until=None):
     51        """
     52        Returns the availability (in hours) of the staff in `uuId`
     53        for each day within the specified date range.
     54
     55        `begin`: Start date in `yyyy-MM-dd`.
     56
     57        `until`: End date in `yyyy-MM-dd`.
     58
     59        If no range specified, the minimum and maximum dates are
     60        used (see projectal.enums.DateLimit).
     61        """
     62        if begin:
     63            begin = datetime.strptime(begin, '%Y-%m-%d').date()
     64        if until:
     65            until = datetime.strptime(until, '%Y-%m-%d').date()
     66
     67        url = '/api/staff/{}/calendar/availability?'.format(uuId)
     68        params = []
     69        params.append('begin={}'.format(begin)) if begin else None
     70        params.append('until={}'.format(until)) if until else None
     71        url += '&'.join(params)
     72
     73        return api.get(url)
     74
     75    @classmethod
     76    def usage(cls, begin, until, holder=None, start=None, limit=None, span=None,
     77              ksort=None, order=None, staff=None):
     78        """
     79        Returns the staff-to-task allocations for all staff within the `holder`.
     80
     81        See [Usage API](https://projectal.com/docs/latest/#tag/Staff/paths/~1api~1staff~1usage/post)
     82        for full details.
     83        """
     84        url = '/api/staff/usage?begin={}&until={}'.format(begin, until)
     85        params = []
     86        params.append('holder={}'.format(holder)) if holder else None
     87        params.append('start={}'.format(start)) if start else None
     88        params.append('limit={}'.format(limit)) if limit else None
     89        params.append('span={}'.format(span)) if span else None
     90        params.append('ksort={}'.format(ksort)) if ksort else None
     91        params.append('order={}'.format(order)) if order else None
     92        if len(params) > 0:
     93            url += '&' + '&'.join(params)
     94        payload = staff if staff and not holder else None
     95        response = api.post(url, payload)
     96        # Do some extra checks for empty list case
     97        if 'status' in response:
     98            # We didn't have a 'jobCase' key and returned the outer dict.
     99            return []
    100        return response
    101
    102    @classmethod
    103    def auto_assign(cls, type="Recommend", over_allocate_staff=False,
    104                    include_assigned_task=False, include_started_task=False,
    105                    skills=None, tasks=None, staffs=None):
    106        """
    107        Automatically assign a set of staff (real or generic) to a set of tasks
    108        using various skill and allocation criteria.
    109
    110        See [Staff Assign API](https://projectal.com/docs/latest/#tag/Staff-Assign/paths/~1api~1allocation~1staff/post)
    111        for full details.
    112        """
    113        url = '/api/allocation/staff'
    114        payload = {
    115            "type": type,
    116            "overAllocateStaff": over_allocate_staff,
    117            "includeAssignedTask": include_assigned_task,
    118            "includeStartedTask": include_started_task,
    119            "skillMatchList": skills if skills else [],
    120            "staffList": staffs if staffs else [],
    121            "taskList": tasks if tasks else []
    122        }
    123        return api.post(url, payload)

Implementation of the Staff API.

@classmethod
def calendar(cls, uuId, begin=None, until=None): View Source

    21    @classmethod
    22    def calendar(cls, uuId, begin=None, until=None):
    23        """
    24        Returns the calendar of the staff with `uuId`.
    25
    26        `begin`: Start date in `yyyy-MM-dd`.
    27
    28        `until`: End date in `yyyy-MM-dd`.
    29
    30
    31        Optionally specify a date range. If no range specified, the
    32        minimum and maximum dates are used (see projectal.enums.DateLimit).
    33        """
    34        if begin:
    35            begin = datetime.strptime(begin, '%Y-%m-%d').date()
    36        if until:
    37            until = datetime.strptime(until, '%Y-%m-%d').date()
    38
    39        url = '/api/staff/{}/calendar?'.format(uuId)
    40        params = []
    41        params.append('begin={}'.format(begin)) if begin else None
    42        params.append('until={}'.format(until)) if until else None
    43        url += '&'.join(params)
    44
    45        cals = api.get(url)
    46        cals = [projectal.Calendar(c) for c in cals]
    47        return cals

Returns the calendar of the staff with `uuId`.

`begin`: Start date in `yyyy-MM-dd`.

`until`: End date in `yyyy-MM-dd`.

Optionally specify a date range. If no range specified, the minimum and maximum dates are used (see projectal.enums.DateLimit).

@classmethod
def calendar_availability(cls, uuId, begin=None, until=None): View Source

    49    @classmethod
    50    def calendar_availability(cls, uuId, begin=None, until=None):
    51        """
    52        Returns the availability (in hours) of the staff in `uuId`
    53        for each day within the specified date range.
    54
    55        `begin`: Start date in `yyyy-MM-dd`.
    56
    57        `until`: End date in `yyyy-MM-dd`.
    58
    59        If no range specified, the minimum and maximum dates are
    60        used (see projectal.enums.DateLimit).
    61        """
    62        if begin:
    63            begin = datetime.strptime(begin, '%Y-%m-%d').date()
    64        if until:
    65            until = datetime.strptime(until, '%Y-%m-%d').date()
    66
    67        url = '/api/staff/{}/calendar/availability?'.format(uuId)
    68        params = []
    69        params.append('begin={}'.format(begin)) if begin else None
    70        params.append('until={}'.format(until)) if until else None
    71        url += '&'.join(params)
    72
    73        return api.get(url)

Returns the availability (in hours) of the staff in `uuId` for each day within the specified date range.

`begin`: Start date in `yyyy-MM-dd`.

`until`: End date in `yyyy-MM-dd`.

If no range specified, the minimum and maximum dates are used (see projectal.enums.DateLimit).

@classmethod
def usage( cls, begin, until, holder=None, start=None, limit=None, span=None, ksort=None, order=None, staff=None): View Source

     75    @classmethod
     76    def usage(cls, begin, until, holder=None, start=None, limit=None, span=None,
     77              ksort=None, order=None, staff=None):
     78        """
     79        Returns the staff-to-task allocations for all staff within the `holder`.
     80
     81        See [Usage API](https://projectal.com/docs/latest/#tag/Staff/paths/~1api~1staff~1usage/post)
     82        for full details.
     83        """
     84        url = '/api/staff/usage?begin={}&until={}'.format(begin, until)
     85        params = []
     86        params.append('holder={}'.format(holder)) if holder else None
     87        params.append('start={}'.format(start)) if start else None
     88        params.append('limit={}'.format(limit)) if limit else None
     89        params.append('span={}'.format(span)) if span else None
     90        params.append('ksort={}'.format(ksort)) if ksort else None
     91        params.append('order={}'.format(order)) if order else None
     92        if len(params) > 0:
     93            url += '&' + '&'.join(params)
     94        payload = staff if staff and not holder else None
     95        response = api.post(url, payload)
     96        # Do some extra checks for empty list case
     97        if 'status' in response:
     98            # We didn't have a 'jobCase' key and returned the outer dict.
     99            return []
    100        return response

Returns the staff-to-task allocations for all staff within the `holder`.

See Usage API for full details.

@classmethod
def auto_assign( cls, type='Recommend', over_allocate_staff=False, include_assigned_task=False, include_started_task=False, skills=None, tasks=None, staffs=None): View Source

    102    @classmethod
    103    def auto_assign(cls, type="Recommend", over_allocate_staff=False,
    104                    include_assigned_task=False, include_started_task=False,
    105                    skills=None, tasks=None, staffs=None):
    106        """
    107        Automatically assign a set of staff (real or generic) to a set of tasks
    108        using various skill and allocation criteria.
    109
    110        See [Staff Assign API](https://projectal.com/docs/latest/#tag/Staff-Assign/paths/~1api~1allocation~1staff/post)
    111        for full details.
    112        """
    113        url = '/api/allocation/staff'
    114        payload = {
    115            "type": type,
    116            "overAllocateStaff": over_allocate_staff,
    117            "includeAssignedTask": include_assigned_task,
    118            "includeStartedTask": include_started_task,
    119            "skillMatchList": skills if skills else [],
    120            "staffList": staffs if staffs else [],
    121            "taskList": tasks if tasks else []
    122        }
    123        return api.post(url, payload)

Automatically assign a set of staff (real or generic) to a set of tasks using various skill and allocation criteria.

See Staff Assign API for full details.

##### Inherited Members

projectal.entity.Entity
  get
  update
  delete
  history
  create
  save
  clone
  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.LocationLinker
  link_location
  unlink_location
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.CompanyLinker
  link_company
  unlink_company
projectal.linkers.DepartmentLinker
  link_department
  unlink_department
projectal.linkers.TaskLinker
  link_task
  unlink_task
projectal.linkers.TaskTemplateLinker
  link_task_template
  unlink_task_template
projectal.linkers.TagLinker
  link_tag
  unlink_tag
builtins.dict
  setdefault
  pop
  popitem
  keys
  items
  values
  fromkeys
  clear
  copy