Implemented the basics versions of createApplication and deleteApplication
Both seem to be working, need to run more tests though
This commit is contained in:
parent
8cfe2a0092
commit
858c7fbe70
39
gotipy.py
39
gotipy.py
@ -8,6 +8,37 @@ class gotipy(object):
|
|||||||
self.url = url
|
self.url = url
|
||||||
self.headers = {'X-Gotify-Key' : self.token}
|
self.headers = {'X-Gotify-Key' : self.token}
|
||||||
|
|
||||||
|
## Token Functions
|
||||||
|
def getApplications(self):
|
||||||
|
self.requrl = self.url + '/application'
|
||||||
|
|
||||||
|
req = requests.get(self.requrl, headers=self.headers)
|
||||||
|
try:
|
||||||
|
return req.json()['error']
|
||||||
|
except:
|
||||||
|
return req.json()
|
||||||
|
|
||||||
|
def createApplication(self, name, description):
|
||||||
|
self.name = name
|
||||||
|
self.description = description
|
||||||
|
self.requrl = self.url + '/application'
|
||||||
|
|
||||||
|
data = {}
|
||||||
|
data["name"] = self.name
|
||||||
|
data["description"] = self.description
|
||||||
|
|
||||||
|
req = requests.post(self.requrl, headers=self.headers, json=data)
|
||||||
|
pprint(req)
|
||||||
|
return req
|
||||||
|
|
||||||
|
def deleteApplication(self, id):
|
||||||
|
self.id = id
|
||||||
|
self.requrl = self.url + '/application/' + self.id
|
||||||
|
|
||||||
|
req = requests.delete(self.requrl, headers=self.headers)
|
||||||
|
return req
|
||||||
|
|
||||||
|
## Message Functions
|
||||||
def sendMessage(self, title, message):
|
def sendMessage(self, title, message):
|
||||||
self.title = title
|
self.title = title
|
||||||
self.message = message
|
self.message = message
|
||||||
@ -23,11 +54,5 @@ class gotipy(object):
|
|||||||
return req.json()['error']
|
return req.json()['error']
|
||||||
except:
|
except:
|
||||||
return "Message Sent :)"
|
return "Message Sent :)"
|
||||||
def getApplications(self):
|
|
||||||
self.requrl = self.url + '/application'
|
|
||||||
|
|
||||||
req = requests.get(self.requrl, headers=self.headers)
|
## User Functions
|
||||||
try:
|
|
||||||
return req.json()['error']
|
|
||||||
except:
|
|
||||||
return req.json()
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user