Пример #1
0
 def mutate(self, info, action="PUT", options=None):
     if action == "PUT":
         StoreProxy.store().Entity.put(options)
     elif action == "DELETE":
         StoreProxy.store().Entity.delete(options["id"])
     else:
         raise Exception("Unsupported mutation action")
     entity = Entity(**options)
     return EntityMutation(entity=entity)
Пример #2
0
 def mutate(self, info, action="PUT", options=None):
     if action == "PUT":
         StoreProxy.store().Bot.put(options)
     elif action == "DELETE":
         StoreProxy.store().Bot.delete(options["id"])
     else:
         raise Exception("Unsupported mutation action")
     bot = Bot(**options)
     return BotMutation(bot=bot)
Пример #3
0
 def mutate(self, info, action="PUT", options=None):
     if action == "PUT":
         StoreProxy.store().Rule.put(options)
     elif action == "DELETE":
         StoreProxy.store().Rule.delete(options["id"])
     else:
         raise Exception("Unsupported mutation action")
     rule = Rule(**options)
     return RuleMutation(rule=rule)
Пример #4
0
 def mutate(self, info, action="PUT", options=None):
     if action == "PUT":
         StoreProxy.store().Intent.put(options)
     elif action == "DELETE":
         StoreProxy.store().Intent.delete(options["id"])
     else:
         raise Exception("Unsupported mutation action")
     intent = Intent(**options)
     return IntentMutation(intent=intent)
Пример #5
0
 def resolve_bot(self, info, id):
     try:
         bot = StoreProxy.store().Bot.findById(id=id)
         return Bot(**bot)
     except Exception, e:
         print "e = ", e
         return Bot(**{})
Пример #6
0
 def resolve_entities(self, *args, **kwargs):
     return [
         Entity(**e)
         for e in StoreProxy.store().Bot.get_bot_entities(id=self.id)
     ]
Пример #7
0
 def resolve_intents(self, *args, **kwargs):
     return [
         Intent(**i)
         for i in StoreProxy.store().Bot.get_bot_intents(id=self.id)
     ]
Пример #8
0
 def resolve_variables(self, *args, **kwargs):
     variables = [
         Variable(**v)
         for v in StoreProxy.store().Entity.get_entity_variables(id=self.id)
     ]
     return variables
Пример #9
0
 def resolve_rules(self, *args, **kwargs):
     return [
         Rule(**v)
         for v in StoreProxy.store().Intent.get_intent_rules(id=self.id)
     ]
Пример #10
0
 def store(cls, store=None):
     return StoreProxy.store()
Пример #11
0
 def resolve_rules(self, info, intentid, offset=None, limit=None):
     return [Rule(**r) for r  in StoreProxy.store().Rule.findByParent(parentid=intentid)]
Пример #12
0
 def resolve_variables(self, info, entityid, offset=None, limit=None):
     return [Variable(**v) for v in StoreProxy.store().Variable.findByParent(parentid=entityid)]
Пример #13
0
 def resolve_intent(self, *args, **kwargs):
     return Intent(**StoreProxy.store().Intent.findById(id=kwargs["id"]))
Пример #14
0
 def resolve_entity(self, *args, **kwargs):
     return Entity(**StoreProxy.store().Entity.findById(id=kwargs["id"]))
Пример #15
0
        return [Variable(**v) for v in StoreProxy.store().Variable.findByParent(parentid=entityid)]

    def resolve_rules(self, info, intentid, offset=None, limit=None):
        return [Rule(**r) for r  in StoreProxy.store().Rule.findByParent(parentid=intentid)]

    def resolve_rule(self, *args, **kwargs):
        return Rule(**Query.store().Rule.findById(id=kwargs["id"]))

    def resolve_bots(self, info, offset=0, size=10):
        return [Bot(**b) for b in Query.store().Bot.list(offset=offset, size=size)]


if __name__ == "__main__":
    from server.databot.model.models import Models

    StoreProxy.store(Models)
    schema = graphene.Schema(query=Query)
    r = schema.execute("""
            {
            rules(intentid:"qnxarmz") {
                    parent,
                    id,
                    name,
                    description,
                    replacements
            }
            
        }
    """)
    print r.errors
    print r.data
Пример #16
0
 def resolve_bot(self):
     return Bot(**StoreProxy.store().Bot.findById(id=self.parent))