From 6019299ae02967a53abe8a61d7fa508ece530e12 Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Sat, 26 Mar 2016 15:26:14 +1100 Subject: [PATCH 01/30] Bump to 1.0.0 before publishing, as this adds lxml dependency --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6b8b450..779be41 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ name='Crowd', license='BSD', py_modules=['crowd'], - version='0.9.1', + version='1.0.0', install_requires=['requests', 'lxml'], description='A python client to the Atlassian Crowd REST API', From e30ec04868ba80b5d251a847c1d50c6a40b1cb09 Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Fri, 15 Apr 2016 14:24:55 +1000 Subject: [PATCH 02/30] Add shields --- README.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.rst b/README.rst index ef59aba..18e7e28 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,26 @@ python-crowd ============ +.. image:: https://img.shields.io/pypi/pyversions/crowd.svg + :target: https://pypi.python.org/pypi/jira/ + +.. image:: https://img.shields.io/pypi/l/crowd.svg + :target: https://pypi.python.org/pypi/crowd/ + +.. image:: https://img.shields.io/pypi/dm/crowd.svg + :target: https://pypi.python.org/pypi/crowd/ + +------------ + +.. image:: https://api.travis-ci.org/pycontribs/crowd.svg?branch=master + :target: https://travis-ci.org/pycontribs/crowd + +.. image:: https://img.shields.io/pypi/status/crowd.svg + :target: https://pypi.python.org/pypi/crowd/ + +.. image:: https://img.shields.io/coveralls/pycontribs/crowd.svg + :target: https://coveralls.io/r/pycontribs/crowd + python-crowd is a python client library to the Atlassian Crowd REST API. This library may be useful to you if you wish to create an application From 05fc8c537518068c20019b08fa001154946a3f66 Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Fri, 15 Apr 2016 14:29:36 +1000 Subject: [PATCH 03/30] Update travis shield --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 18e7e28..9ef20a4 100644 --- a/README.rst +++ b/README.rst @@ -13,7 +13,7 @@ python-crowd ------------ .. image:: https://api.travis-ci.org/pycontribs/crowd.svg?branch=master - :target: https://travis-ci.org/pycontribs/crowd + :target: https://travis-ci.org/pycontribs/python-crowd .. image:: https://img.shields.io/pypi/status/crowd.svg :target: https://pypi.python.org/pypi/crowd/ From cf8b2b00626bab25cc1684219ac752cd102557a3 Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Fri, 15 Apr 2016 14:30:16 +1000 Subject: [PATCH 04/30] Update travis shield (again) --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 9ef20a4..ee8bbbb 100644 --- a/README.rst +++ b/README.rst @@ -12,7 +12,7 @@ python-crowd ------------ -.. image:: https://api.travis-ci.org/pycontribs/crowd.svg?branch=master +.. image:: https://api.travis-ci.org/pycontribs/python-crowd.svg?branch=master :target: https://travis-ci.org/pycontribs/python-crowd .. image:: https://img.shields.io/pypi/status/crowd.svg From 1a726b76e13ad41ae2cfe36c69c9cb850f4f7691 Mon Sep 17 00:00:00 2001 From: Nicholas Jones Date: Wed, 17 Aug 2016 17:17:00 -0400 Subject: [PATCH 05/30] Add support for client side SSL certificates --- crowd.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crowd.py b/crowd.py index 258e4ec..bfbdcf5 100644 --- a/crowd.py +++ b/crowd.py @@ -31,14 +31,18 @@ class CrowdServer(object): The ``ssl_verify`` parameter controls how and if certificates are verified. If ``True``, the SSL certificate will be verified. A CA_BUNDLE path can also be provided. + + The ``client_cert`` tuple (cert,key) specifies a SSL client certificate and key files. """ - def __init__(self, crowd_url, app_name, app_pass, ssl_verify=True, timeout=None): + def __init__(self, crowd_url, app_name, app_pass, ssl_verify=True, + timeout=None, client_cert=None): self.crowd_url = crowd_url self.app_name = app_name self.app_pass = app_pass self.rest_url = crowd_url.rstrip("/") + "/rest/usermanagement/1" self.ssl_verify = ssl_verify + self.client_cert = client_cert self.timeout = timeout self.session = self._build_session(content_type='json') @@ -58,6 +62,7 @@ def _build_session(self, content_type='json'): } session = requests.Session() session.verify = self.ssl_verify + session.cert = self.client_cert session.auth = requests.auth.HTTPBasicAuth(self.app_name, self.app_pass) session.headers.update(headers) return session From 7d5e67f1bbe216e0d86632a048dbb21e3f13078c Mon Sep 17 00:00:00 2001 From: Paul Mattal Date: Fri, 9 Sep 2016 15:11:08 -0400 Subject: [PATCH 06/30] Add functionality to modify users in set_user_attribute() and add_user_to_group(). --- crowd.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/crowd.py b/crowd.py index 258e4ec..3b172fd 100644 --- a/crowd.py +++ b/crowd.py @@ -425,6 +425,56 @@ def set_active(self, username, active_state): return None + def set_user_attribute(self, username, attribute, value, raise_on_error=False): + """Set an attribute on a user + :param username: The username on which to set the attribute + :param attribute: The name of the attribute to set + :param value: The value of the attribute to set + :return: True on success, False on failure. + """ + data = { + 'attributes': [ + { + 'name': attribute, + 'values': [ + value + ] + }, + ] + } + response = self._post(self.rest_url + "/user/attribute", + params={"username": username,}, + data=json.dumps(data)) + + if response.status_code == 204: + return True + + if raise_on_error: + raise RuntimeError(response.json()['message']) + + return False + + def add_user_to_group(self, username, groupname, raise_on_error=False): + """Add a user to a group + :param username: The username to assign to the group + :param groupname: The group name into which to assign the user + :return: True on success, False on failure. + """ + data = { + 'name': groupname, + } + response = self._post(self.rest_url + "/user/group/direct", + params={"username": username,}, + data=json.dumps(data)) + + if response.status_code == 201: + return True + + if raise_on_error: + raise RuntimeError(response.json()['message']) + + return False + def change_password(self, username, newpassword, raise_on_error=False): """Change new password for a user From e37527600094cbc95fbdcaa22d17b6ad0c887297 Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Sun, 11 Sep 2016 12:31:22 +1000 Subject: [PATCH 07/30] Remove --use-mirrors pip arg in travis build --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c513760..35aaa9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,6 @@ python: - "3.3" - "2.7" install: - - pip install . --use-mirrors + - pip install . - pip install nose script: python tests/unittests.py From 78dcefcb7ce0e70f77cc0d3ff031f50e9fb0a019 Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Sun, 11 Sep 2016 12:40:40 +1000 Subject: [PATCH 08/30] bump version 1.0.1 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 779be41..6866341 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ name='Crowd', license='BSD', py_modules=['crowd'], - version='1.0.0', + version='1.0.1', install_requires=['requests', 'lxml'], description='A python client to the Atlassian Crowd REST API', From 600d1ffd3b7d2ffa6c4150e58776243bfe64ddd3 Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Sun, 11 Sep 2016 13:14:04 +1000 Subject: [PATCH 09/30] Update published repo url --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6866341..fb0134e 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ author='Alexander Else', author_email='aelse@else.id.au', - url='https://github.com/aelse/python-crowd', + url='https://github.com/pycontribs/python-crowd', classifiers=[ "Development Status :: 4 - Beta", From 802de00caa3ae50e227d38c2c567dd8ef6f90855 Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Sun, 11 Sep 2016 13:22:08 +1000 Subject: [PATCH 10/30] Update link to docs --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index ee8bbbb..9106cf9 100644 --- a/README.rst +++ b/README.rst @@ -34,7 +34,7 @@ Documentation Docs are built automatically by sphinx. You can build them yourself in the doc directory or access them at -. +http://python-crowd.readthedocs.io/en/latest/ Examples ======== From 1aa064c77a23c0ac08868b09e19d8a60d14f5efb Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Sun, 11 Sep 2016 13:32:23 +1000 Subject: [PATCH 11/30] bump docs version --- doc/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 6c5c851..30dcbc9 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -48,9 +48,9 @@ # built documents. # # The short X.Y version. -version = '0.9' +version = '1.0' # The full version, including alpha/beta/rc tags. -release = '0.9.0' +release = '1.0.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. From 88e64871c05d41a466e2ae41501cbe8391df00bb Mon Sep 17 00:00:00 2001 From: Jascha Geerds Date: Fri, 21 Jul 2017 11:51:28 +0200 Subject: [PATCH 12/30] Open README.rst with explicit encoding This fixes package installation when the default system encoding is not UTF-8 (e.g. LANG=C): `UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3560: ordinal not in range(128)` --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fb0134e..aa11d4c 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ from setuptools import setup +import codecs import os.path __dir__ = os.path.dirname(os.path.abspath(__file__)) @@ -10,7 +11,8 @@ install_requires=['requests', 'lxml'], description='A python client to the Atlassian Crowd REST API', - long_description=open(os.path.join(__dir__, 'README.rst')).read(), + long_description=codecs.open(os.path.join(__dir__, 'README.rst'), + encoding='utf-8').read(), author='Alexander Else', author_email='aelse@else.id.au', From 8d7a0fa3b13dd1536e30de80f4e5c90eaba8d8aa Mon Sep 17 00:00:00 2001 From: Jascha Geerds Date: Fri, 21 Jul 2017 11:56:14 +0200 Subject: [PATCH 13/30] Add myself to list of contributors --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index 9106cf9..60b948f 100644 --- a/README.rst +++ b/README.rst @@ -94,3 +94,4 @@ to the end of this list and include the change in your pull request. * Christian Schläppi (@nevious) * Yuichi Tokutomi (@Tommy1969) * Attila Bogár (@attilabogar) +* Jascha Geerds (@jgeerds) From ca2f9649feab20579f3696c525aeff1fb1f2e522 Mon Sep 17 00:00:00 2001 From: John Christian Date: Tue, 15 May 2018 09:39:19 -0400 Subject: [PATCH 14/30] Add files via upload Add start_index and max_results support to search method in crowd.py Resolves: #44 --- README.rst | 1 + crowd.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 60b948f..474b86a 100644 --- a/README.rst +++ b/README.rst @@ -95,3 +95,4 @@ to the end of this list and include the change in your pull request. * Yuichi Tokutomi (@Tommy1969) * Attila Bogár (@attilabogar) * Jascha Geerds (@jgeerds) +* John Christian (@potus98) diff --git a/crowd.py b/crowd.py index 2b8672f..4b4288b 100644 --- a/crowd.py +++ b/crowd.py @@ -628,7 +628,7 @@ def get_memberships(self): memberships[group] = {u'users': users, u'groups': groups} return memberships - def search(self, entity_type, property_name, search_string): + def search(self, entity_type, property_name, search_string, start_index=0, max_results=99999): """Performs a user search using the Crowd search API. https://developer.atlassian.com/display/CROWDDEV/Crowd+REST+Resources#CrowdRESTResources-SearchResource @@ -637,6 +637,8 @@ def search(self, entity_type, property_name, search_string): entity_type: 'user' or 'group' property_name: eg. 'email', 'name' search_string: the string to search for. + start_index: starting index of the results (default: 0) + max_results: maximum number of results returned (default: 99999) Returns: json results: @@ -656,6 +658,8 @@ def search(self, entity_type, property_name, search_string): params = { 'entity-type': entity_type, 'expand': entity_type, + 'start-index': start_index, + 'max-results': max_results } # Construct XML payload of the form: # From 4eeb43d68c5be4da5d021c3644c576809355a170 Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Thu, 8 Nov 2018 18:57:47 +1100 Subject: [PATCH 15/30] Bump version 1.0.2 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index aa11d4c..1255e34 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ name='Crowd', license='BSD', py_modules=['crowd'], - version='1.0.1', + version='1.0.2', install_requires=['requests', 'lxml'], description='A python client to the Atlassian Crowd REST API', From 6ab40b03767a43f7b1cb657d24520869cd47c332 Mon Sep 17 00:00:00 2001 From: John Christian Date: Wed, 12 Dec 2018 09:06:31 -0500 Subject: [PATCH 16/30] issue-43 Add remove_user_from_group functionality --- crowd.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/crowd.py b/crowd.py index 4b4288b..b95f351 100644 --- a/crowd.py +++ b/crowd.py @@ -480,6 +480,32 @@ def add_user_to_group(self, username, groupname, raise_on_error=False): return False + def remove_user_from_group(self, username, groupname, raise_on_error=False): + """Remove a user from a group + + Attempts to remove a user from a group + + Args + username: The username to remove from the group. + groupname: The group name to be removed from the user. + + Returns: + True: Succeeded + False: If unsuccessful + """ + + response = self._delete(self.rest_url + "/group/user/direct",params={"username": username, "groupname": groupname}) + + print response + + if response.status_code == 204: + return True + + if raise_on_error: + raise RuntimeError(response.json()['message']) + + return False + def change_password(self, username, newpassword, raise_on_error=False): """Change new password for a user From 34a7c8ac9150523019f9e5f72be8bf28c1f13fdd Mon Sep 17 00:00:00 2001 From: John Christian Date: Wed, 12 Dec 2018 09:08:02 -0500 Subject: [PATCH 17/30] issue-43 increase version due to new functionality --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1255e34..33cc755 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ name='Crowd', license='BSD', py_modules=['crowd'], - version='1.0.2', + version='1.1.0', install_requires=['requests', 'lxml'], description='A python client to the Atlassian Crowd REST API', From e4ee4ce5078a2fd3882ba9d5539b59de03e7420e Mon Sep 17 00:00:00 2001 From: John Christian Date: Wed, 12 Dec 2018 15:36:22 -0500 Subject: [PATCH 18/30] issue-43 remove print from remove_user_from_group --- crowd.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/crowd.py b/crowd.py index b95f351..ecd3fd9 100644 --- a/crowd.py +++ b/crowd.py @@ -496,8 +496,6 @@ def remove_user_from_group(self, username, groupname, raise_on_error=False): response = self._delete(self.rest_url + "/group/user/direct",params={"username": username, "groupname": groupname}) - print response - if response.status_code == 204: return True From 311a6b08005bdf185f2fd4d26de8315e29718291 Mon Sep 17 00:00:00 2001 From: John Christian Date: Wed, 12 Dec 2018 15:39:20 -0500 Subject: [PATCH 19/30] issue-43 update version 1.1.0 to 1.1.1 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 33cc755..05feccd 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ name='Crowd', license='BSD', py_modules=['crowd'], - version='1.1.0', + version='1.1.1', install_requires=['requests', 'lxml'], description='A python client to the Atlassian Crowd REST API', From 6719d651af9818b8bbc97a75a9c562e6916df4ef Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Mon, 14 Jan 2019 10:21:30 +1100 Subject: [PATCH 20/30] Build against python 3.4 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 35aaa9a..3eb9be2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: python python: - - "3.3" + - "3.4" - "2.7" install: - pip install . From 4d866851b77a825e41e204aba57f2a245d2fa900 Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Mon, 14 Jan 2019 10:22:27 +1100 Subject: [PATCH 21/30] Python 3 support requires python 3.4 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 05feccd..4edac36 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3.3", + "Programming Language :: Python :: 3.4", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Systems Administration :: Authentication/Directory", ] From 0684c159c489a798412a6faf019e3511775617bb Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Mon, 14 Jan 2019 10:30:07 +1100 Subject: [PATCH 22/30] Bump major version due to incompatibility with python 3.3 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 05feccd..e9c8f71 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ name='Crowd', license='BSD', py_modules=['crowd'], - version='1.1.1', + version='2.0.0', install_requires=['requests', 'lxml'], description='A python client to the Atlassian Crowd REST API', From 8606ac1f5a73b072e68c827860f649c978631ed7 Mon Sep 17 00:00:00 2001 From: Maiko Bossuyt Date: Fri, 31 May 2019 11:19:46 +0200 Subject: [PATCH 23/30] Fix an error when appending the validationFactors "X-Forwarded-For" --- crowd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 crowd.py diff --git a/crowd.py b/crowd.py old mode 100644 new mode 100755 index ecd3fd9..14c114d --- a/crowd.py +++ b/crowd.py @@ -281,7 +281,7 @@ def validate_session(self, token, remote="127.0.0.1", proxy=None): } if proxy: - params["validation-factors"]["validationFactors"].append({"name": "X-Forwarded-For", "value": proxy, }) + params["validationFactors"].append({"name": "X-Forwarded-For", "value": proxy, }) url = self.rest_url + "/session/%s" % token response = self._post(url, data=json.dumps(params), params={"expand": "user"}) From 70b0492481f38179c0801a4c416fadc748ae580f Mon Sep 17 00:00:00 2001 From: Maiko Bossuyt Date: Fri, 31 May 2019 11:21:07 +0200 Subject: [PATCH 24/30] Bump version and change to contributors list --- README.rst | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) mode change 100644 => 100755 README.rst mode change 100644 => 100755 setup.py diff --git a/README.rst b/README.rst old mode 100644 new mode 100755 index 474b86a..701d530 --- a/README.rst +++ b/README.rst @@ -96,3 +96,4 @@ to the end of this list and include the change in your pull request. * Attila Bogár (@attilabogar) * Jascha Geerds (@jgeerds) * John Christian (@potus98) +* Maiko Bossuyt (@maiko) diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index 575d219..348fe9c --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ name='Crowd', license='BSD', py_modules=['crowd'], - version='2.0.0', + version='2.0.1', install_requires=['requests', 'lxml'], description='A python client to the Atlassian Crowd REST API', From 4ee219b9fd795f919f6aeb33de7a36f84ca96680 Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Sat, 12 Oct 2019 11:53:27 +1100 Subject: [PATCH 25/30] Minimum python3 requirement is 3.5 --- .travis.yml | 3 ++- setup.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3eb9be2..2b4c9c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: python python: - - "3.4" + - "3.7" + - "3.5" - "2.7" install: - pip install . diff --git a/setup.py b/setup.py index 348fe9c..7dca2d7 100755 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Systems Administration :: Authentication/Directory", ] From a72992088053d573dfc5c5becf6cc99ddc35e0a1 Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Sat, 12 Oct 2019 12:01:53 +1100 Subject: [PATCH 26/30] Bump version 3.0.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7dca2d7..e2f90b8 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ name='Crowd', license='BSD', py_modules=['crowd'], - version='2.0.1', + version='3.0.0', install_requires=['requests', 'lxml'], description='A python client to the Atlassian Crowd REST API', From bed7462304e56809ee590fe5fecb45ca4500230a Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Sat, 12 Oct 2019 12:04:43 +1100 Subject: [PATCH 27/30] Build for python 3.6 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2b4c9c3..6fce01b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: python python: - "3.7" + - "3.6" - "3.5" - "2.7" install: From f3cb7c82bdc4c90bfecd36150dad1a70f800396d Mon Sep 17 00:00:00 2001 From: Alexander Else Date: Thu, 17 Oct 2019 10:59:20 +1100 Subject: [PATCH 28/30] Build for python 3.8 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6fce01b..64e95dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: python python: + - "3.8" - "3.7" - "3.6" - "3.5" From 333d24d6c044d1d7cb0a1cc77e46a2e2bb84d767 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 29 Apr 2021 19:08:22 +0000 Subject: [PATCH 29/30] Upgrade to GitHub-native Dependabot --- .github/dependabot.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..14bd311 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: +- package-ecosystem: pip + directory: "/" + schedule: + interval: daily + time: "11:00" + open-pull-requests-limit: 1 From d31079259755d7f38d8d2b7a7193e3427736b1d4 Mon Sep 17 00:00:00 2001 From: Oleg Sinilo Date: Tue, 30 Nov 2021 17:08:18 +0300 Subject: [PATCH 30/30] feature: add get_cookie_conf, group methods / refactoring --- .gitignore | 1 + README.rst | 1 + crowd.py | 170 +++++++++++++++++++++++++++++++++++++++++++++++++++-- setup.py | 2 +- 4 files changed, 168 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 0d20b64..a17907e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.pyc +dist/ \ No newline at end of file diff --git a/README.rst b/README.rst index 701d530..c3b4fb5 100755 --- a/README.rst +++ b/README.rst @@ -97,3 +97,4 @@ to the end of this list and include the change in your pull request. * Jascha Geerds (@jgeerds) * John Christian (@potus98) * Maiko Bossuyt (@maiko) +* Oleg Sinilo (@GoRoSfan) diff --git a/crowd.py b/crowd.py index 14c114d..fa05387 100755 --- a/crowd.py +++ b/crowd.py @@ -318,6 +318,21 @@ def terminate_session(self, token): # Otherwise return True return True + def get_cookie_conf(self): + """Retrieve cookie configuration + + Returns: + dict: conf information + None: if failure occurred + + """ + response = self._get(self.rest_url + "/config/cookie") + + if not response.ok: + return None + + return response.json() + def add_user(self, username, raise_on_error=False, **kwargs): """Add a user to the directory @@ -459,6 +474,143 @@ def set_user_attribute(self, username, attribute, value, raise_on_error=False): return False + def create_group(self, name, description='', raise_on_error=False): + """Create a new group with the . + + Args: + name (str): the group name of a new group + + Returns: + None: if succeeded + error msg (str): If unsuccessful + + """ + data = { + "name": name, + "description": description, + "type": "GROUP", + "active": True + } + response = self._post(self.rest_url + "/group", data=json.dumps(data)) + if response.status_code == 201: + return + + if raise_on_error: + raise RuntimeError(response.json()['message']) + + return response.json()['message'] + + def remove_group(self, name, raise_on_error=False): + """Remove a group with the . + + Args: + name (str): the group name of a removed group + + Returns: + None: If succeeded + error msg (str): If unsuccessful + + """ + data = { + "groupname": name + } + response = self._delete(self.rest_url + "/group", params=data) + if response.status_code == 204: + return + + if raise_on_error: + raise RuntimeError(response.json()['message']) + + return response.json()['message'] + + def update_group(self, name, data, raise_on_error=False): + """Update a group with the . + + Args: + name (str): the group name of a removed group + data (dict): new group attrs + + Returns: + None: if succeeded + error msg (str): If unsuccessful + + """ + params = { + 'groupname': name + } + data["name"] = name + data["type"] = "GROUP" + + response = self._put( + self.rest_url + "/group", params=params, data=json.dumps(data) + ) + if response.status_code == 200: + return + + if raise_on_error: + raise RuntimeError(response.json()['message']) + + return response.json()['message'] + + def add_child_group(self, name, parent, raise_on_error=False): + """Add a child group with the to group. + + Args: + name (str): the name of a child group + parent (str): the name of a parent group + + Returns: + None: if succeeded + error msg (str): If unsuccessful + + """ + params = { + 'groupname': parent + } + data = { + "name": name + } + response = self._post( + self.rest_url + "/group/child-group/direct", + data=json.dumps(data), + params=params + ) + if response.status_code == 201: + return + + if raise_on_error: + raise RuntimeError(response.json()['message']) + + return response.json()['message'] + + def remove_child_group(self, name, parent, raise_on_error=False): + """Add a child group with the to group. + + Args: + name (str): the name of a child group + parent (str): the name of a parent group + + Returns: + None: if succeeded + error msg (str): If unsuccessful + + """ + params = { + 'groupname': parent, + 'child-groupname': name + } + response = self._delete( + self.rest_url + "/group/child-group/direct", + params=params + ) + if response.status_code == 204: + return + + if raise_on_error: + raise RuntimeError(response.json()['message']) + + return response.json()['message'] + def add_user_to_group(self, username, groupname, raise_on_error=False): """Add a user to a group :param username: The username to assign to the group @@ -483,9 +635,9 @@ def add_user_to_group(self, username, groupname, raise_on_error=False): def remove_user_from_group(self, username, groupname, raise_on_error=False): """Remove a user from a group - Attempts to remove a user from a group + Attempts to remove a user from a group - Args + Args: username: The username to remove from the group. groupname: The group name to be removed from the user. @@ -494,7 +646,13 @@ def remove_user_from_group(self, username, groupname, raise_on_error=False): False: If unsuccessful """ - response = self._delete(self.rest_url + "/group/user/direct",params={"username": username, "groupname": groupname}) + response = self._delete( + self.rest_url + "/group/user/direct", + params={ + "username": username, + "groupname": groupname + } + ) if response.status_code == 204: return True @@ -567,7 +725,8 @@ def get_groups(self, username): return [g['name'] for g in response.json()['groups']] def get_nested_groups(self, username): - """Retrieve a list of all group names that have as a direct or indirect member. + """Retrieve a list of all group names that have as a direct + or indirect member. Args: username: The account username. @@ -587,7 +746,8 @@ def get_nested_groups(self, username): return [g['name'] for g in response.json()['groups']] def get_nested_group_users(self, groupname): - """Retrieves a list of all users that directly or indirectly belong to the given groupname. + """Retrieves a list of all users that directly or indirectly belong to + the given groupname. Args: groupname: The group name. diff --git a/setup.py b/setup.py index e2f90b8..5e311e0 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ name='Crowd', license='BSD', py_modules=['crowd'], - version='3.0.0', + version='3.1.0', install_requires=['requests', 'lxml'], description='A python client to the Atlassian Crowd REST API',