Skip to content

Commit 5afd09c

Browse files
committed
feat(kno-252): added tenancy support
1 parent a1d590d commit 5afd09c

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ client.notify(
6060
actor="dnedry",
6161
recipients=["jhammond", "agrant", "imalcolm", "esattler"],
6262
cancellation_key=alert.id,
63+
tenant="jurassic-park",
6364
data={
6465
"type": "trex",
6566
"priority": 1
@@ -103,7 +104,7 @@ You can use the `pyjwt` package to [sign JWTs easily](https://pyjwt.readthedocs.
103104
You will need to generate an environment specific signing key, which you can find in the Knock dashboard.
104105

105106
If you're using a signing token you will need to pass this to your client to perform authentication.
106-
You can read more about [clientside authentication here](https://docs.knock.app/client-integration/authenticating-users).
107+
You can read more about [client-side authentication here](https://docs.knock.app/client-integration/authenticating-users).
107108

108109
```python
109110
import jwt

knockapi/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def preferences(self):
5353
from .resources import Preferences
5454
return Preferences(self)
5555

56-
def notify(self, key, actor, recipients, data={}, cancellation_key=None):
56+
def notify(self, key, actor, recipients, data={}, cancellation_key=None, tenant=None):
5757
"""
5858
Triggers a workflow.
5959
@@ -62,10 +62,11 @@ def notify(self, key, actor, recipients, data={}, cancellation_key=None):
6262
actor (str): The ID of the actor performing this action.
6363
recipients (array): An array of user IDs of who should be notified.
6464
data (dict): Any data to be passed to the notify call.
65+
tenant (str): An optional identifier for the tenant object that the notifications
6566
cancellation_key (str): A key used to cancel this workflow.
6667
6768
Returns:
6869
dict: Response from Knock.
6970
"""
7071
# Note: this is essentially a delegated method
71-
return self.workflows.trigger(key, actor, recipients, data=data, cancellation_key=cancellation_key)
72+
return self.workflows.trigger(key, actor, recipients, data=data, cancellation_key=cancellation_key, tenant=tenant)

knockapi/resources/workflows.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
class Workflows(Service):
5-
def trigger(self, key, actor, recipients, data={}, cancellation_key=None):
5+
def trigger(self, key, actor, recipients, data={}, cancellation_key=None, tenant=None):
66
"""
77
Triggers a workflow.
88
@@ -11,6 +11,8 @@ def trigger(self, key, actor, recipients, data={}, cancellation_key=None):
1111
actor (str): The ID of the actor performing this action.
1212
recipients (array): An array of user IDs of who should be notified.
1313
data (dict): Any data to be passed to the notify call.
14+
tenant (str): An optional identifier for the tenant object that the notifications
15+
belong to.
1416
cancellation_key (str): A key used to cancel this notify.
1517
1618
Returns:
@@ -22,7 +24,8 @@ def trigger(self, key, actor, recipients, data={}, cancellation_key=None):
2224
'actor': actor,
2325
'recipients': recipients,
2426
'data': data,
25-
'cancellation_key': cancellation_key
27+
'cancellation_key': cancellation_key,
28+
'tenant': tenant
2629
}
2730

2831
return self.request("post", endpoint, payload=params)

0 commit comments

Comments
 (0)