Skip to content

Commit 2144a1f

Browse files
committed
PYAPI-27 Portfolio: Cleanup in API
1 parent 4d183fc commit 2144a1f

File tree

3 files changed

+44
-28
lines changed

3 files changed

+44
-28
lines changed

PKG-INFO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 1.1
22
Name: atlassian-python-api
3-
Version: 0.7.11
3+
Version: 0.8.1
44
Author: Matt Harasymczuk
55
Author-email: code at mattagile com
66
Maintainer: Matt Harasymczuk

atlassian/portfolio.py

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,62 @@
77

88
class Portfolio(AtlassianRestAPI):
99

10-
def plan(self, plan_id):
11-
return self.get('/rest/roadmap/1.0/plans/{0}.json'.format(plan_id))
10+
def __init__(self, plan_id, *args, **kwargs):
11+
self.plan_id = plan_id
12+
super(Portfolio, self).__init__(*args, **kwargs)
1213

13-
def stages(self, plan_id):
14-
return self.get('/rest/roadmap/1.0/plans/{0}/stages.json'.format(plan_id))
14+
def get_epic(self, epic):
15+
key = [x.get('link', None) for x in epic.get('links', [])]
16+
estimates = self.estimates_dict(epic['estimates'])
17+
estimates.update(Total=sum(estimates.values()))
18+
return {
19+
'title': epic.get('title', None),
20+
'team': self.team_name(epic.get('teamId')) if epic.get('teamId', None) else None,
21+
'description': epic.get('description', None),
22+
'issuekey': key[0] if key else None,
23+
'estimates': estimates}
1524

16-
def teams(self, plan_id):
17-
return self.get('/rest/roadmap/1.0/plans/{0}/teams.json'.format(plan_id))
25+
def plan(self):
26+
return self.get('/rest/roadmap/1.0/plans/{0}.json'.format(self.plan_id))
1827

19-
def team_name(self, plan_id, team_id):
20-
return [team['title'] for team in self.teams(team_id)['collection'] if team['id'] == str(team_id)][0]
28+
def stages(self):
29+
return self.get('/rest/roadmap/1.0/plans/{0}/stages.json'.format(self.plan_id))
2130

22-
def config(self, plan_id):
23-
return self.get('/rest/roadmap/1.0/plans/{0}/config.json'.format(plan_id))
31+
def teams(self):
32+
return self.get('/rest/roadmap/1.0/plans/{0}/teams.json'.format(self.plan_id))
2433

25-
def persons(self, plan_id):
26-
return self.get('/rest/roadmap/1.0/plans/{0}/persons.json'.format(plan_id))
34+
def team_name(self, team_id):
35+
return [team['title'] for team in self.teams()['collection'] if team['id'] == str(team_id)][0]
2736

28-
def streams(self, plan_id):
29-
return self.get('/rest/roadmap/1.0/plans/{0}/streams.json'.format(plan_id))
37+
def config(self):
38+
return self.get('/rest/roadmap/1.0/plans/{0}/config.json'.format(self.plan_id))
3039

31-
def releases(self, plan_id):
32-
return self.streams(plan_id)
40+
def persons(self):
41+
return self.get('/rest/roadmap/1.0/plans/{0}/persons.json'.format(self.plan_id))
3342

34-
def themes(self, plan_id):
35-
return self.get('/rest/roadmap/1.0/plans/{0}/themes.json'.format(plan_id))
43+
def streams(self):
44+
return self.get('/rest/roadmap/1.0/plans/{0}/streams.json'.format(self.plan_id))
3645

37-
def state(self, plan_id, plan_version):
38-
return self.get('/rest/roadmap/1.0/scheduling/{0}/state.json?planVersion={1}'.format(plan_id, plan_version))
46+
def releases(self):
47+
return self.streams()
3948

40-
def filter(self, plan_id, plan_version, limit=500):
41-
url = '/rest/roadmap/1.0/plans/{0}/workitems/filter.json?planVersion={1}'.format(plan_id, plan_version)
49+
def themes(self):
50+
return self.get('/rest/roadmap/1.0/plans/{0}/themes.json'.format(self.plan_id))
51+
52+
def state(self, plan_version):
53+
return self.get('/rest/roadmap/1.0/scheduling/{0}/state.json?planVersion={1}'.format(self.plan_id,
54+
plan_version))
55+
56+
def filter(self, plan_version, limit=500):
57+
url = '/rest/roadmap/1.0/plans/{0}/workitems/filter.json?planVersion={1}'.format(self.plan_id, plan_version)
4258
return self.post(url, data={'limit': limit})
4359

4460
def dependencies(self, workitem_id, plan_version):
4561
url = '/rest/roadmap/1.0/workitems/{0}/dependencies.json?planVersion={1}'.format(workitem_id, plan_version)
4662
return self.get(url)
4763

48-
def stage_name(self, plan_id, stage_id):
49-
return [stage['title'] for stage in self.stages(plan_id)['collection'] if stage['id'] == str(stage_id)][0]
64+
def stage_name(self, stage_id):
65+
return [stage['title'] for stage in self.stages()['collection'] if stage['id'] == str(stage_id)][0]
5066

51-
def estimates_dict(self, plan_id, estimates):
52-
return {self.stage_name(plan_id, stage['targetId']): stage['value'] for stage in estimates['stages']}
67+
def estimates_dict(self, estimates):
68+
return {self.stage_name(stage['targetId']): stage['value'] for stage in estimates['stages']}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
name='atlassian-python-api',
99
description='Atlassian Python API',
1010
license='Apache License 2.0',
11-
version='0.7.11',
11+
version='0.8.1',
1212
download_url='https://github.com/MattAgile/atlassian-python-api',
1313

1414
author='Matt Harasymczuk',

0 commit comments

Comments
 (0)