Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 24bb276a authored by fandrem's avatar fandrem
Browse files

David refactor and add comment method

parent 943664b9
No related branches found
No related tags found
No related merge requests found
Showing with 923 additions and 123 deletions
......@@ -37,8 +37,8 @@ sys.path.append(config_global.get('APPLICATION', 'PYTHON-LIBRARY'))
import snet.sloggly
sys.path.append('/opt/auth/library')
import leankit
sys.path.append('/opt/auth/')
import library.leankit as leankit
try:
logger = snet.sloggly.setup_custom_logger(script, logging.INFO)
......@@ -257,15 +257,16 @@ def ec_ldap_get():
def main():
dryrun = False
dryrun = True
# note com is no inside for now
snet_groups = 'officials,mgt,net,pm,sd,sec,sup,tda'.split(',')
snet_groups = 'officials,mgt,net,pm,sd,sec,sup,com,tda'.split(',')
devnull_user = ['geirnal', 'lehonan', 'perreja', 'rotchri']
donotdelete = ['wim.oyen@global.ntt']
donotdelete = ['wim.oyen@global.ntt', 'david.deveen@global.ntt']
extra_leankit_results = list()
'''
extra_leankit_results.append({
'emailAddress': 'dbox1495@gmail.com',
'firstName': 'Daniel',
......@@ -277,7 +278,7 @@ def main():
'firstName': 'Koen',
'lastName': 'Hauwaert'
})
'''
extra_leankit_results_idx = list()
for uu in extra_leankit_results:
......@@ -403,7 +404,7 @@ def main():
continue
if duser['emailAddress'] not in snet_mail_index and duser['emailAddress'].lower() not in snet_mail_index_lc and duser['emailAddress'] not in donotdelete and duser['emailAddress'].lower() not in donotdelete and duser['emailAddress'].lower() not in extra_leankit_results_idx:
print('Leankit user ' + duser['emailAddress'] + ' should be deleted.')
print('Leankit user ' + duser['emailAddress'] + ' should be deleted. Doing nothing for now.')
continue
leankit_account.append(duser['emailAddress'])
......
#!/opt/gvenv/venv_leankit/bin/python3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
......@@ -39,8 +40,8 @@ sys.path.append(config_global.get('APPLICATION', 'PYTHON-LIBRARY'))
from redminelib import Redmine
import snet.sloggly
sys.path.append('/opt/auth/library')
import leankit
sys.path.append('/opt/auth/')
import library.leankit as leankit
try:
logger = snet.sloggly.setup_custom_logger(script, logging.INFO)
......@@ -219,16 +220,12 @@ elif args.leankit_create is True and args.leankit_board is not None:
'''
{'pageMeta': {'totalRecords': 2, 'offset': 0, 'limit': 100, 'startRow': 1, 'endRow': 2}, 'boards': [{'id': '31512088856393', 'title': 'DEV', 'description': '', 'boardRoleId': 4, 'isWelcome': False, 'boardRole': 'boardAdministrator', 'level': {'id': '31512085971730', 'depth': 3, 'maxDepth': 3, 'label': 'Team', 'color': '#ff841f'}}, {'id': '31512088544453', 'title': 'DEV-NMS3-phasein', 'description': '', 'boardRoleId': 4, 'isWelcome': False, 'boardRole': 'boardAdministrator'}]}
'''
found = False
for bb in leankit_res['boards']:
if bb['title'] == args.leankit_board:
found = True
leankit_board_id = bb['id']
if found is False:
if leankit_res is None:
logger.error("Leankit board '%s': id is not found. Check the board name parameter." % args.leankit_board)
sys.exit(1)
leankit_board_id = leankit_res['id']
if args.leankit_create is True:
leankit_res = leankit.get_cardtype_from_board(leankit_board_id)
# print(leankit_res)
......@@ -503,9 +500,13 @@ else:
print(leankit_res)
leankit_id = leankit_card_id
issue = redmine.issue.get(redmine_id)
issue.custom_fields = [{'id': 41, 'value': leankit_card_id}]
issue = redmine.issue.get(int(redmine_id))
# print('redmine_issue:' + str(issue))
issue.custom_fields = [{'id': 41, 'value': leankit_id}]
issue.save()
# print('redmine_issue:' + str(issue.custom_fields))
# print(issue.custom_field.all())
# print(issue.custom_fields.get(41))
print('#Redmine %s' % (redmine_id))
print('#Leankit %s' % (leankit_id))
......
This diff is collapsed.
from __future__ import annotations #ApiObjBase
class ApiObjBase(object):
_data: dict
def __init__(self, data: dict = {}):
""" constructor """
self._data = data
def __iter__(self):
""" add support for json serialization by implementing the __iter__ method"""
for key in self._data:
yield key, self._data[key]
@staticmethod
def decode(obj: dict):
raise NotImplementedError
from library.leankit.models.User import User
from library.leankit.models.ClassOfService import ClassOfService
from library.leankit.models.CardType import CardType
from library.leankit.models.Lane import Lane, LaneType, LaneClassType
from library.leankit.models.Priority import Priority
from library.leankit.models.BoardLevel import BoardLevel
class BoardCustomFieldChoiceConfiguration:
choices: list
def __iter__(self):
yield 'choices', self.choises
class BoardCustomField(object):
id: str # eg. '31512088420962'
index: int # eg. '0'
type: str # eg. 'choice'
label: str # eg. 'PM'
helpText: str # eg. ''
choiceConfiguration: BoardCustomFieldChoiceConfiguration # eg. '{'choices': ['CEUPPENS Olivier (DIGIT-EXT)', 'CHEVALIER Julie (DIGIT-EXT)', 'VANHOUT Chris (DIGIT-EXT)', 'DEDONIS Vytis (DIGIT-EXT)']}'
# support for json serialization by implementing the __iter__ method
def __iter__(self):
yield 'id', self.id
yield 'index', self.index
yield 'type', self.type
yield 'label', self.label
yield 'helpText', self.helpText
yield 'choiceConfiguration', self.choiceConfiguration
class Board(object):
'''
id string The board id
title string The board title
description string The board description
boardRoleId integer The board role id
isWelcome boolean Indicates if the board is a welcome board
boardRole string The string representation of the board role
'''
id: str # eg. '31512088061881'
title: str # eg. 'testing'
description: str # eg. 'Board for Project Managers during the interim period until Planview is ready'
boardRoleId: str # eg. 'boardUser'
isWelcome: bool # eg. 'False'
boardRole: str # eg. 'boardUser'
# support for json serialization by implementing the __iter__ method
def __iter__(self):
yield 'id', self.id
yield 'title', self.title
yield 'description', self.description
yield 'boardRoleId', self.boardRoleId
yield 'isWelcome', self.isWelcome
yield 'boardRole', self.boardRole
def __getitem__(self, key):
return getattr(self, key)
def get_lane_by_name(self, lane_name: str):
return next(lane for lane in self.lanes if lane.name == lane_name)
@staticmethod
def decode(obj: dict):
newBoard = Board()
print(obj)
# {'id': '31512097494387', 'title': 'DEV HLP', 'description': '', 'boardRoleId': 2, 'isWelcome': False, 'boardRole': 'boardUser', 'level': {'id': '31512085971730', 'depth': 3, 'maxDepth': 3, 'label': 'Team', 'color': '#ff841f'}}
newBoard.id = str(obj["id"])
newBoard.title = str(obj["title"])
newBoard.description = str(obj["description"])
newBoard.boardRoleId = str(obj["boardRoleId"])
newBoard.isWelcome = bool(obj["isWelcome"])
newBoard.boardRole = str(obj["boardRole"])
return newBoard
class BoardLevel(object):
id: str # eg. '31512085971730'
depth: int # eg. '3'
maxDepth: int # eg. '3'
label: str # eg. 'Team'
color: str # eg. '#ff841f'
# support for json serialization by implementing the __iter__ method
def __iter__(self):
yield 'id', self.id
yield 'depth', self.depth
yield 'maxDepth', self.maxDepth
yield 'label', self.label
yield 'color', self.color
@staticmethod
def decode(obj: dict):
boardLevel = BoardLevel()
boardLevel.id = str(obj["id"])
boardLevel.depth = int(obj["depth"])
boardLevel.maxDepth = int(obj["maxDepth"])
boardLevel.label = str(obj["label"])
boardLevel.color = str(obj["color"])
return boardLevel
from library.leankit.models.User import User
from library.leankit.models.ClassOfService import ClassOfService
from library.leankit.models.CardType import CardType
from library.leankit.models.Lane import Lane, LaneType, LaneClassType
from library.leankit.models.Priority import Priority
from library.leankit.models.BoardLevel import BoardLevel
class BoardCustomFieldChoiceConfiguration:
choices: list
def __iter__(self):
yield 'choices', self.choises
class BoardCustomField(object):
id: str # eg. '31512088420962'
index: int # eg. '0'
type: str # eg. 'choice'
label: str # eg. 'PM'
helpText: str # eg. ''
choiceConfiguration: BoardCustomFieldChoiceConfiguration # eg. '{'choices': ['CEUPPENS Olivier (DIGIT-EXT)', 'CHEVALIER Julie (DIGIT-EXT)', 'VANHOUT Chris (DIGIT-EXT)', 'DEDONIS Vytis (DIGIT-EXT)']}'
# support for json serialization by implementing the __iter__ method
def __iter__(self):
yield 'id', self.id
yield 'index', self.index
yield 'type', self.type
yield 'label', self.label
yield 'helpText', self.helpText
yield 'choiceConfiguration', self.choiceConfiguration
class Board(object):
users: list # eg. '[{'id': '31512085836488', 'username': 'Olivier.CEUPPENS@ext.ec.europa.eu', 'firstName': 'Olivier', 'lastName': 'CEUPPENS', 'fullName': 'Olivier CEUPPENS', 'emailAddress': 'Olivier.CEUPPENS@ext.ec.europa.eu', 'gravatarLink': None, 'avatar': None, 'lastAccess': '2021-11-09T08:57:39.286Z', 'dateFormat': 'dd/MM/yyyy', 'organizationId': '31512084678944', 'boardId': '31512088061881', 'wip': 0, 'roleTypeId': 5, 'settings': {}, 'boardRoles': []}]'
classesOfService: list # eg. '[{'id': '31512088061890', 'name': 'Date Dependent', 'iconPath': '/customicons/24/212121/lk_icons_final_01-13.png', 'policy': ''}, {'id': '31512088061891', 'name': 'Expedite', 'iconPath': '/customicons/24/e35027/lk_icons_final_01-03.png', 'policy': ''}, {'id': '31512088061892', 'name': 'Regulatory', 'iconPath': '/customicons/24/49bbd6/lk_icons_final_05-11.png', 'policy': ''}, {'id': '31512088061893', 'name': 'Standard', 'iconPath': '/customicons/24/212121/blank_icon.png', 'policy': ''}, {'id': '31512088468643', 'name': 'PM Project Task', 'iconPath': '/customicons/24/e35027/lk_icons_final_18-12.png', 'policy': ''}]'
tags: list # eg. '[['firewall', 'proxy']]'
customFields: list # eg. '[{'id': '31512088420962', 'index': 0, 'type': 'choice', 'label': 'PM', 'helpText': '', 'choiceConfiguration': {'choices': ['CEUPPENS Olivier (DIGIT-EXT)', 'CHEVALIER Julie (DIGIT-EXT)', 'VANHOUT Chris (DIGIT-EXT)', 'DEDONIS Vytis (DIGIT-EXT)']}}, {'id': '31512088421162', 'index': 1, 'type': 'choice', 'label': 'Project Domain', 'helpText': '', 'choiceConfiguration': {'choices': ['Security', 'Network', 'Network Deployments', 'Development', 'Supporting Services', 'Compliance']}}]'
id: str # eg. '31512088061881'
title: str # eg. 'testing'
description: str # eg. 'Board for Project Managers during the interim period until Planview is ready'
creationDate: str # eg. '2021-08-30T15:24:39.296Z'
classOfServiceEnabled: bool # eg. 'True'
customIconFieldLabel: str # eg. 'Class of Service'
organizationId: str # eg. '31512084678944'
version: int # eg. '1176'
cardColorField: int # eg. '1'
isCardIdEnabled: bool # eg. 'True'
isHeaderEnabled: bool # eg. 'True'
isHyperlinkEnabled: bool # eg. 'False'
isPrefixEnabled: bool # eg. 'False'
prefix: None # eg. 'None'
format: None # eg. 'None'
isPrefixIncludedInHyperlink: bool # eg. 'False'
baseWipOnCardSize: bool # eg. 'False'
excludeCompletedAndArchiveViolations: bool # eg. 'False'
isDuplicateCardIdAllowed: bool # eg. 'True'
isAutoIncrementCardIdEnabled: bool # eg. 'False'
currentExternalCardId: str # eg. '0'
isWelcome: bool # eg. 'False'
isShared: bool # eg. 'True'
isArchived: bool # eg. 'False'
sharedBoardRole: str # eg. '2'
customBoardMoniker: None # eg. 'None'
isPermalinkEnabled: bool # eg. 'False'
isExternalUrlEnabled: bool # eg. 'False'
allowUsersToDeleteCards: bool # eg. 'True'
allowPlanviewIntegration: bool # eg. 'True'
subscriptionId: None # eg. 'None'
boardRole: str # eg. 'boardUser'
effectiveBoardRole: str # eg. 'boardUser'
cardTypes: list # eg. '[{'id': '31512088061883', 'name': 'Other Work', 'colorHex': '#FFFFFF', 'isCardType': True, 'isTaskType': False}, {'id': '31512088061884', 'name': 'Defect', 'colorHex': '#F1C7C5', 'isCardType': True, 'isTaskType': False}, {'id': '31512088061885', 'name': 'Documentation', 'colorHex': '#D0CCE0', 'isCardType': True, 'isTaskType': False}, {'id': '31512088061886', 'name': 'Improvement', 'colorHex': '#BFDFC2', 'isCardType': True, 'isTaskType': False}, {'id': '31512088061887', 'name': 'New Feature', 'colorHex': '#B8CFDF', 'isCardType': True, 'isTaskType': False}, {'id': '31512088061888', 'name': 'Risk / Issue', 'colorHex': '#FAD7B2', 'isCardType': True, 'isTaskType': False}, {'id': '31512088061889', 'name': 'Subtask', 'colorHex': '#FFF8DF', 'isCardType': False, 'isTaskType': True}, {'id': '31512088223250', 'name': 'PM Project Task', 'colorHex': '#02FE1F', 'isCardType': True, 'isTaskType': True}, {'id': '31512088468400', 'name': 'PM Project Subtask', 'colorHex': '#FFF1BF', 'isCardType': False, 'isTaskType': True}, {'id': '31512088679692', 'name': 'Project', 'colorHex': '#FFFFFF', 'isCardType': True, 'isTaskType': True}, {'id': '31512088679694', 'name': 'Change', 'colorHex': '#FFFFFF', 'isCardType': True, 'isTaskType': True}, {'id': '31512089937452', 'name': 'NTX Global Project', 'colorHex': '#FFFFFF', 'isCardType': True, 'isTaskType': False}, {'id': '31512089940077', 'name': 'Project Task', 'colorHex': '#FFFFFF', 'isCardType': True, 'isTaskType': True}]'
laneClassTypes: list # eg. '[{'id': 0, 'name': 'active'}, {'id': 1, 'name': 'backlog'}, {'id': 2, 'name': 'archive'}]'
lanes: list # eg. '[{'id': '31512088061894', 'name': 'Not Started - Future Work', 'description': None, 'cardStatus': 'notStarted', 'active': True, 'cardLimit': 0, 'creationDate': '2021-08-30T15:24:39.263Z', 'index': 0, 'parentLaneId': None, 'activityId': None, 'orientation': 'vertical', 'isConnectionDoneLane': False, 'isDefaultDropLane': False, 'columns': 3, 'wipLimit': 0, 'cardCount': 6, 'cardSize': 6, 'archiveCardCount': 0, 'sortBy': None, 'subscriptionId': None, 'laneClassType': 'backlog', 'laneType': 'ready', 'isCollapsed': False}, {'id': '31512088061899', 'name': 'New Requests', 'description': None, 'cardStatus': 'notStarted', 'active': True, 'cardLimit': 0, 'creationDate': '2021-08-30T15:24:39.263Z', 'index': 0, 'parentLaneId': '31512088061894', 'activityId': None, 'orientation': 'vertical', 'isConnectionDoneLane': False, 'isDefaultDropLane': True, 'columns': 1, 'wipLimit': 0, 'cardCount': 6, 'cardSize': 6, 'archiveCardCount': 0, 'sortBy': None, 'subscriptionId': None, 'laneClassType': 'backlog', 'laneType': 'ready', 'isCollapsed': False}, {'id': '31512088066548', 'name': 'Finished As Planned', 'description': None, 'cardStatus': 'finished', 'active': True, 'cardLimit': 0, 'creationDate': '2021-08-30T15:24:39.263Z', 'index': 0, 'parentLaneId': '31512088061895', 'activityId': None, 'orientation': 'horizontal', 'isConnectionDoneLane': False, 'isDefaultDropLane': False, 'columns': 3, 'wipLimit': 0, 'cardCount': 0, 'cardSize': 0, 'archiveCardCount': 0, 'sortBy': None, 'subscriptionId': None, 'laneClassType': 'archive', 'laneType': 'untyped', 'isCollapsed': False}, {'id': '31512088061896', 'name': 'Doing Now', 'description': None, 'cardStatus': 'started', 'active': True, 'cardLimit': 0, 'creationDate': '2021-08-30T15:24:39.263Z', 'index': 1, 'parentLaneId': None, 'activityId': None, 'orientation': 'vertical', 'isConnectionDoneLane': False, 'isDefaultDropLane': False, 'columns': 2, 'wipLimit': 0, 'cardCount': 0, 'cardSize': 0, 'archiveCardCount': 0, 'sortBy': None, 'subscriptionId': None, 'laneClassType': 'active', 'laneType': 'inProcess', 'isCollapsed': False}, {'id': '31512088066547', 'name': 'Started but not Finished', 'description': None, 'cardStatus': 'finished', 'active': True, 'cardLimit': 0, 'creationDate': '2021-08-30T15:24:39.263Z', 'index': 1, 'parentLaneId': '31512088061895', 'activityId': None, 'orientation': 'horizontal', 'isConnectionDoneLane': False, 'isDefaultDropLane': False, 'columns': 3, 'wipLimit': 0, 'cardCount': 0, 'cardSize': 0, 'archiveCardCount': 0, 'sortBy': None, 'subscriptionId': None, 'laneClassType': 'archive', 'laneType': 'untyped', 'isCollapsed': False}, {'id': '31512088061898', 'name': 'Approved', 'description': None, 'cardStatus': 'notStarted', 'active': True, 'cardLimit': 0, 'creationDate': '2021-08-30T15:24:39.263Z', 'index': 2, 'parentLaneId': '31512088061894', 'activityId': None, 'orientation': 'vertical', 'isConnectionDoneLane': False, 'isDefaultDropLane': False, 'columns': 1, 'wipLimit': 0, 'cardCount': 0, 'cardSize': 0, 'archiveCardCount': 0, 'sortBy': None, 'subscriptionId': None, 'laneClassType': 'backlog', 'laneType': 'ready', 'isCollapsed': False}, {'id': '31512088066546', 'name': 'Discarded Requests / Ideas', 'description': None, 'cardStatus': 'finished', 'active': True, 'cardLimit': 0, 'creationDate': '2021-08-30T15:24:39.263Z', 'index': 2, 'parentLaneId': '31512088061895', 'activityId': None, 'orientation': 'horizontal', 'isConnectionDoneLane': False, 'isDefaultDropLane': False, 'columns': 3, 'wipLimit': 0, 'cardCount': 0, 'cardSize': 0, 'archiveCardCount': 0, 'sortBy': None, 'subscriptionId': None, 'laneClassType': 'archive', 'laneType': 'untyped', 'isCollapsed': False}, {'id': '31512088066549', 'name': 'Under Review', 'description': None, 'cardStatus': 'started', 'active': True, 'cardLimit': 0, 'creationDate': '2021-08-30T15:24:39.263Z', 'index': 2, 'parentLaneId': None, 'activityId': None, 'orientation': 'vertical', 'isConnectionDoneLane': False, 'isDefaultDropLane': False, 'columns': 2, 'wipLimit': 0, 'cardCount': 0, 'cardSize': 0, 'archiveCardCount': 0, 'sortBy': None, 'subscriptionId': None, 'laneClassType': 'active', 'laneType': 'inProcess', 'isCollapsed': False}, {'id': '31512088061897', 'name': 'Recently Finished', 'description': None, 'cardStatus': 'finished', 'active': True, 'cardLimit': 0, 'creationDate': '2021-08-30T15:24:39.263Z', 'index': 3, 'parentLaneId': None, 'activityId': None, 'orientation': 'vertical', 'isConnectionDoneLane': True, 'isDefaultDropLane': False, 'columns': 2, 'wipLimit': 0, 'cardCount': 1, 'cardSize': 1, 'archiveCardCount': 0, 'sortBy': None, 'subscriptionId': None, 'laneClassType': 'active', 'laneType': 'completed', 'isCollapsed': False}, {'id': '31512088066550', 'name': 'Ready to Start', 'description': None, 'cardStatus': 'notStarted', 'active': True, 'cardLimit': 0, 'creationDate': '2021-08-30T15:24:39.263Z', 'index': 3, 'parentLaneId': '31512088061894', 'activityId': None, 'orientation': 'vertical', 'isConnectionDoneLane': False, 'isDefaultDropLane': False, 'columns': 1, 'wipLimit': 0, 'cardCount': 0, 'cardSize': 0, 'archiveCardCount': 0, 'sortBy': None, 'subscriptionId': None, 'laneClassType': 'backlog', 'laneType': 'ready', 'isCollapsed': False}, {'id': '31512088061895', 'name': 'Finished - Ready to Archive', 'description': None, 'cardStatus': 'finished', 'active': True, 'cardLimit': 0, 'creationDate': '2021-08-30T15:24:39.263Z', 'index': 4, 'parentLaneId': None, 'activityId': None, 'orientation': 'vertical', 'isConnectionDoneLane': False, 'isDefaultDropLane': False, 'columns': 3, 'wipLimit': 0, 'cardCount': 0, 'cardSize': 0, 'archiveCardCount': 0, 'sortBy': None, 'subscriptionId': None, 'laneClassType': 'archive', 'laneType': 'completed', 'isCollapsed': True}]'
laneTypes: list # eg. '[{'id': 1, 'name': 'ready'}, {'id': 2, 'name': 'inProcess'}, {'id': 3, 'name': 'completed'}, {'id': 99, 'name': 'untyped'}]'
userSettings: dict # eg. '{}'
level: BoardLevel # eg. '{'id': '31512085971730', 'depth': 3, 'maxDepth': 3, 'label': 'Team', 'color': '#ff841f'}'
priorities: list # eg. '[{'id': 3, 'name': 'critical'}, {'id': 2, 'name': 'high'}, {'id': 1, 'name': 'normal'}, {'id': 0, 'name': 'low'}]'
layoutChecksum: str # eg. '4634ab4f64013c1b83ad63f3571c20ba'
defaultCardTypeId: str # eg. '31512088061883'
defaultTaskTypeId: str # eg. '31512088061889'
# support for json serialization by implementing the __iter__ method
def __iter__(self):
yield 'users', self.users
yield 'classesOfService', self.classesOfService
yield 'tags', self.tags
yield 'customFields', self.customFields
yield 'id', self.id
yield 'title', self.title
yield 'description', self.description
yield 'creationDate', self.creationDate
yield 'classOfServiceEnabled', self.classOfServiceEnabled
yield 'customIconFieldLabel', self.customIconFieldLabel
yield 'organizationId', self.organizationId
yield 'version', self.version
yield 'cardColorField', self.cardColorField
yield 'isCardIdEnabled', self.isCardIdEnabled
yield 'isHeaderEnabled', self.isHeaderEnabled
yield 'isHyperlinkEnabled', self.isHyperlinkEnabled
yield 'isPrefixEnabled', self.isPrefixEnabled
yield 'prefix', self.prefix
yield 'format', self.format
yield 'isPrefixIncludedInHyperlink', self.isPrefixIncludedInHyperlink
yield 'baseWipOnCardSize', self.baseWipOnCardSize
yield 'excludeCompletedAndArchiveViolations', self.excludeCompletedAndArchiveViolations
yield 'isDuplicateCardIdAllowed', self.isDuplicateCardIdAllowed
yield 'isAutoIncrementCardIdEnabled', self.isAutoIncrementCardIdEnabled
yield 'currentExternalCardId', self.currentExternalCardId
yield 'isWelcome', self.isWelcome
yield 'isShared', self.isShared
yield 'isArchived', self.isArchived
yield 'sharedBoardRole', self.sharedBoardRole
yield 'customBoardMoniker', self.customBoardMoniker
yield 'isPermalinkEnabled', self.isPermalinkEnabled
yield 'isExternalUrlEnabled', self.isExternalUrlEnabled
yield 'allowUsersToDeleteCards', self.allowUsersToDeleteCards
yield 'allowPlanviewIntegration', self.allowPlanviewIntegration
yield 'subscriptionId', self.subscriptionId
yield 'boardRole', self.boardRole
yield 'effectiveBoardRole', self.effectiveBoardRole
yield 'cardTypes', self.cardTypes
yield 'laneClassTypes', self.laneClassTypes
yield 'lanes', self.lanes
yield 'laneTypes', self.laneTypes
yield 'userSettings', self.userSettings
yield 'level', self.level
yield 'priorities', self.priorities
yield 'layoutChecksum', self.layoutChecksum
yield 'defaultCardTypeId', self.defaultCardTypeId
yield 'defaultTaskTypeId', self.defaultTaskTypeId
def get_lane_by_name(self, lane_name: str):
return next(lane for lane in self.lanes if lane.name == lane_name)
@staticmethod
def decode(obj: dict):
newBoard = Board()
print(obj)
# {'id': '31512097494387', 'title': 'DEV HLP', 'description': '', 'boardRoleId': 2, 'isWelcome': False, 'boardRole': 'boardUser', 'level': {'id': '31512085971730', 'depth': 3, 'maxDepth': 3, 'label': 'Team', 'color': '#ff841f'}}
if 'users' in obj:
newBoard.users = list(map(lambda user: User.decode(user), obj['users']))
if 'classesOfService' in obj:
newBoard.classesOfService = list(map(lambda classOfService: ClassOfService.decode(classOfService), obj['classesOfService']))
if 'tags' in obj:
newBoard.tags = obj["tags"] # a list of strings
if 'customFields' in obj:
newBoard.customFields = list(map(lambda customField: BoardCustomField.decode(customField), obj['customFields']))
if 'id' in obj:
newBoard.id = str(obj["id"])
if 'title' in obj:
newBoard.title = str(obj["title"])
if 'description' in obj:
newBoard.description = str(obj["description"])
newBoard.creationDate = str(obj["creationDate"])
newBoard.classOfServiceEnabled = bool(obj["classOfServiceEnabled"])
newBoard.customIconFieldLabel = str(obj["customIconFieldLabel"])
newBoard.organizationId = str(obj["organizationId"])
newBoard.version = int(obj["version"])
newBoard.cardColorField = int(obj["cardColorField"])
newBoard.isCardIdEnabled = bool(obj["isCardIdEnabled"])
newBoard.isHeaderEnabled = bool(obj["isHeaderEnabled"])
newBoard.isHyperlinkEnabled = bool(obj["isHyperlinkEnabled"])
newBoard.isPrefixEnabled = bool(obj["isPrefixEnabled"])
newBoard.prefix = obj["prefix"]
newBoard.format = obj["format"]
newBoard.isPrefixIncludedInHyperlink = bool(obj["isPrefixIncludedInHyperlink"])
newBoard.baseWipOnCardSize = bool(obj["baseWipOnCardSize"])
newBoard.excludeCompletedAndArchiveViolations = bool(obj["excludeCompletedAndArchiveViolations"])
newBoard.isDuplicateCardIdAllowed = bool(obj["isDuplicateCardIdAllowed"])
newBoard.isAutoIncrementCardIdEnabled = bool(obj["isAutoIncrementCardIdEnabled"])
newBoard.currentExternalCardId = str(obj["currentExternalCardId"])
newBoard.isWelcome = bool(obj["isWelcome"])
newBoard.isShared = bool(obj["isShared"])
newBoard.isArchived = bool(obj["isArchived"])
newBoard.sharedBoardRole = str(obj["sharedBoardRole"])
newBoard.customBoardMoniker = obj["customBoardMoniker"]
newBoard.isPermalinkEnabled = bool(obj["isPermalinkEnabled"])
newBoard.isExternalUrlEnabled = bool(obj["isExternalUrlEnabled"])
newBoard.allowUsersToDeleteCards = bool(obj["allowUsersToDeleteCards"])
newBoard.allowPlanviewIntegration = bool(obj["allowPlanviewIntegration"])
newBoard.subscriptionId = str(obj["subscriptionId"])
newBoard.boardRole = str(obj["boardRole"])
newBoard.effectiveBoardRole = str(obj["effectiveBoardRole"])
newBoard.cardTypes = list(map(lambda cardType: CardType.decode(cardType), obj['cardTypes']))
# todo, continue conversion from here
newBoard.laneClassTypes = list[laneClassTypes_class](obj["laneClassTypes"])
newBoard.lanes = list[lanes_class](obj["lanes"])
newBoard.laneTypes = list[laneTypes_class](obj["laneTypes"])
newBoard.userSettings = dict(obj["userSettings"])
newBoard.level = dict(obj["level"])
newBoard.priorities = list[priorities_class](obj["priorities"])
newBoard.layoutChecksum = str(obj["layoutChecksum"])
newBoard.defaultCardTypeId = str(obj["defaultCardTypeId"])
newBoard.defaultTaskTypeId = str(obj["defaultTaskTypeId"])
return newBoard
from multipledispatch import dispatch
# from library.leankit.models.User import User
class CardConnection():
parents: list
children: list
def __iter__(self):
yield 'parents', self.parents
yield 'children', self.children
class CardExternalLink():
label: str
url: str
def __iter__(self):
yield 'label', self.label
yield 'url', self.url
class CardCustomField(object):
fieldId: str
value: str
def __iter__(self):
yield 'fieldId', self.fieldId
yield 'value', self.value
class Card(object):
boardId: str
title: str
typeId: str
assignedUserIds: list
description: str
size: int
laneId: str
connections: dict
mirrorSourceCardId: str
copiedFromCardId: str
blockReason: str
priority: str
customIconId: str
customId: str
externalLink: list
index: int
plannedStart: str
plannedFinish: str
tags: list
wipOverrideComment: str
customFields: list
@dispatch()
def __init__(self):
"""parameterless constructor for json deserialization support"""
pass
@dispatch(str, str)
def __init__(self, boardId: str, title: str):
self.boardId = boardId
self.title = title
def __iter__(self):
for attr_name in dir(self):
if not attr_name.startswith("__"):
print(attr_name)
yield attr_name, getattr(self, attr_name)
# @dispatch(User)
# def assign_user(self, user: User):
# self.assign_user(user.id)
@dispatch(str)
def assign_user(self, userid: str):
if userid not in self.assignedUserIds:
self.assignedUserIds.append(userid)
# @dispatch(User)
# def unassign_user(self, user: User):
# self.unassign_user(user.id)
@dispatch(str)
def unassign_user(self, userid: str):
if userid in self.assignedUserIds:
self.assignedUserIds.remove(userid)
# def card_decoder(obj):
# if 'boardId' in obj and 'title' in obj:
# new_card = Card(obj['boardId'], obj['title'])
# if 'typeId' in obj:
# new_card['typeId'] = obj['typeId']
#
# if 'assignedUserIds' in obj:
# new_card['assignedUserIds'] = obj['assignedUserIds']
#
# # TODO set others, or generate using inspection/reflection
# return new_card
# return obj
# cardObj = json.loads('{"__type__": "Card", "rollNumber":1, "name": "Ault kelly", "marks": 78}', object_hook=studentDecoder)
# {
# "boardId": "944576308",
# "title": "The title of the card",
# "typeId": "944576314",
# "assignedUserIds": [ "478440842" ],
# "description": "The card description",
# "size": 1,
# "laneId": "944576326",
# "connections": {
# "parents": ["945202295"],
# "children": ["945250930"]
# },
# "mirrorSourceCardId": "945202295",
# "copiedFromCardId": "945261794",
# "blockReason": "The block reason",
# "priority": "normal",
# "customIconId": "944576317",
# "customId": "Card header text",
# "externalLink": {
# "label": "The link label",
# "url": "https://www.leankit.com"
# },
# "index": 1,
# "plannedStart": "2020-01-20",
# "plannedFinish": "2020-02-01",
# "tags": [
# "tagOne",
# "tagTwo"
# ],
# "wipOverrideComment": "The override reason",
# "customFields": [ {
# "fieldId": "945250752",
# "value": "This is the field value"
# } ]
# }
class CardType(object):
id: str # eg. '31512088061883'
name: str # eg. 'Other Work'
colorHex: str # eg. '#FFFFFF'
isCardType: bool # eg. 'True'
isTaskType: bool # eg. 'False'
# support for json serialization by implementing the __iter__ method
def __iter__(self):
yield 'id', self.id
yield 'name', self.name
yield 'colorHex', self.colorHex
yield 'isCardType', self.isCardType
yield 'isTaskType', self.isTaskType
class ClassOfService(object):
id: str # eg. '31512088061890'
name: str # eg. 'Date Dependent'
iconPath: str # eg. '/customicons/24/212121/lk_icons_final_01-13.png'
policy: str # eg. ''
# support for json serialization by implementing the __iter__ method
def __iter__(self):
yield 'id', self.id
yield 'name', self.name
yield 'iconPath', self.iconPath
yield 'policy', self.policy
class LaneClassType(object):
id: int # eg. '0'
name: str # eg. 'active'
# support for json serialization by implementing the __iter__ method
def __iter__(self):
yield 'id', self.id
yield 'name', self.name
class LaneType(object):
id: int # eg. '1'
name: str # eg. 'ready'
# support for json serialization by implementing the __iter__ method
def __iter__(self):
yield 'id', self.id
yield 'name', self.name
class Lane(object):
id: str # eg. '31512088061894'
name: str # eg. 'Not Started - Future Work'
description: None # eg. 'None'
cardStatus: str # eg. 'notStarted'
active: bool # eg. 'True'
cardLimit: int # eg. '0'
creationDate: str # eg. '2021-08-30T15:24:39.263Z'
index: int # eg. '0'
parentLaneId: None # eg. 'None'
activityId: None # eg. 'None'
orientation: str # eg. 'vertical'
isConnectionDoneLane: bool # eg. 'False'
isDefaultDropLane: bool # eg. 'False'
columns: int # eg. '3'
wipLimit: int # eg. '0'
cardCount: int # eg. '6'
cardSize: int # eg. '6'
archiveCardCount: int # eg. '0'
sortBy: None # eg. 'None'
subscriptionId: None # eg. 'None'
laneClassType: str # eg. 'backlog'
laneType: str # eg. 'ready'
isCollapsed: bool # eg. 'False'
# support for json serialization by implementing the __iter__ method
def __iter__(self):
yield 'id', self.id
yield 'name', self.name
yield 'description', self.description
yield 'cardStatus', self.cardStatus
yield 'active', self.active
yield 'cardLimit', self.cardLimit
yield 'creationDate', self.creationDate
yield 'index', self.index
yield 'parentLaneId', self.parentLaneId
yield 'activityId', self.activityId
yield 'orientation', self.orientation
yield 'isConnectionDoneLane', self.isConnectionDoneLane
yield 'isDefaultDropLane', self.isDefaultDropLane
yield 'columns', self.columns
yield 'wipLimit', self.wipLimit
yield 'cardCount', self.cardCount
yield 'cardSize', self.cardSize
yield 'archiveCardCount', self.archiveCardCount
yield 'sortBy', self.sortBy
yield 'subscriptionId', self.subscriptionId
yield 'laneClassType', self.laneClassType
yield 'laneType', self.laneType
yield 'isCollapsed', self.isCollapsed
from library.leankit.models.BoardLevel import BoardLevel
from library.leankit.models.Card import Card
from library.leankit.models.Board import Board
class PageMeta:
totalRecords: int
offset: int
limit: int
startRow: int
endRow: int
def __getitem__(self, key):
return getattr(self, key)
@staticmethod
def decode(obj: dict):
newPageMeta = PageMeta()
newPageMeta.totalRecords = int(obj["totalRecords"])
newPageMeta.offset = int(obj["offset"])
newPageMeta.limit = int(obj["limit"])
newPageMeta.startRow = int(obj["startRow"])
newPageMeta.endRow = int(obj["endRow"])
return newPageMeta
class BoardRef:
id: str # eg. '31512088856393'
title: str # eg. 'DEV'
description: str # eg. ''
boardRoleId: int # eg. 2
isWelcome: bool # eg. False
boardRole: str # eg. 'boardUser'
level: BoardLevel # eg. '{'id': '31512085971730', 'depth': 3, 'maxDepth': 3, 'label': 'Team', 'color': '#ff841f'}'
# support for json serialization by implementing the __iter__ method
def __iter__(self):
yield 'id', self.id
yield 'title', self.title
yield 'description', self.description
yield 'boardRoleId', self.boardRoleId
yield 'isWelcome', self.isWelcome
yield 'boardRole', self.boardRole
yield 'level', self.level
def __getitem__(self, key):
return getattr(self, key)
@staticmethod
def decode(obj: dict):
newBoardRef = BoardRef()
newBoardRef.id = str(obj["id"])
newBoardRef.title = str(obj["title"])
newBoardRef.description = str(obj["description"])
newBoardRef.boardRoleId = int(obj["boardRoleId"])
newBoardRef.isWelcome = bool(obj["isWelcome"])
newBoardRef.boardRole = str(obj["boardRole"])
newBoardRef.level = BoardLevel.decode(obj["level"])
return newBoardRef
class BoardListResponse:
pageMeta: PageMeta
boards: list
# support for json serialization by implementing the __iter__ method
def __iter__(self):
yield 'pageMeta', self.pageMeta
yield 'boards', self.boards
def __getitem__(self, key):
return getattr(self, key)
@staticmethod
def decode(obj: dict):
newListResponse = BoardListResponse()
newListResponse.pageMeta = PageMeta.decode(obj['pageMeta'])
print(newListResponse.pageMeta)
newListResponse.boards = list(map(lambda board: Board.decode(board), obj['boards']))
return newListResponse
class CardListResponse:
pageMeta: PageMeta
cards: list
def __getitem__(self, key):
return getattr(self, key)
# support for json serialization by implementing the __iter__ method
def __iter__(self):
yield 'pageMeta', self.pageMeta
yield 'cards', self.cards
class Priority(object):
id: int # eg. '3'
name: str # eg. 'critical'
# support for json serialization by implementing the __iter__ method
def __iter__(self):
yield 'id', self.id
yield 'name', self.name
class User(object):
id: str # eg. '31512085836488'
username: str # eg. 'Olivier.CEUPPENS@ext.ec.europa.eu'
firstName: str # eg. 'Olivier'
lastName: str # eg. 'CEUPPENS'
fullName: str # eg. 'Olivier CEUPPENS'
emailAddress: str # eg. 'Olivier.CEUPPENS@ext.ec.europa.eu'
gravatarLink: None # eg. 'None'
avatar: None # eg. 'None'
lastAccess: str # eg. '2021-11-09T08:57:39.286Z'
dateFormat: str # eg. 'dd/MM/yyyy'
organizationId: str # eg. '31512084678944'
boardId: str # eg. '31512088061881'
wip: int # eg. '0'
roleTypeId: int # eg. '5'
settings: dict # eg. '{}'
boardRoles: list # eg. '[]'
# support for json serialization by implementing the __iter__ method
def __iter__(self):
yield 'id', self.id
yield 'username', self.username
yield 'firstName', self.firstName
yield 'lastName', self.lastName
yield 'fullName', self.fullName
yield 'emailAddress', self.emailAddress
yield 'gravatarLink', self.gravatarLink
yield 'avatar', self.avatar
yield 'lastAccess', self.lastAccess
yield 'dateFormat', self.dateFormat
yield 'organizationId', self.organizationId
yield 'boardId', self.boardId
yield 'wip', self.wip
yield 'roleTypeId', self.roleTypeId
yield 'settings', self.settings
yield 'boardRoles', self.boardRoles
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment