Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 227c3fb469 | |||
| 0378a38d87 | |||
| 5c12e06e58 | |||
| 27363e5fa7 | |||
| 8be16c34ff | |||
| 8971629bcb | |||
| 7e237c6b68 | |||
| 062904fd2a |
@@ -12,3 +12,4 @@ Karl Goetz
|
||||
Alex Kerney
|
||||
Gustav <https://github.com/dkgv>
|
||||
Sebastian2023 <https://github.com/Sebastian2023>
|
||||
Dominik George <https://github.com/Natureshadow>
|
||||
@@ -3,6 +3,13 @@
|
||||
Release history
|
||||
===============
|
||||
|
||||
1.3.0
|
||||
-----
|
||||
|
||||
- Add fix for handling global Discourse timeouts
|
||||
- Add group owners
|
||||
- Update API for add_group_owner
|
||||
|
||||
1.2.0
|
||||
-----
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ version = attr: pydiscourse.__version__
|
||||
author = "Marc Sibson and contributors"
|
||||
author_email = "ben@benlopatin.com"
|
||||
license = "MIT"
|
||||
url = "https://github.com/bennylope/pydiscourse"
|
||||
url = https://github.com/bennylope/pydiscourse
|
||||
description = "A Python library for the Discourse API"
|
||||
long_description = file: README.rst, HISTORY.rst
|
||||
platforms =
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
"""Python client for the Discourse API."""
|
||||
|
||||
__version__ = "1.2.0"
|
||||
__version__ = "1.3.0"
|
||||
|
||||
from pydiscourse.client import DiscourseClient
|
||||
|
||||
|
||||
@@ -1119,7 +1119,24 @@ class DiscourseClient(object):
|
||||
|
||||
"""
|
||||
return self._put(
|
||||
"/admin/groups/{0}/owners.json".format(groupid), usernames=username
|
||||
"/admin/groups/{0}/owners.json".format(groupid), **{"group[usernames]": username}
|
||||
)
|
||||
|
||||
def add_group_owners(self, groupid, usernames):
|
||||
"""
|
||||
Add a list of owners to a group by usernames
|
||||
|
||||
Args:
|
||||
groupid: the ID of the group
|
||||
username: the list of new owner usernames
|
||||
|
||||
Returns:
|
||||
JSON API response
|
||||
|
||||
"""
|
||||
usernames = ",".join(usernames)
|
||||
return self._put(
|
||||
"/admin/groups/{0}/owners.json".format(groupid), **{"group[usernames]": usernames}
|
||||
)
|
||||
|
||||
def delete_group_owner(self, groupid, userid):
|
||||
@@ -1544,10 +1561,15 @@ class DiscourseClient(object):
|
||||
if 400 <= response.status_code < 500:
|
||||
if 429 == response.status_code:
|
||||
# This codepath relies on wait_seconds from Discourse v2.0.0.beta3 / v1.9.3 or higher.
|
||||
rj = response.json()
|
||||
wait_delay = (
|
||||
retry_backoff + rj["extras"]["wait_seconds"]
|
||||
) # how long to back off for.
|
||||
if "application/json" in response.headers.get("Content-Type"):
|
||||
ret = response.json()
|
||||
wait_delay = (
|
||||
retry_backoff + ret["extras"]["wait_seconds"]
|
||||
) # how long to back off for.
|
||||
else:
|
||||
# We got an early 429 error without a proper JSON body
|
||||
ret = response.content
|
||||
wait_delay = retry_backoff + 10
|
||||
|
||||
if retry_count > 1:
|
||||
time.sleep(wait_delay)
|
||||
@@ -1557,7 +1579,7 @@ class DiscourseClient(object):
|
||||
wait_delay, retry_count
|
||||
)
|
||||
)
|
||||
log.debug("API returned {0}".format(rj))
|
||||
log.debug("API returned {0}".format(ret))
|
||||
continue
|
||||
else:
|
||||
raise DiscourseClientError(msg, response=response)
|
||||
|
||||
Reference in New Issue
Block a user