Skip to content

Commit 3820176

Browse files
author
Gonchik Tsymzhitov
committed
Jira: add create project method
1 parent 5dfb05a commit 3820176

File tree

2 files changed

+57
-17
lines changed

2 files changed

+57
-17
lines changed

atlassian/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.17.0
1+
1.17.1

atlassian/jira.py

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -970,17 +970,6 @@ def get_issue_transitions_full(self, issue_key, transition_id=None, expand=None)
970970
params['expand'] = expand
971971
return self.get(url, params=params)
972972

973-
def get_server_info(self, do_health_check=False):
974-
"""
975-
Returns general information about the current Jira server.
976-
with health checks or not.
977-
"""
978-
if do_health_check:
979-
check = True
980-
else:
981-
check = False
982-
return self.get('rest/api/2/serverInfo', params={"doHealthCheck": check})
983-
984973
#######################################################################################################
985974
# User
986975
# Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/user
@@ -1230,6 +1219,13 @@ def add_user_to_application(self, username, application_key):
12301219
}
12311220
return self.post('rest/api/2/user/application', params=params) is None
12321221

1222+
#######################################################################################################
1223+
# Projects
1224+
# Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/project
1225+
#######################################################################################################
1226+
def get_all_projects(self, included_archived=None):
1227+
return self.projects(included_archived)
1228+
12331229
def projects(self, included_archived=None):
12341230
"""Returns all projects which are visible for the currently logged in user.
12351231
If no user is logged in, it returns the list of projects that are visible when using anonymous access.
@@ -1241,11 +1237,28 @@ def projects(self, included_archived=None):
12411237
params['includeArchived'] = included_archived
12421238
return self.get('rest/api/2/project')
12431239

1244-
def get_all_projects(self, included_archived=None):
1245-
return self.projects(included_archived)
1246-
1247-
def project(self, key):
1248-
return self.get('rest/api/2/project/{0}'.format(key))
1240+
def create_project_from_raw_json(self, json):
1241+
"""
1242+
Creates a new project.
1243+
{
1244+
"key": "EX",
1245+
"name": "Example",
1246+
"projectTypeKey": "business",
1247+
"projectTemplateKey": "com.atlassian.jira-core-project-templates:jira-core-project-management",
1248+
"description": "Example Project description",
1249+
"lead": "Charlie",
1250+
"url": "http://atlassian.com",
1251+
"assigneeType": "PROJECT_LEAD",
1252+
"avatarId": 10200,
1253+
"issueSecurityScheme": 10001,
1254+
"permissionScheme": 10011,
1255+
"notificationScheme": 10021,
1256+
"categoryId": 10120
1257+
}
1258+
:param json:
1259+
:return:
1260+
"""
1261+
return self.post(json=json)
12491262

12501263
def delete_project(self, key):
12511264
"""
@@ -1255,6 +1268,22 @@ def delete_project(self, key):
12551268
"""
12561269
return self.delete('rest/api/2/project/{0}'.format(key))
12571270

1271+
def project(self, key, expand=None):
1272+
params = {}
1273+
if expand:
1274+
params['expand'] = expand
1275+
return self.get('rest/api/2/project/{0}'.format(key), params=params)
1276+
1277+
def get_project(self, key, expand):
1278+
"""
1279+
Contains a full representation of a project in JSON format.
1280+
All project keys associated with the project will only be returned if expand=projectKeys.
1281+
:param key:
1282+
:param expand:
1283+
:return:
1284+
"""
1285+
return self.project(key=key, expand=expand)
1286+
12581287
def get_project_components(self, key):
12591288
"""
12601289
Get project components using project key
@@ -2178,6 +2207,17 @@ def reindex_project(self, project_key):
21782207
def reindex_issue(self, list_of_):
21792208
pass
21802209

2210+
def get_server_info(self, do_health_check=False):
2211+
"""
2212+
Returns general information about the current Jira server.
2213+
with health checks or not.
2214+
"""
2215+
if do_health_check:
2216+
check = True
2217+
else:
2218+
check = False
2219+
return self.get('rest/api/2/serverInfo', params={"doHealthCheck": check})
2220+
21812221
#######################################################################
21822222
# Tempo Account REST API implements
21832223
#######################################################################

0 commit comments

Comments
 (0)