def get_resource(session=None, exception_when_missing=True, **kwargs): """ :param session: :param exception_when_missing: raise exception when missing :return:get field of the resource """ return utils.get_db_object( session, Resource, exception_when_missing, **kwargs)
def get_resource(session=None, exception_when_missing=True, **kwargs): """ :param session: :param exception_when_missing: raise exception when missing :return:get field of the resource """ return utils.get_db_object(session, Resource, exception_when_missing, **kwargs)
def _get_gateway(session, gateway_id, exception_when_missing=True): return utils.get_db_object(session, Gateway, exception_when_missing=exception_when_missing, id=gateway_id)
def _update_resource(session, resource_id, **kwargs): res = utils.get_db_object(session, Resource, id=resource_id) return utils.update_db_object(session, res, **kwargs)
def _user_gateway(session, user_name, exception_when_missing=True): return utils.get_db_object(session, User, exception_when_missing=exception_when_missing, username=user_name)
def delete_user(session, username, **kwargs): user = utils.get_db_object(session, User, exception_when_missing=False, username=username) return utils.del_db_object(session, user)
def get_sensor_group(session, sg_id): return utils.get_db_object(session, SensorGroup, id=sg_id)
def get_gateway_model(session, gateway_id, exception_when_missing=False): return utils.get_db_object(session, GatewayModel, exception_when_missing=exception_when_missing, gateway_id=gateway_id)