Skip to content

Commit c03332b

Browse files
committed
Add user properties methods
1 parent 39c4478 commit c03332b

File tree

3 files changed

+39
-17
lines changed

3 files changed

+39
-17
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ See the `Contribution Guidelines for this project`_ for details on how to make c
135135
.. |License| image:: https://img.shields.io/pypi/l/atlassian-python-api.svg
136136
:target: https://pypi.python.org/pypi/atlassian-python-api
137137
:alt: License
138-
.. |Codacy Badge| image:: https://api.codacy.com/project/badge/Grade/c822908f507544fe98ae37b25518ae3d
139-
:target: https://www.codacy.com/project/gonchik/atlassian-python-api/dashboard
138+
.. |Codacy Badge| image:: https://app.codacy.com/project/badge/Grade/2cca43995cf041b8b181e2b2ff04cee6
139+
:target: https://app.codacy.com/gh/atlassian-api/atlassian-python-api/dashboard
140140
:alt: Codacy Badge
141141
.. |PyPI - Downloads| image:: https://pepy.tech/badge/atlassian-python-api/month
142142
:alt: PyPI - Downloads

atlassian/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.21.0
1+
3.22.0

atlassian/jira.py

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,51 +1532,73 @@ def user_create(self, username, email, display_name, password=None, notification
15321532
url = self.resource_url("user")
15331533
return self.post(url, data=data)
15341534

1535-
def user_properties(self, account_id):
1535+
def user_properties(self, username=None, account_id=None):
15361536
"""
15371537
Get user property
1538-
:param account_id:
1538+
:param username:
1539+
:param account_id: account_id is parameter used in Cloud instances
15391540
:return:
15401541
"""
15411542
base_url = self.resource_url("user/properties")
1542-
url = "{base_url}?accountId={account_id}".format(base_url=base_url, account_id=account_id)
1543+
url = ""
1544+
if username or not self.cloud:
1545+
url = "{base_url}?accountId={username}".format(base_url=base_url, username=username)
1546+
elif account_id or self.cloud:
1547+
url = "{base_url}?accountId={account_id}".format(base_url=base_url, account_id=account_id)
15431548
return self.get(url)
15441549

1545-
def user_property(self, account_id, key_property):
1550+
def user_property(self, username=None, account_id=None, key_property=None):
15461551
"""
15471552
Get user property
1548-
:param account_id:
1553+
:param username:
1554+
:param account_id: account_id is parameter used in Cloud instances
15491555
:param key_property:
15501556
:return:
15511557
"""
1552-
params = {"accountId": account_id}
1558+
if username or not self.cloud:
1559+
params = {"username": username}
1560+
elif account_id or self.cloud:
1561+
params = {"accountId": account_id}
15531562
base_url = self.resource_url("user/properties")
15541563
return self.get("{base_url}/{key_property}".format(base_url=base_url, key_property=key_property), params=params)
15551564

1556-
def user_set_property(self, account_id, key_property, value_property):
1565+
def user_set_property(self, username=None, account_id=None, key_property=None, value_property=None):
15571566
"""
15581567
Set property for user
1559-
:param account_id:
1568+
:param username:
1569+
:param account_id: account_id is parameter used in Cloud instances
15601570
:param key_property:
15611571
:param value_property:
15621572
:return:
15631573
"""
15641574
base_url = self.resource_url("user/properties")
1565-
url = "{base_url}/{key_property}?accountId={account_id}".format(
1566-
base_url=base_url, key_property=key_property, account_id=account_id
1567-
)
1575+
url = ""
1576+
if username or not self.cloud:
1577+
url = "{base_url}/{key_property}?username={username}".format(
1578+
base_url=base_url, key_property=key_property, username=username
1579+
)
1580+
elif account_id or self.cloud:
1581+
url = "{base_url}/{key_property}?accountId={account_id}".format(
1582+
base_url=base_url, key_property=key_property, account_id=account_id
1583+
)
1584+
15681585
return self.put(url, data=value_property)
15691586

1570-
def user_delete_property(self, account_id, key_property):
1587+
def user_delete_property(self, username=None, account_id=None, key_property=None):
15711588
"""
15721589
Delete property for user
1573-
:param account_id:
1590+
:param username:
1591+
:param account_id: account_id is parameter used in Cloud instances
15741592
:param key_property:
15751593
:return:
15761594
"""
15771595
base_url = self.resource_url("user/properties")
15781596
url = "{base_url}/{key_property}".format(base_url=base_url, key_property=key_property)
1579-
params = {"accountId": account_id}
1597+
params = {}
1598+
if username or not self.cloud:
1599+
params = {"username": username}
1600+
elif account_id or self.cloud:
1601+
params = {"accountId": account_id}
15801602
return self.delete(url, params=params)
15811603

15821604
def user_update_or_create_property_through_rest_point(self, username, key, value):

0 commit comments

Comments
 (0)