Remove API key From Console

master
Sebastian Serfling 2023-10-13 12:37:31 +02:00
parent f6120e361d
commit 3357c9d4b1
2 changed files with 37 additions and 0 deletions

View File

@ -119,6 +119,19 @@ class CL_SET_HOST(BaseModel):
hddtotal: str
ipadresse: str
class CL_GET_CPU(BaseModel):
hostname: str
cputype: str
cpuname: str
dbname: str
class CL_SET_CPU(BaseModel):
hostname: str
cputype: str
ghz: str
cpuname: str
dbname: str
class CL_UPDATE_HOST(BaseModel):
hostname: str
dbname: str

24
main.py
View File

@ -94,6 +94,16 @@ async def gethost(get: CL.CL_GET_HOST,api_key: APIKey = Depends(auth.get_api_key
else:
return result[0][0]
@app.post("/host/get/cpu")
async def getcpu(get: CL.CL_GET_CPU,api_key: APIKey = Depends(auth.get_api_key)):
result = database(
f"SELECT id FROM `{get.dbname}`.cpulist WHERE cpuname = '{get.cpuname} AND cputyp = {get.cputype}')",
"", "")
if not result:
return False
else:
return result[0][0]
@app.post("/host/get/database")
async def getdatabase(get: CL.CL_GET_DATABASE,api_key: APIKey = Depends(auth.get_api_key)):
result = database(f"SELECT Datenbank FROM `Kunden` where `Subnetz` = '{get.ip}'","Stines-GmbH","")
@ -113,6 +123,20 @@ async def sethost(get: CL.CL_SET_HOST,api_key: APIKey = Depends(auth.get_api_key
else:
return result[0][0]
@app.post("/host/set/cpu")
async def setcpu(get: CL.CL_SET_CPU,api_key: APIKey = Depends(auth.get_api_key)):
database(f"INSERT INTO `{get.dbname}`.cpulist (cpuname,ghz,cputyp) VALUES ('{get.cpuname}','{get.ghz}','{get.cputyp}')","","")
result = database(
f"SELECT id FROM `{get.dbname}`.cpulist WHERE cpuname = '{get.cpuname} AND cputyp = {get.cputyp}')",
"", "")
database(
f"INSERT INTO `{get.dbname}`.cpu_to_client (hardwareID,cpulistID) VALUES ('{get.hardwareID}','{result[0][0]}',)",
"", "")
if not result:
return False
else:
return result[0][0]
@app.post("/host/update")
async def updatehost(get: CL.CL_UPDATE_HOST,api_key: APIKey = Depends(auth.get_api_key)):
database(f"UPDATE `{get.dbname}`.hardware SET ipadresse = '{get.ipadresse}', ram = '{get.ram}', hddused = '{get.hddused}' ,hddfree = '{get.hddfree}',hddtotal = '{get.hddtotal}' WHERE hostname = '{get.hostname}'","","")