Exemplo n.º 1
0
    def delete(self):
        """ delete group """
        cust_id = aaa_verify()
        group_id_list = request.json.get("user_groups")

        response_delete_groups(cust_id, group_id_list)
        return ret.http_resp(ret.RET_OK), status.HTTP_200_OK
 def get(self):
     """ give User list """
     cust_id = aaa_verify()
     response = response_getall(cust_id)
     if not response:
         raise NotFound(ret.http_resp(ret.RET_NOT_FOUND))
     return ret.http_resp(ret.RET_OK, extra=response), status.HTTP_200_OK
    def get(self):
        """ get all device groups """
        cust_id = aaa_verify()
        response = response_getallsummary(cust_id)
        if not response:
            raise NotFound(ret.http_resp(ret.RET_NOT_FOUND))

        return ret.http_resp(ret.RET_OK, extra=response), status.HTTP_200_OK
 def post(self):
     """ get detail device """
     cust_id = aaa_verify()
     device_list = request.json.get("devices")
     response = response_get_detail(cust_id, device_list)
     if not response:
         raise NotFound(ret.http_resp(ret.RET_NOT_FOUND))
     return ret.http_resp(ret.RET_OK, extra=response), status.HTTP_200_OK
 def post(self):
     """ add User """
     cust_id = aaa_verify()
     payload = request.json
     response = response_add(cust_id, payload)
     if not response:
         raise NotFound(ret.http_resp(ret.RET_NOT_FOUND))
     return ret.http_resp(ret.RET_OK, extra=response), status.HTTP_200_OK
    def put(self):
        """update the selected groups """
        cust_id = aaa_verify()

        renamed_items = [(rename.get("id"), rename.get("name"), rename.get("display_name"))
                         for rename in request.json.get("device_groups")]
        response_update_groups(cust_id, renamed_items)
        return ret.http_resp(ret.RET_OK), status.HTTP_200_OK
 def post(self):
     """ give User list """
     cust_id = aaa_verify()
     user_list = request.json.get("users")
     response = response_get_detail(cust_id, user_list)
     if not response:
         raise NotFound(ret.http_resp(ret.RET_NOT_FOUND))
     return ret.http_resp(ret.RET_OK, extra=response), status.HTTP_200_OK
Exemplo n.º 8
0
 def post(self):
     """ add group """
     cust_id = aaa_verify()
     data = request.json
     response = response_add_groups(cust_id, data)
     if not response:
         raise NotFound(ret.http_resp(ret.RET_NOT_FOUND))
     return ret.http_resp(ret.RET_OK,
                          extra=response), status.HTTP_201_CREATED
    def post(self):
        """ show device group detail """
        cust_id = aaa_verify()
        data = request.json
        device_groups_list = data.get("device_groups")
        response = response_getdetail(cust_id, device_groups_list)
        if not response:
            raise NotFound(ret.http_resp(ret.RET_NOT_FOUND))

        return ret.http_resp(ret.RET_OK, extra=response), status.HTTP_200_OK
    def post(self):
        """ add group """
        cust_id = aaa_verify()
        data = request.json

        add_groups = [(group.get("name"), group.get("display_name")) for group in data.get("device_groups")]
        response = response_add_groups(add_groups, cust_id)

        if not response:
            raise NotFound(ret.http_resp(ret.RET_NOT_FOUND))
        return ret.http_resp(ret.RET_OK, extra=response), status.HTTP_201_CREATED
    def post(self):
        """ give User device list """
        cust_id = aaa_verify()
        payload = request.json
        user_name, device_number = get_cust_user_device(payload)

        # using redis to enhance efficiency
        namespace = f"traffic_light:device:getall:{cust_id}"
        cache = redis_general_get(namespace)
        if not cache:
            data = getall_devicelist_for_geojson(cust_id, user_name,
                                                 device_number)
            response = get_geojson_from_sql_results(data)
            logger.info(f"cache not found, query from database...")
            redis_general_add(namespace, response)
        else:
            logger.info(f"get all devices using cache: {namespace}")
            response = cache

        if not response:
            raise NotFound(ret.http_resp(ret.RET_NOT_FOUND))

        return ret.http_resp(ret.RET_OK, extra=response), status.HTTP_200_OK
 def delete(self):
     """ Delete User """
     cust_id = aaa_verify()
     user_list = request.json.get("users")
     response_delete(cust_id, user_list)
     return ret.http_resp(ret.RET_OK), status.HTTP_200_OK
 def delete(self):
     """ delete device """
     cust_id = aaa_verify()
     response_delete_devices(cust_id, request.json.get("devices"))
     return ret.http_resp(ret.RET_OK), status.HTTP_200_OK
 def put(self):
     """ update device """
     cust_id = aaa_verify()
     payload = request.json
     response_update(cust_id, payload)
     return ret.http_resp(ret.RET_OK), status.HTTP_200_OK
Exemplo n.º 15
0
 def put(self, user_group_id):
     """ join schedule groups """
     cust_id = aaa_verify()
     payload = request.json
     response_leave_users(cust_id, user_group_id, payload)
     return ret.http_resp(ret.RET_OK), status.HTTP_200_OK
 def put(self, group_id):
     """remove user groups from selected device group """
     cust_id = aaa_verify()
     response_leave_usergroups(cust_id, group_id, request.json.get("user_groups"))
     return ret.http_resp(ret.RET_OK), status.HTTP_200_OK
 def put(self, group_id):
     """put device(s) into selected group """
     cust_id = aaa_verify()
     response_join_groups(cust_id, group_id, request.json.get("devices"))
     return ret.http_resp(ret.RET_OK), status.HTTP_200_OK