diff --git a/.gitignore b/.gitignore
index 85bc1b8..b040d4b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@ env/
main*.py
*.swp
*.pyc
+__pycache__/
\ No newline at end of file
diff --git a/README.md b/README.md
index 1a68a2c..54596a9 100644
--- a/README.md
+++ b/README.md
@@ -5,10 +5,72 @@ Initialize the wrapper with the token you want to use
i.e: gotipy_usr = gotipy.gotipy("user token", "https://URL.TLD")
Functions Implimented
--getApplications() // Gets a list of applications and returns the value in a dictionary
--createApplication(name, description) // Creates a new Application
+- basicAuth(user, passwd)
+Sets up basic Auth for inclusion in the header
--deleteApplication(id) // Deletes the requseted application (Note for now this uses a string)
+- getApplications()
+Returns a JSON formatted list of applications
--sendMessage(title, message) // Sends a notification with the specified title/message
\ No newline at end of file
+- createApplication(name, description)
+Creates an application with defined name and description
+
+- deleteApplication(appid)
+Delete Application via appid
+
+- updateApplicationImage(appid, imgData)
+Updates the application image
+
+- getClients()
+Returns a JSON formatted list of Clients
+
+- addClient(name)
+Creates a new client with name
+
+- deleteClient(clientid)
+Delete clients via clientID
+
+- getMessagesByApp(appid)
+Returns a JSON formatted list of messages in an application
+
+- deleteAllMessagesFromApp(appid)
+Deletes all messages in an application
+
+- getAllMessages()
+Returns a JSON formatted list of all messages
+
+- sendMessage(title, message)
+Sends a message using an application auth token (Note this is the only function that requires an application token)
+
+- deleteAllMessages()
+Deletes all messages
+
+- deleteMessageByID(msgid)
+Delete a message by its ID
+
+- getStream() ## Currently broken, returns 400 error, no idea why
+This should return all new messages but it doesn't, also broken when testing with the docs so #nfi
+
+- getCurrentUser()
+Returns a JSON formatted list of information for the current user
+
+- changeUserPassword(passwd)
+Changes the password of the current account
+
+- getUsers()
+Returns a JSON formatted list of users
+
+- createUser(isAdmin, username, password)
+Creates a new user with the specified details (isAdmin: boolean value)
+
+- getUserByID(userID)
+Returns a JSON formatted list of the selected user
+
+- updateUserByID(userID, isAdmin, username, password) ## I really do not like this implementation will look into a better way
+Updates the user information by ID, need to pass an entire user data object currently, working on a better way
+
+- deleteUserByID(userID)
+Deletes user by ID
+
+- getVersion()
+Returns the version of gotify running on the server
\ No newline at end of file
diff --git a/gotipy.py b/gotipy.py
index ea81934..8f1e085 100644
--- a/gotipy.py
+++ b/gotipy.py
@@ -29,10 +29,7 @@ class gotipy(object):
self.requrl = self.url + '/application'
req = requests.get(self.requrl, headers=self.headers)
- try:
- return req.json()['error']
- except:
- return req.json()
+ return req
def createApplication(self, name, description):
self.name = name
@@ -49,7 +46,7 @@ class gotipy(object):
def deleteApplication(self, appid):
self.appid = appid
- self.requrl = self.url + '/application/' + self.appid
+ self.requrl = self.url + '/application/' + str(self.appid)
req = requests.delete(self.requrl, headers=self.headers)
return req
@@ -68,7 +65,43 @@ class gotipy(object):
req = requests.get(self.requrl, headers=self.headers)
return req
+ def addClient(self, name):
+ self.name = name
+ self.requrl = self.url + '/client'
+ data = {"name": self.name}
+ pprint(data)
+
+ req = requests.post(self.requrl, headers=self.headers, json=data)
+ return req
+
+ def deleteClient(self, clientid):
+ self.clientid = clientid
+ self.requrl = self.url + '/client/' + str(self.clientid)
+
+ req = requests.delete(self.requrl, headers=self.headers)
+ return req
+
## Message Functions
+ def getMessagesByApp(self, appid):
+ self.appid = appid
+ self.requrl = self.url + '/application/' + str(self.appid) + "/message"
+
+ req = requests.get(self.requrl, headers=self.headers)
+ return req
+
+ def deleteAllMessagesFromApp(self, appid):
+ self.appid = appid
+ self.requrl = self.url + '/application/' + str(self.appid) + "/message"
+
+ req = requests.delete(self.requrl, headers=self.headers)
+ return req
+
+ def getAllMessages(self):
+ self.requrl = self.url + '/message'
+
+ req = requests.get(self.requrl, headers=self.headers)
+ return req
+
def sendMessage(self, title, message):
self.title = title
self.message = message
@@ -80,9 +113,93 @@ class gotipy(object):
data["title"] = self.title
req = requests.post(self.requrl, headers=self.headers, json=data)
- try:
- return req.json()['error']
- except:
- return "Message Sent :)"
+ return req
+
+ def deleteAllMessages(self):
+ self.requrl = self.url + '/message'
+
+ req = requests.delete(self.requrl, headers=self.headers)
+ return req
+
+ def deleteMessageByID(self, msgid):
+ self.msgid = msgid
+ self.requrl = self.url + '/message/' + str(self.msgid)
+
+ req = requests.delete(self.requrl, headers=self.headers)
+ return req
+
+ def getStream(self): ## Currently broken, returns 400 error, no idea why
+ self.requrl = self.url + '/stream'
+
+ req = requests.get(self.requrl, headers=self.headers)
+ return req
## User Functions
+
+ def getCurrentUser(self):
+ self.requrl = self.url + '/current/user'
+
+ req = requests.get(self.requrl, headers=self.headers)
+ return req
+
+ def changeUserPassword(self, passwd):
+ self.passwd = str(passwd)
+ self.requrl = self.url + '/current/user/password'
+
+ data = {"pass": self.passwd}
+ req = requests.post(self.requrl, headers=self.headers, json=data)
+ return req
+
+ def getUsers(self):
+ self.requrl = self.url + '/user'
+
+ req = requests.get(self.requrl, headers=self.headers)
+ return req
+
+ def createUser(self, isAdmin, username, password):
+ self.isAdmin = bool(isAdmin)
+ self.username = str(username)
+ self.password = str(password)
+ self.requrl = self.url + '/user'
+
+ data = {"admin": self.isAdmin,
+ "name": self.username,
+ "pass": self.password}
+
+ req = requests.post(self.requrl, headers=self.headers, json=data)
+ return req
+
+ def getUserByID(self, userID):
+ self.userID = str(userID)
+ self.requrl = self.url + '/user/' + self.userID
+
+ req = requests.get(self.requrl, headers=self.headers)
+ return req
+
+ def updateUserByID(self, userID, isAdmin, username, password): ## I really do not like this implementation will look into a better way
+ self.userID = str(userID)
+ self.isAdmin = bool(isAdmin)
+ self.username = str(username)
+ self.password = str(password)
+ self.requrl = self.url + '/user/' + self.userID
+
+ data = {"admin": self.isAdmin,
+ "name": self.username,
+ "pass": self.password}
+ req = requests.post(self.requrl, headers=self.headers, json=data)
+ return req
+
+ def deleteUserByID(self, userID):
+ self.userID = str(userID)
+ self.requrl = self.url + '/user/' + self.userID
+
+ req = requests.delete(self.requrl, headers=self.headers)
+ return req
+
+## Get version information
+
+ def getVersion(self):
+ self.requrl = self.url + '/version'
+
+ req = requests.get(self.requrl)
+ return req
\ No newline at end of file