Skip to content

Commit

Permalink
Add user properties methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gonchik committed Apr 28, 2022
1 parent 39c4478 commit c03332b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ See the `Contribution Guidelines for this project`_ for details on how to make c
.. |License| image:: https://img.shields.io/pypi/l/atlassian-python-api.svg
:target: https://pypi.python.org/pypi/atlassian-python-api
:alt: License
.. |Codacy Badge| image:: https://api.codacy.com/project/badge/Grade/c822908f507544fe98ae37b25518ae3d
:target: https://www.codacy.com/project/gonchik/atlassian-python-api/dashboard
.. |Codacy Badge| image:: https://app.codacy.com/project/badge/Grade/2cca43995cf041b8b181e2b2ff04cee6
:target: https://app.codacy.com/gh/atlassian-api/atlassian-python-api/dashboard
:alt: Codacy Badge
.. |PyPI - Downloads| image:: https://pepy.tech/badge/atlassian-python-api/month
:alt: PyPI - Downloads
Expand Down
2 changes: 1 addition & 1 deletion atlassian/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.21.0
3.22.0
50 changes: 36 additions & 14 deletions atlassian/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -1532,51 +1532,73 @@ def user_create(self, username, email, display_name, password=None, notification
url = self.resource_url("user")
return self.post(url, data=data)

def user_properties(self, account_id):
def user_properties(self, username=None, account_id=None):
"""
Get user property
:param account_id:
:param username:
:param account_id: account_id is parameter used in Cloud instances
:return:
"""
base_url = self.resource_url("user/properties")
url = "{base_url}?accountId={account_id}".format(base_url=base_url, account_id=account_id)
url = ""
if username or not self.cloud:
url = "{base_url}?accountId={username}".format(base_url=base_url, username=username)
elif account_id or self.cloud:
url = "{base_url}?accountId={account_id}".format(base_url=base_url, account_id=account_id)
return self.get(url)

def user_property(self, account_id, key_property):
def user_property(self, username=None, account_id=None, key_property=None):
"""
Get user property
:param account_id:
:param username:
:param account_id: account_id is parameter used in Cloud instances
:param key_property:
:return:
"""
params = {"accountId": account_id}
if username or not self.cloud:
params = {"username": username}
elif account_id or self.cloud:
params = {"accountId": account_id}
base_url = self.resource_url("user/properties")
return self.get("{base_url}/{key_property}".format(base_url=base_url, key_property=key_property), params=params)

def user_set_property(self, account_id, key_property, value_property):
def user_set_property(self, username=None, account_id=None, key_property=None, value_property=None):
"""
Set property for user
:param account_id:
:param username:
:param account_id: account_id is parameter used in Cloud instances
:param key_property:
:param value_property:
:return:
"""
base_url = self.resource_url("user/properties")
url = "{base_url}/{key_property}?accountId={account_id}".format(
base_url=base_url, key_property=key_property, account_id=account_id
)
url = ""
if username or not self.cloud:
url = "{base_url}/{key_property}?username={username}".format(
base_url=base_url, key_property=key_property, username=username
)
elif account_id or self.cloud:
url = "{base_url}/{key_property}?accountId={account_id}".format(
base_url=base_url, key_property=key_property, account_id=account_id
)

return self.put(url, data=value_property)

def user_delete_property(self, account_id, key_property):
def user_delete_property(self, username=None, account_id=None, key_property=None):
"""
Delete property for user
:param account_id:
:param username:
:param account_id: account_id is parameter used in Cloud instances
:param key_property:
:return:
"""
base_url = self.resource_url("user/properties")
url = "{base_url}/{key_property}".format(base_url=base_url, key_property=key_property)
params = {"accountId": account_id}
params = {}
if username or not self.cloud:
params = {"username": username}
elif account_id or self.cloud:
params = {"accountId": account_id}
return self.delete(url, params=params)

def user_update_or_create_property_through_rest_point(self, username, key, value):
Expand Down

0 comments on commit c03332b

Please sign in to comment.