Skip to content

Commit 2ded504

Browse files
Gonchik TsymzhitovGonchik Tsymzhitov
authored andcommitted
Merge remote-tracking branch 'upstream/master'
2 parents 87139be + 216ec04 commit 2ded504

File tree

4 files changed

+81
-1
lines changed

4 files changed

+81
-1
lines changed

atlassian/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.9.5
1+
1.9.6

atlassian/confluence.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,37 @@ def get_space(self, space_key, expand='description.plain,homepage'):
485485
expand=expand)
486486
return self.get(url)
487487

488+
def get_user_details_by_username(self, username, expand=None):
489+
"""
490+
Get information about a user through username
491+
:param username: The user name
492+
:param expand: OPTIONAL expand for get status of user.
493+
Possible param is "status". Results are "Active, Deactivated"
494+
:return: Returns the user details
495+
"""
496+
if expand:
497+
url = 'rest/api/user?username={username}&expand={expand}'.format(username=username,
498+
expand=expand)
499+
else:
500+
url = 'rest/api/user?username={username}'.format(username=username)
501+
502+
return self.get(url)
503+
504+
def get_user_details_by_userkey(self, userkey, expand=None):
505+
"""
506+
Get information about a user through user key
507+
:param userkey: The user key
508+
:param expand: OPTIONAL expand for get status of user.
509+
Possible param is "status". Results are "Active, Deactivated"
510+
:return: Returns the user details
511+
"""
512+
if expand:
513+
url = 'rest/api/user?key={userkey}&expand={expand}'.format(userkey=userkey,
514+
expand=expand)
515+
else:
516+
url = 'rest/api/user?key={userkey}'.format(userkey=userkey)
517+
return self.get(url)
518+
488519
def cql(self, cql, start=0, limit=None):
489520
"""
490521
Get results from cql search result with all related fields

atlassian/jira.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,43 @@ def get_project_components(self, key):
129129
"""
130130
return self.get('rest/api/2/project/{0}/components'.format(key))
131131

132+
def get_project_versions(self, key, expand=None):
133+
"""
134+
Contains a full representation of a the specified project's versions.
135+
:param key:
136+
:param expand: the parameters to expand
137+
:return:
138+
"""
139+
if expand is not None:
140+
params["expand"] = expand
141+
return self.get('rest/api/2/project/{}/versions'.format(key))
142+
143+
def get_project_versions_paginated(self, key, start=None, limit=None, order_by=None, expand=None):
144+
"""
145+
Returns all versions for the specified project. Results are paginated.
146+
Results can be ordered by the following fields:
147+
sequence
148+
name
149+
startDate
150+
releaseDate
151+
:param key: the project key or id
152+
:param start: the page offset, if not specified then defaults to 0
153+
:param limit: how many results on the page should be included. Defaults to 50.
154+
:param order_by: ordering of the results.
155+
:param expand: the parameters to expand
156+
:return:
157+
"""
158+
params = {}
159+
if start is not None:
160+
params["startAt"] = int(start)
161+
if limit is not None:
162+
params["maxResults"] = int(limit)
163+
if order_by is not None:
164+
params["orderBy"] = order_by
165+
if expand is not None:
166+
params["expand"] = expand
167+
return self.get('rest/api/2/project/{}/version'.format(key), params)
168+
132169
def issue(self, key, fields='*all'):
133170
return self.get('rest/api/2/issue/{0}?fields={1}'.format(key, fields))
134171

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# coding: utf8
2+
from atlassian import Confluence
3+
4+
""" This example related get user details and his status"""
5+
6+
confluence = Confluence(
7+
url='http://localhost:8090',
8+
username='admin',
9+
password='admin')
10+
11+
result = confluence.get_user_details_by_username(username="gonchik.tsymzhitov", expand="status")
12+
print(result)

0 commit comments

Comments
 (0)