New fixes

This commit is contained in:
2020-09-11 15:05:11 +02:00
parent 426a7a461c
commit 855f82f622
5 changed files with 106 additions and 25 deletions

25
api.py
View File

@@ -1,5 +1,5 @@
#!/usr/bin/python3
BUILD = 28
BUILD = 29
API_VER = 2
from flask import Flask, request
import random
@@ -61,7 +61,7 @@ def getComputerExists():
return str({'RESULT': '1'})
elif sql.select("SELECT COUNT(*) 'RESULT' FROM COMPUTERS WHERE Name='"+ComputerName+"'")[0]['RESULT'] != 0: #Not UUID match, but computer exists
return str({'TEXT': 'Error, computer and UUID doesn\'t match in database', 'RESULT': 'ERROR','EXITCODE':'2'})
if sqlAddComputers == True: #Computer doesn't exist, but you have enabled add all computers
if sqlAddComputers == 'True': #Computer doesn't exist, but you have enabled add all computers
sql.insert("INSERT INTO COMPUTERS (`Name`,`UUID`) VALUES('"+ComputerName+"','"+UUID+"')")
return str({'RESULT': '1'})
else: #Computer doesn't exist and you don't want to be added
@@ -71,6 +71,27 @@ def getComputerExists():
return str({'RESULT': '1'})
##
# getGroupID: Return GroupID from GroupName
# /get/groupid?
# @param ComputerName/ComputerID -> Computer to see groups (Not neccesary)
# @param GroupID -> For know Name of a GroupID
##
@app.route("/get/groupid",methods=['POST'])
def getGroupID(): #Get local groups of a Computer
logit(request.base_url)
GroupName=None
for key, value in request.args.to_dict().items():
if key == "GroupName":
GroupID = str(sql.select("SELECT ID_G FROM GROUPS WHERE Name='"+value+"'")[0]['ID_G'])
if GroupID is not None:
return GroupID
else:
return str({'TEXT': 'I need a valid GroupName for returning GroupID','RESULT':'ERROR'})
##
# getGroups: Know all groups, or groups of a computer
# /get/groups?