-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJira_get_started.py
More file actions
61 lines (57 loc) · 1.56 KB
/
Jira_get_started.py
File metadata and controls
61 lines (57 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# This code sample uses the 'requests' library:
# http://docs.python-requests.org
import requests
from requests.auth import HTTPBasicAuth
import json
base_url = "https://abesit-ipm.atlassian.net"
auth = HTTPBasicAuth("tarunagarwal27.99@gmail.com", "tl4F0d5aapRqiR7BfGkiBBDD")
all_projects = list()
all_users = list()
def getAllProjects():
url = "/rest/api/2/project/search"
api = base_url+url
headers = {
"Accept": "application/json"
}
response = requests.request(
"GET",
api,
headers=headers,
auth=auth
)
result = json.loads(response.text)
result = result['values']
total_projects = len(result)
for ctr in range(total_projects):
details = dict()
details['projectId'] = result[ctr]['id']
details['projectKey'] = result[ctr]['key']
details['projectName'] = result[ctr]['name']
all_projects.append(details)
return all_projects
def getAllUsers():
url = '/rest/api/2/users/search'
api = base_url+url
headers = {
"Accept": "application/json"
}
response = requests.request(
"GET",
api,
headers=headers,
auth=auth
)
result = json.loads(response.text)
total_users = len(result)
for ctr in range(total_users):
details = dict()
if result[ctr]['accountType'] == 'atlassian':
details['accountId'] = result[ctr]['accountId']
details['emailAddress'] = result[ctr]['emailAddress']
all_users.append(details)
return all_users
getAllProjects()
getAllUsers()
# print(all_projects)
# print(all_users)
# getSpecificProject()