def group_exist(): data = json.loads(request.data.decode("utf-8")) required_fields = ["group_id"] missing_fields = get_missing_fields(required_fields, data) if missing_fields: return api_result("Fields %s are missing" % missing_fields, True) group_existing = base.is_group_exist(data["group_id"]) return api_result(group_existing, False)
def edit_token(): data = json.loads(request.data.decode("utf-8")) required_fields = ["group_id", "access_token"] missing_fields = get_missing_fields(required_fields, data) if missing_fields: return api_result("Fields %s are missing" % missing_fields, True) result, code = base.edit_token(data["group_id"], data["access_token"]) if not code: return api_result(result, True) return api_result("", False)
def activate_service(): data = json.loads(request.data.decode("utf-8")) required_fields = ["group_id", "service_id", "activation"] missing_fields = get_missing_fields(required_fields, data) if missing_fields: return api_result("Fields %s are missing" % missing_fields, True) result, code = services.activate_service(data["group_id"], data["service_id"], data["activation"]) if not code: return api_result(result, True) return api_result("ok", False)
def delete_varible(): data = json.loads(request.data.decode("utf-8")) required_fields = ["secret_key", "group_id", "varible_name"] missing_fields = get_missing_fields(required_fields, data) if missing_fields: return api_result("Fields %s are missing" % missing_fields, True) if SECRET_SERVICE_KEY != data["secret_key"]: return api_result("Incorrect secret key", True) result, code = base.delete_varible(data["group_id"], data["varible_name"]) if not code: return api_result(result, True) return api_result("ok", False)
def update_image(): data = json.loads(request.data.decode("utf-8")) required_fields = ["secret_key", "group_id"] missing_fields = get_missing_fields(required_fields, data) if missing_fields: return api_result("Fields %s are missing" % missing_fields, True) if SECRET_SERVICE_KEY != data["secret_key"]: return api_result("Incorrect secret key", True) thread = threading.Thread(target=update_cover_image, args=(data["group_id"], )) thread.daemon = True thread.start() return api_result("ok", False)
def update_cover(): data = json.loads(request.data.decode("utf-8")) required_fields = ["group_id", "resources", "views"] missing_fields = get_missing_fields(required_fields, data) if missing_fields: return api_result("Fields %s are missing" % missing_fields, True) result, code = base.set_cover(data["group_id"], data["views"], data["resources"]) if not code: return api_result(result, True) thread = threading.Thread(target=update_cover_image, args=(data["group_id"], )) thread.daemon = True thread.start() return api_result("", False)