Skip to content

Commit 016e0e7

Browse files
committed
PYAPI-30 Portfolio: API Cleanup
1 parent 2a77f06 commit 016e0e7

File tree

3 files changed

+41
-59
lines changed

3 files changed

+41
-59
lines changed

PKG-INFO

Lines changed: 0 additions & 27 deletions
This file was deleted.

atlassian/portfolio.py

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,62 +13,79 @@ def __init__(self, plan_id, *args, **kwargs):
1313

1414
def get_epic(self, epic):
1515
key = [x.get('link', None) for x in epic.get('links', [])]
16-
estimates = self.estimates_dict(epic['estimates'])
16+
estimates = self.get_estimates_dict(epic['estimates'])
1717
estimates.update(Total=sum(estimates.values()))
18+
team_id = epic.get('teamId', None)
1819
return {
1920
'title': epic.get('title', None),
20-
'team': self.team_name(epic.get('teamId')) if epic.get('teamId', None) else None,
21+
'team': self.get_team_name(team_id) if team_id else None,
2122
'description': epic.get('description', None),
2223
'issuekey': key[0] if key else None,
2324
'estimates': estimates}
2425

25-
def plan(self):
26+
def get_plan(self):
2627
url = '/rest/roadmap/1.0/plans/{0}.json'.format(self.plan_id)
2728
return self.get(url)
2829

29-
def stages(self):
30+
def get_stages(self):
3031
url = '/rest/roadmap/1.0/plans/{0}/stages.json'.format(self.plan_id)
3132
return self.get(url)
3233

33-
def teams(self):
34+
def get_teams(self):
3435
url = '/rest/roadmap/1.0/plans/{0}/teams.json'.format(self.plan_id)
3536
return self.get(url)
3637

37-
def team_name(self, team_id):
38-
return [team['title'] for team in self.teams()['collection'] if team['id'] == str(team_id)][0]
38+
def get_team_name(self, team_id):
39+
all_teams = self.get_teams()['collection']
40+
return [team['title'] for team in all_teams if team['id'] == str(team_id)][0]
3941

40-
def config(self):
42+
def get_config(self):
4143
url = '/rest/roadmap/1.0/plans/{0}/config.json'.format(self.plan_id)
4244
return self.get(url)
4345

44-
def persons(self):
46+
def get_persons(self):
4547
url = '/rest/roadmap/1.0/plans/{0}/persons.json'.format(self.plan_id)
4648
return self.get(url)
4749

48-
def streams(self):
50+
def get_streams(self):
4951
url = '/rest/roadmap/1.0/plans/{0}/streams.json'.format(self.plan_id)
5052
return self.get(url)
5153

52-
def releases(self):
53-
return self.streams()
54+
def get_releases(self):
55+
return self.get_streams()
5456

55-
def themes(self):
57+
def get_themes(self):
5658
url = '/rest/roadmap/1.0/plans/{0}/themes.json'.format(self.plan_id)
5759
return self.get(url)
5860

59-
def state(self, plan_version):
60-
url = '/rest/roadmap/1.0/scheduling/{0}/state.json?planVersion={1}'.format(self.plan_id, plan_version)
61+
def get_state(self):
62+
url = '/rest/roadmap/1.0/scheduling/{0}/state.json'.format(self.plan_id)
6163
return self.get(url)
6264

63-
def filter(self, plan_version, limit=500):
64-
url = '/rest/roadmap/1.0/plans/{0}/workitems/filter.json?planVersion={1}'.format(self.plan_id, plan_version)
65+
def get_filter(self, limit=500):
66+
url = '/rest/roadmap/1.0/plans/{0}/workitems/filter.json'.format(self.plan_id)
6567
return self.post(url, data={'limit': limit})
6668

67-
def filters(self, query_string):
69+
def get_filters(self, query_string):
6870
url = '/rest/roadmap/1.0/system/filters.json?queryString={0}'.format(query_string)
6971
return self.get(url)
7072

71-
def import_issues(self, jql, limit=100, exclude_linked=True, estimation_method='estimates', epic_fetch_enabled=True,
73+
def get_dependencies(self, workitem_id, plan_version):
74+
url = '/rest/roadmap/1.0/workitems/{0}/dependencies.json?planVersion={1}'.format(workitem_id, plan_version)
75+
return self.get(url)
76+
77+
def get_stage_name(self, stage_id):
78+
all_stages = self.get_stages()['collection']
79+
return [stage['title'] for stage in all_stages if stage['id'] == str(stage_id)][0]
80+
81+
def get_estimates_dict(self, estimates):
82+
return {self.get_stage_name(stage['targetId']): stage['value'] for stage in estimates['stages']}
83+
84+
def import_workitem(self, data):
85+
url = '/rest/roadmap/1.0/plans/bulk/{0}/workitems.json'.format(self.plan_id)
86+
return self.post(url, data)
87+
88+
def get_jql_issues(self, jql, limit=500, exclude_linked=True, estimation_method='estimates', epic_fetch_enabled=True,
7289
load_story_points=True):
7390
url = '/rest/roadmap/1.0/system/import.json'
7491
data = {'planId': str(self.plan_id),
@@ -78,14 +95,4 @@ def import_issues(self, jql, limit=100, exclude_linked=True, estimation_method='
7895
'maxResults': limit,
7996
'estimationMethod': estimation_method,
8097
'loadStoryPoints': load_story_points}
81-
self.post(url, data=data)
82-
83-
def dependencies(self, workitem_id, plan_version):
84-
url = '/rest/roadmap/1.0/workitems/{0}/dependencies.json?planVersion={1}'.format(workitem_id, plan_version)
85-
return self.get(url)
86-
87-
def stage_name(self, stage_id):
88-
return [stage['title'] for stage in self.stages()['collection'] if stage['id'] == str(stage_id)][0]
89-
90-
def estimates_dict(self, estimates):
91-
return {self.stage_name(stage['targetId']): stage['value'] for stage in estimates['stages']}
98+
self.post(url, data=data)

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66

77
setup(
88
name='atlassian-python-api',
9-
description='Atlassian Python API',
9+
description='Python Atlassian REST API Wrapper',
10+
long_description='Python Atlassian REST API Wrapper',
1011
license='Apache License 2.0',
11-
version='0.8.5',
12+
version='0.9.0',
1213
download_url='https://github.com/MattAgile/atlassian-python-api',
1314

1415
author='Matt Harasymczuk',
@@ -22,6 +23,7 @@
2223

2324
zip_safe=False,
2425
install_requires=['requests==2.5.3'],
26+
platforms='Platform Independent',
2527

2628
classifiers=[
2729
'Development Status :: 4 - Beta',

0 commit comments

Comments
 (0)