def batch_delete_entities_post(): json_input_data = json.loads(request.data) entity_ids = json_input_data["data"] try: batch_delete_entities(entity_ids) # Since reponse is an operation/ future object we don't really have # anything to return here. return util.create_success_response("Batch deleted entities.") except google_exceptions.FailedPrecondition as e: raise InvalidDialogFlowID(str(e), status_code=400)
def batch_create_entities_post(): json_input_data = json.loads(request.data) entity_types = json_input_data["data"] try: ID_list = batch_create_entities(entity_types) return util.create_success_response("Batch created entities.", data=ID_list) except google_exceptions.FailedPrecondition as e: # Entity with same name exception. raise InvalidDialogFlowID(str(e), status_code=400)
def batch_create_intents_post(): json_input_data = json.loads(request.data) intents = json_input_data["data"] try: # Since response from batch_create_intents is an operation/ future # object we don't really have anything to return here. So just a # simple counter, so atleast we know how many intents we created. counter = batch_create_intents(intents) return util.create_success_response("Batch created " + str(counter) + " intents.") except google_exceptions.FailedPrecondition as e: # Intent with same name exception. raise InvalidDialogFlowID(str(e), status_code=400)
def create_intent_post(): json_input_data = json.loads(request.data) try: intent_name = json_input_data["intent_name"] except KeyError: return "Could not find intent_name" try: training_phrases = json_input_data["training_phrases"] except KeyError: training_phrases = [] try: intent = create_intent(intent_name, training_phrases) return util.create_success_response("Intent created", data=intent.name) except google_exceptions.FailedPrecondition as e: # Intent with same name exception. raise InvalidDialogFlowID(str(e), status_code=400)