Francisco Aranda commited on
Commit
b888aa1
·
1 Parent(s): 6020a54

delete resources event listener

Browse files
Files changed (1) hide show
  1. main.py +8 -7
main.py CHANGED
@@ -24,22 +24,23 @@ async def record_events(record: rg.Record, **kwargs):
24
  # Create a webhook for dataset events
25
  @rg.webhook_listener(events=["dataset.created", "dataset.updated", "dataset.published"])
26
  async def dataset_events(type: str, dataset: rg.Dataset | None = None, **kwargs):
 
27
 
28
- if "deleted" in type:
29
- print(f"Received event {type} for dataset {kwargs['data']}")
30
- incoming_events.put((type, kwargs["data"]))
31
- else:
32
- print(f"Received event {type} for dataset {dataset.id}")
33
- incoming_events.put((type, dataset))
34
 
35
 
36
  # Create a webhook for response events
37
- @rg.webhook_listener(events=["response.created", "response.updated", "response.deleted"])
38
  async def response_events(response: rg.UserResponse, **kwargs):
39
  print(f"Received event {kwargs['type']} for response {response.id}")
40
 
41
  incoming_events.put(response)
42
 
 
 
 
 
 
43
 
44
  def check_incoming_events():
45
  """
 
24
  # Create a webhook for dataset events
25
  @rg.webhook_listener(events=["dataset.created", "dataset.updated", "dataset.published"])
26
  async def dataset_events(type: str, dataset: rg.Dataset | None = None, **kwargs):
27
+ print(f"Received event {type} for dataset {dataset.id}")
28
 
29
+ incoming_events.put((type, dataset))
 
 
 
 
 
30
 
31
 
32
  # Create a webhook for response events
33
+ @rg.webhook_listener(events=["response.created", "response.updated"])
34
  async def response_events(response: rg.UserResponse, **kwargs):
35
  print(f"Received event {kwargs['type']} for response {response.id}")
36
 
37
  incoming_events.put(response)
38
 
39
+ @rg.webhook_listener(events=["record.deleted", "dataset.deleted", "response.deleted"])
40
+ async def deleted_events(type: str, data: dict, **kwargs):
41
+ print(f"Received event {type} for resource {data}")
42
+
43
+ incoming_events.put((type, data))
44
 
45
  def check_incoming_events():
46
  """