Skip to content

Commit

Permalink
added check sqs endpoint to sdk (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
gumuz authored Jan 5, 2021
1 parent 4210ad2 commit 8888d3a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
14 changes: 14 additions & 0 deletions stream_chat/async_chat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,20 @@ async def delete_blocklist(self, name):
"""
return await self.delete(f"blocklists/{name}")

async def check_sqs(self, sqs_key=None, sqs_secret=None, sqs_url=None):
"""
Check SQS Push settings
When no parameters are given, the current SQS app settings are used
:param sqs_key: AWS access key
:param sqs_secret: AWS secret key
:param sqs_url: URL to SQS queue
:return:
"""
data = {"sqs_key": sqs_key, "sqs_secret": sqs_secret, "sqs_url": sqs_url}
return await self.post("check_sqs", data=data)

async def close(self):
await self.session.close()

Expand Down
14 changes: 14 additions & 0 deletions stream_chat/base/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,17 @@ def delete_blocklist(self, name):
:return:
"""
pass

@abc.abstractmethod
async def check_sqs(self, sqs_key=None, sqs_secret=None, sqs_url=None):
"""
Check SQS Push settings
When no parameters are given, the current SQS app settings are used
:param sqs_key: AWS access key
:param sqs_secret: AWS secret key
:param sqs_url: URL to SQS queue
:return:
"""
pass
14 changes: 14 additions & 0 deletions stream_chat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,17 @@ def delete_blocklist(self, name):
:return:
"""
return self.delete(f"blocklists/{name}")

def check_sqs(self, sqs_key=None, sqs_secret=None, sqs_url=None):
"""
Check SQS Push settings
When no parameters are given, the current SQS app settings are used
:param sqs_key: AWS access key
:param sqs_secret: AWS secret key
:param sqs_url: URL to SQS queue
:return:
"""
data = {"sqs_key": sqs_key, "sqs_secret": sqs_secret, "sqs_url": sqs_url}
return self.post("check_sqs", data=data)
6 changes: 6 additions & 0 deletions stream_chat/tests/async_chat/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,9 @@ async def test_update_blocklist(self, event_loop, client):
@pytest.mark.asyncio
async def test_delete_blocklist(self, event_loop, client):
await client.delete_blocklist("Foo")

@pytest.mark.asyncio
async def test_check_sqs(self, client):
response = await client.check_sqs("key", "secret", "https://foo.com/bar")
assert response["status"] == "error"
assert "invalid SQS url" in response["error"]
5 changes: 5 additions & 0 deletions stream_chat/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,8 @@ def test_update_blocklist(self, client):

def test_delete_blocklist(self, client):
client.delete_blocklist("Foo")

def test_check_sqs(self, client):
response = client.check_sqs("key", "secret", "https://foo.com/bar")
assert response["status"] == "error"
assert "invalid SQS url" in response["error"]

0 comments on commit 8888d3a

Please sign in to comment.