From 01fdbc4d31e862d0da92f783a08c75c0d108c3c5 Mon Sep 17 00:00:00 2001 From: benjamyn Date: Sun, 11 Nov 2018 20:29:31 +1100 Subject: [PATCH] Updated README.md with a new layout Fixed name of function to better fit the standard (addClient -> createClient) --- README.md | 205 ++++++++++++++++++++++++++++++++++++------------------ gotipy.py | 5 +- 2 files changed, 139 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index 34321ff..badd8f5 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Initialize the wrapper with the token you want to use i.e: gotipy_usr = gotipy.gotipy("user token", "https://URL.TLD") -applications class +

applications class

@@ -20,7 +20,7 @@ i.e: gotipy_usr = gotipy.gotipy("user token", "https://URL.TLD") - + @@ -35,73 +35,142 @@ i.e: gotipy_usr = gotipy.gotipy("user token", "https://URL.TLD")
Function
createApplicationname, descriptionName, Description JSON formatted list
-

Functions Implimented

+

clients class

+ + + + + + + + + + + + + + + + + + + + + +
FunctionArgumentsReturn
getClientsN/AJSON formatted list
createClientNameJSON formatted list
deleteClientClient IDHTTP response code
-- basicAuth(user, passwd) -Sets up basic Auth for inclusion in the header +

msgManager class

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FunctionArgumentsReturn
getMessagesByAppApplication IDJSON formatted list
deleteAllMessagesFromAppApplication IDHTTP response code
getAllMesagesN/AJSON formatted list
deleteAllMessagesN/AHTTP response code
deleteMessagesByIDMessage IDHTTP response code
getStreamN/AJSON formatted list
-- getApplications() -Returns a JSON formatted list of applications +

messages class

+ + + + + + + + + + + +
FunctionArgumentsReturn
sendMessageTitle, MessageJSON formatted list
-- createApplication(name, description) -Creates an application with defined name and description +

users class

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FunctionArgumentsReturn
getCurrentUser()N/AJSON formatted list
changeUserPasswordPasswordJSON formatted list
getUsersN/AJSON formatted list
createUserAdmin, Username, PasswordJSON formatted list
getUserByIDUser IDJSON formatted list
updateUserByIDUser ID, Admin, Username, PasswordJSON formatted list
deleteUserByIDUser IDHTTP response code
-- 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 +

utils class

+ + + + + + + + + + + + + + + + +
FunctionArgumentsReturn
getVersionN/AJSON formatted list
basicAuthUsername, passwordJSON formatted list
\ No newline at end of file diff --git a/gotipy.py b/gotipy.py index 9fb37eb..a610367 100644 --- a/gotipy.py +++ b/gotipy.py @@ -62,7 +62,7 @@ class gotipy(object): req = requests.get(self.requrl, headers=self.headers) return req - def addClient(self, name): + def createClient(self, name): self.name = name self.requrl = self.url + '/client' data = {"name": self.name} @@ -71,7 +71,6 @@ class gotipy(object): 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) @@ -235,4 +234,4 @@ class gotipy(object): print(self.string.encode('utf-8')) self.headers["authorization"] = "Basic " + base64.b64encode(self.string) print(self.encoded) - return self.headers \ No newline at end of file + return self.headers