Symphony REST API - Python Client
Project description
sym_api_client_python
The Python client is built in an event handler architecture. If you are building a bot that listens to conversations, you will only have to implement an interface of a listener with the functions to handle all events that will come through the Data Feed.
Install using pip --
Note this repo is in constant development
Configuration
Create a config.json file in your project which includes the following properties
{
"sessionAuthHost": "COMPANYNAME-api.symphony.com",
"sessionAuthPort": 8444,
"keyAuthHost": "COMPANYNAME-api.symphony.com",
"keyAuthPort": 8444,
"podHost": "COMPANYNAME.symphony.com",
"podPort": 443,
"agentHost": "COMAPNYNAME.symphony.com",
"agentPort": 443,
"botCertPath": "PATH",
"botCertName": "BOT-CERT-NAME",
"botCertPassword": "BOT-PASSWORD",
"botEmailAddress": "BOT-EMAIL-ADDRESS",
"appCertPath": "",
"appCertName": "",
"appCertPassword": "",
"proxyURL": "",
"proxyUsername": "",
"proxyPassword": "",
"authTokenRefreshPeriod": "30"
}
Example main class
from configure.configure import Config
from auth.auth import Auth
from clients.SymBotClient import SymBotClient
from listeners.imListenerTestImp import IMListenerTestImp
from listeners.roomListenerTestImp import RoomListenerTestImp
def main():
#pass in path to config.json file to Config class
configure = Config('./resources/config.json')
#parse through config.json and extract decrypt certificates
configure.connect()
#if you wish to authenticate using RSA replace following line with: auth = rsa_Auth(configure) --> get rid of auth.authenticate
auth = Auth(configure)
#retrieve session and keymanager tokens:
auth.authenticate()
#initialize SymBotClient with auth and configure objects
botClient = SymBotClient(auth, configure)
#initialize datafeed service
DataFeedEventService = botClient.getDataFeedEventService()
#initialize listener classes and append them to DataFeedEventService class
#these listener classes sit in DataFeedEventService class as a way to easily handle events
#coming back from the DataFeed
imListenerTest = IMListenerTestImp(botClient)
DataFeedEventService.addIMListener(imListenerTest)
roomListenerTest = RoomListenerTestImp(botClient)
DataFeedEventService.addRoomListener(roomListenerTest)
#create data feed and read data feed recursively
DataFeedEventService.startDataFeed()
if __name__ == "__main__":
main()
Example RoomListener implementation
class RoomListenerTestImp(RoomListener):
def __init__(self, SymBotClient):
self.botClient = SymBotClient
def onRoomMessage(self, message):
print('room message recieved', message)
#sample code for developer to implement --> use MessageClient and
#data recieved from message event to reply with a #reed
streamId = message['payload']['messageSent']['message']['stream']['streamId']
messageId = message['payload']['messageSent']['message']['messageId']
message = dict(message = '<messageML><hash tag="reed"/></messageML>')
self.botClient.messageClient.createMessage(streamId, message)
def onRoomCreated(self, roomCreated):
print('room created', roomCreated)
def onRoomDeactivated(self, roomDeactivated):
print('room Deactivated', roomDeactivated)
def onRoomMemberDemotedFromOwner(self, roomMemberDemotedFromOwner):
print('room member demoted from owner', roomMemberDemotedFromOwner)
def onRoomMemberPromotedToOwner(self, roomMemberPromotedToOwner):
print('room member promoted to owner', roomMemberPromotedToOwner)
def onRoomReactivated(self, roomReactivated):
print('room reactivated', roomReactivated)
def onRoomUpdated(self, roomUpdated):
print('room updated', roomUpdated)
def onUserJoinedRoom(self, userJoinedRoom):
print('USER JOINED ROOM', userJoinedRoom)
def onUserLeftRoom(self, userLeftRoom):
print('USER LEFT ROOM', userLeftRoom)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sym_api_client_python-0.0.3.tar.gz
.
File metadata
- Download URL: sym_api_client_python-0.0.3.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a08cf1ecf8271b4ad79ba77e3f7f5390b99bcb8cf69a79fdb40d4380f6cc57ad |
|
MD5 | 631c072da7ccd59640247d5fb31fb955 |
|
BLAKE2b-256 | be175f96b5ca654b93e69044526ab6a2dc7b2f4936dabe2af413e72d95c99af2 |
File details
Details for the file sym_api_client_python-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: sym_api_client_python-0.0.3-py3-none-any.whl
- Upload date:
- Size: 24.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cce3d6fbe079cc8df9ea999e9aba2e3a5c5a784be8dba8178154f192db4c1335 |
|
MD5 | 4c92cfee0c8448c42b293ad4331f1291 |
|
BLAKE2b-256 | 0eb5957c7c93a1e2ff4190742758db1921ea10d7a370bc00ee262ae9e4e2a013 |