-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathPersistentSignalRExample.py
More file actions
35 lines (23 loc) · 1003 Bytes
/
PersistentSignalRExample.py
File metadata and controls
35 lines (23 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Copyright (c) One Identity LLC. All rights reserved.
# Licensed under the Apache License, Version 2.0.
from pysafeguard import SafeguardClient, PkceAuth
# The appliance host name or IP address
host = ""
# The user name for PKCE authentication
username = ""
# The password for PKCE authentication
password = ""
# Path to the trusted root CA of the appliance
ca_file = ""
def on_asset_created(name: str, body: str) -> None:
print(f"Asset created: {name}\n{body}")
def on_asset_modified(name: str, body: str) -> None:
print(f"Asset modified: {name}\n{body}")
with SafeguardClient(host, auth=PkceAuth("local", username, password), verify=ca_file) as client:
listener = client.get_persistent_event_listener()
listener.on("AssetCreated", on_asset_created)
listener.on("AssetModified", on_asset_modified)
with listener:
listener.start()
print("Persistent listener started (auto-reconnects on disconnect)")
input("Press Enter to stop listening...")