add new endpoints for app v2 #116
3 changed files with 284 additions and 34 deletions
27
bumper/db.py
27
bumper/db.py
|
|
@ -1,13 +1,13 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import bumper
|
|
||||||
from bumper.models import VacBotClient, VacBotDevice, BumperUser, EcoVacsHomeProducts, OAuth
|
|
||||||
from tinydb import TinyDB, Query
|
|
||||||
from tinydb.storages import MemoryStorage
|
|
||||||
from datetime import datetime, timedelta
|
|
||||||
import os
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
from tinydb import TinyDB, Query
|
||||||
|
|
||||||
|
import bumper
|
||||||
|
from bumper.models import VacBotClient, VacBotDevice, BumperUser, EcoVacsHomeProducts, OAuth
|
||||||
|
|
||||||
bumperlog = logging.getLogger("bumper")
|
bumperlog = logging.getLogger("bumper")
|
||||||
|
|
||||||
|
|
@ -338,6 +338,19 @@ def bot_toEcoVacsHome_JSON(bot): # EcoVacs Home
|
||||||
bot["ota"] = botprod["product"]["ota"]
|
bot["ota"] = botprod["product"]["ota"]
|
||||||
bot["icon"] = botprod["product"]["iconUrl"]
|
bot["icon"] = botprod["product"]["iconUrl"]
|
||||||
bot["model"] = botprod["product"]["model"]
|
bot["model"] = botprod["product"]["model"]
|
||||||
|
bot["pip"] = botprod["product"]["_id"]
|
||||||
|
bot["deviceName"] = botprod["product"]["name"]
|
||||||
|
bot["materialNo"] = botprod["product"]["materialNo"]
|
||||||
|
bot["product_category"] = "DEEBOT" if botprod["product"]["name"].startswith("DEEBOT") else "UNKNOWN"
|
||||||
|
# bot["updateInfo"] = {
|
||||||
|
# "changeLog": "",
|
||||||
|
# "needUpdate": False
|
||||||
|
# }
|
||||||
|
# bot["service"] = {
|
||||||
|
# "jmq": "jmq-ngiot-eu.dc.ww.ecouser.net",
|
||||||
|
# "mqs": "api-ngiot.dc-as.ww.ecouser.net"
|
||||||
|
# }
|
||||||
|
|
||||||
return json.dumps(
|
return json.dumps(
|
||||||
bot, default=lambda o: o.__dict__, sort_keys=False
|
bot, default=lambda o: o.__dict__, sort_keys=False
|
||||||
) # , indent=4)
|
) # , indent=4)
|
||||||
|
|
@ -381,12 +394,14 @@ def client_add(userid, realm, resource):
|
||||||
bumperlog.info("Adding new client with resource {}".format(newclient.resource))
|
bumperlog.info("Adding new client with resource {}".format(newclient.resource))
|
||||||
client_full_upsert(newclient.asdict())
|
client_full_upsert(newclient.asdict())
|
||||||
|
|
||||||
|
|
||||||
def client_remove(resource):
|
def client_remove(resource):
|
||||||
clients = db_get().table("clients")
|
clients = db_get().table("clients")
|
||||||
client = client_get(resource)
|
client = client_get(resource)
|
||||||
if client:
|
if client:
|
||||||
clients.remove(doc_ids=[client.doc_id])
|
clients.remove(doc_ids=[client.doc_id])
|
||||||
|
|
||||||
|
|
||||||
def client_get(resource):
|
def client_get(resource):
|
||||||
clients = db_get().table("clients")
|
clients = db_get().table("clients")
|
||||||
Client = Query()
|
Client = Query()
|
||||||
|
|
|
||||||
38
bumper/plugins/bumper_confserver_portal_ecms.py
Normal file
38
bumper/plugins/bumper_confserver_portal_ecms.py
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from aiohttp import web
|
||||||
|
|
||||||
|
from bumper import plugins
|
||||||
|
from bumper.models import *
|
||||||
|
|
||||||
|
|
||||||
|
class portal_api_ecms(plugins.ConfServerApp):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.name = "portal_api_ecms"
|
||||||
|
self.plugin_type = "sub_api"
|
||||||
|
self.sub_api = "portal_api"
|
||||||
|
|
||||||
|
self.routes = [
|
||||||
|
web.route("*", "/ecms/app/ad/res", self.handle_ad_res, name="portal_api_ecms_ad_res"),
|
||||||
|
]
|
||||||
|
|
||||||
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
||||||
|
async def handle_ad_res(self, request):
|
||||||
|
try:
|
||||||
|
body = {
|
||||||
|
"code": 0,
|
||||||
|
"data": [],
|
||||||
|
"message": "success",
|
||||||
|
"success": True
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
|
||||||
|
plugin = portal_api_ecms()
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import asyncio
|
|
||||||
from aiohttp import web
|
|
||||||
from bumper import plugins
|
|
||||||
import logging
|
import logging
|
||||||
import bumper
|
|
||||||
from bumper.models import *
|
|
||||||
from bumper import plugins
|
|
||||||
from datetime import datetime, timedelta
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from aiohttp import web
|
||||||
|
|
||||||
|
from bumper import plugins
|
||||||
|
from bumper.models import *
|
||||||
|
|
||||||
|
|
||||||
class portal_api_pim(plugins.ConfServerApp):
|
class portal_api_pim(plugins.ConfServerApp):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
@ -17,13 +16,12 @@ class portal_api_pim(plugins.ConfServerApp):
|
||||||
self.sub_api = "portal_api"
|
self.sub_api = "portal_api"
|
||||||
|
|
||||||
self.routes = [
|
self.routes = [
|
||||||
|
|
||||||
web.route("*", "/pim/product/getProductIotMap", self.handle_getProductIotMap, name="portal_api_pim_getProductIotMap"),
|
web.route("*", "/pim/product/getProductIotMap", self.handle_getProductIotMap, name="portal_api_pim_getProductIotMap"),
|
||||||
web.route("*", "/pim/file/get/{id}", self.handle_pimFile, name="portal_api_pim_file"),
|
web.route("*", "/pim/file/get/{id}", self.handle_pimFile, name="portal_api_pim_file"),
|
||||||
web.route("*", "/pim/product/getConfignetAll", self.handle_getConfignetAll, name="portal_api_pim_getConfignetAll"),
|
web.route("*", "/pim/product/getConfignetAll", self.handle_getConfignetAll, name="portal_api_pim_getConfignetAll"),
|
||||||
web.route("*", "/pim/product/getConfigGroups", self.handle_getConfigGroups, name="portal_api_pim_getConfigGroups"),
|
web.route("*", "/pim/product/getConfigGroups", self.handle_getConfigGroups, name="portal_api_pim_getConfigGroups"),
|
||||||
web.route("*", "/pim/dictionary/getErrDetail", self.handle_getErrDetail, name="portal_api_pim_getErrDetail"),
|
web.route("*", "/pim/dictionary/getErrDetail", self.handle_getErrDetail, name="portal_api_pim_getErrDetail"),
|
||||||
|
web.route("*", "/pim/product/software/config/batch", self.handle_product_config_batch, name="portal_api_pim_product_config_batch"),
|
||||||
]
|
]
|
||||||
|
|
||||||
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
@ -76,6 +74,34 @@ class portal_api_pim(plugins.ConfServerApp):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.exception("{}".format(e))
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
async def handle_product_config_batch(self, request):
|
||||||
|
try:
|
||||||
|
json_body = json.loads(await request.text())
|
||||||
|
data = []
|
||||||
|
for pid in json_body["pids"]:
|
||||||
|
for productConfig in productConfigBatch:
|
||||||
|
if pid == productConfig["pid"]:
|
||||||
|
data.append(productConfig)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# not found in productConfigBatch
|
||||||
|
# some devices don't have any product configuration
|
||||||
|
data.append({
|
||||||
|
"cfg": {},
|
||||||
|
"pid": pid
|
||||||
|
})
|
||||||
|
|
||||||
|
body = {
|
||||||
|
"code": 200,
|
||||||
|
"data": data,
|
||||||
|
"message": "success"
|
||||||
|
}
|
||||||
|
return web.json_response(body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
|
||||||
plugin = portal_api_pim()
|
plugin = portal_api_pim()
|
||||||
|
|
||||||
confignetAllResponse = {
|
confignetAllResponse = {
|
||||||
|
|
@ -2681,3 +2707,174 @@ configGroupsResponse = {
|
||||||
"contactUS": "helper"
|
"contactUS": "helper"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
productConfigBatch = [
|
||||||
|
{
|
||||||
|
"pid": "5e14196a6e71b80001b60fda",
|
||||||
|
"cfg": {
|
||||||
|
"supported": {
|
||||||
|
"tmallstand": False,
|
||||||
|
"video": False,
|
||||||
|
"battery": True,
|
||||||
|
"clean": True,
|
||||||
|
"charge": True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": "5e8e8d8a032edd8457c66bfb",
|
||||||
|
"cfg": {
|
||||||
|
"supported": {
|
||||||
|
"tmallstand": False,
|
||||||
|
"video": False,
|
||||||
|
"battery": True,
|
||||||
|
"clean": True,
|
||||||
|
"charge": True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": "5c19a91ca1e6ee000178224a",
|
||||||
|
"cfg": {
|
||||||
|
"supported": {
|
||||||
|
"tmallstand": False,
|
||||||
|
"video": False,
|
||||||
|
"battery": True,
|
||||||
|
"clean": True,
|
||||||
|
"charge": True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": "5e8e8d2a032edd3c03c66bf7",
|
||||||
|
"cfg": {
|
||||||
|
"supported": {
|
||||||
|
"tmallstand": False,
|
||||||
|
"video": False,
|
||||||
|
"battery": True,
|
||||||
|
"clean": True,
|
||||||
|
"charge": True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": "5de0d86ed88546000195239a",
|
||||||
|
"cfg": {
|
||||||
|
"supported": {
|
||||||
|
"tmallstand": False,
|
||||||
|
"video": True,
|
||||||
|
"battery": True,
|
||||||
|
"clean": True,
|
||||||
|
"charge": True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": "5c19a8f3a1e6ee0001782247",
|
||||||
|
"cfg": {
|
||||||
|
"supported": {
|
||||||
|
"tmallstand": False,
|
||||||
|
"video": False,
|
||||||
|
"battery": True,
|
||||||
|
"clean": True,
|
||||||
|
"charge": True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": "5e698a6306f6de52c264c61b",
|
||||||
|
"cfg": {
|
||||||
|
"supported": {
|
||||||
|
"tmallstand": False,
|
||||||
|
"video": False,
|
||||||
|
"battery": True,
|
||||||
|
"clean": True,
|
||||||
|
"charge": True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": "5e699a4106f6de83ea64c620",
|
||||||
|
"cfg": {
|
||||||
|
"supported": {
|
||||||
|
"tmallstand": False,
|
||||||
|
"video": False,
|
||||||
|
"battery": True,
|
||||||
|
"clean": True,
|
||||||
|
"charge": True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": "5edd998afdd6a30008da039b",
|
||||||
|
"cfg": {
|
||||||
|
"supported": {
|
||||||
|
"tmallstand": False,
|
||||||
|
"video": True,
|
||||||
|
"battery": True,
|
||||||
|
"clean": True,
|
||||||
|
"charge": True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": "5edd9a4075f2fc000636086c",
|
||||||
|
"cfg": {
|
||||||
|
"supported": {
|
||||||
|
"tmallstand": False,
|
||||||
|
"video": True,
|
||||||
|
"battery": True,
|
||||||
|
"clean": True,
|
||||||
|
"charge": True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": "5ed5e4d3a719ea460ec3216c",
|
||||||
|
"cfg": {
|
||||||
|
"supported": {
|
||||||
|
"tmallstand": False,
|
||||||
|
"video": False,
|
||||||
|
"battery": True,
|
||||||
|
"clean": True,
|
||||||
|
"charge": True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": "5f88195e6cf8de0008ed7c11",
|
||||||
|
"cfg": {
|
||||||
|
"supported": {
|
||||||
|
"tmallstand": False,
|
||||||
|
"video": False,
|
||||||
|
"battery": True,
|
||||||
|
"clean": True,
|
||||||
|
"charge": True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": "5f8819156cf8de0008ed7c0d",
|
||||||
|
"cfg": {
|
||||||
|
"supported": {
|
||||||
|
"tmallstand": False,
|
||||||
|
"video": False,
|
||||||
|
"battery": True,
|
||||||
|
"clean": True,
|
||||||
|
"charge": True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": "5fa105c6d16a99000667eb54",
|
||||||
|
"cfg": {
|
||||||
|
"supported": {
|
||||||
|
"tmallstand": False,
|
||||||
|
"video": False,
|
||||||
|
"battery": True,
|
||||||
|
"clean": True,
|
||||||
|
"charge": True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue