from airbot.model.botitem import Item from grapher import App from genid import ID from airbot import errors from factory import base_factory, list_children_factory import pprint base_factory(objecttype="account", parentobjecttype=None, parentidentitifier=None, identifier="accountid") list_children_factory(parentobjecttype="account", chilobjecttype="bot", childobjectpluralized="bots") list_children_factory(parentobjecttype="account", chilobjecttype="user", childobjectpluralized="users") @App.field("createAccount", path="Mutation/createAccount", argmap={"/arguments/identity": "identity"}) def create_account(identity): accountid = ID.now() uri = "uri:account:" + accountid candidates = [c for c in Item.query("account", Item.creator == identity)] if len(candidates): raise errors.DuplicateError("You already created an airbot account ") account = Item(parent="service",
import json from airbot.model.botitem import Item from grapher import App from genid import ID from airbot import errors from factory import base_factory, list_children_factory, apply_options,merge_doc import pprint from airbot.model.botitem import Item from datetime import datetime base_factory(objecttype="bot",parentobjecttype="account",parentidentitifier="accountid",identifier="botid") list_children_factory(parentobjecttype="bot", chilobjecttype="entity", childobjectpluralized="entities") list_children_factory(parentobjecttype="bot", chilobjecttype="intent", childobjectpluralized="intents") from lex import Bot from airbot.athena.query import AthenaQuery from entity import ENTITYSTATES from airbot.glue.crawler import Crawler import random from airbot.cube.entity import Cube @App.field( field = "listEntities", path = "Bot/entities", argmap={ "/arguments/identity" : "identity", "/source/ID" : "uri", "/arguments/options" : "options" } ) def listIdentities(uri, identity, options): bot = Item.get("bot", uri)
import unicodedata from airbot.model.botitem import Item from grapher import App from genid import ID from airbot import errors import pprint from factory import base_factory, list_children_factory from airbot import errors import json from genid import ID base_factory(objecttype="variable", parentobjecttype="entity", parentidentitifier="entityid", identifier="variableid") from unidecode import unidecode from airbot.athena.query import AthenaQuery from entity import ENTITYSTATES from airbot.logger import logger import types @App.field(field="deleteVariable", path="Mutation/deleteVariable", argmap={ "/arguments/variableid": "variableid", "/arguments/identity": "identity" }) def deleteVariable(identity, variableid): try: v = Item.get("variable", variableid) v.delete()