in lex/__init__.py [0:0]
def upsert(self, intent):
args = {}
for l in intent.keys():
args[l] = intent[l]
if 'slots' in intent.keys():
for i in intent['slots']:
if 'slotTypeVersion' in i.keys() and \
i['slotTypeVersion'] == '$LATEST':
print 'Getting slot versions for ' + i['name']
slots = self.client.get_slot_type_versions(
name=i['slotType'], maxResults=50)['slotTypes']
if len(slots) > 0:
latestVersion = slots[len(slots)-1]['version']
print 'Latest slot version = {}' \
.format(latestVersion)
i['slotTypeVersion'] = latestVersion
print 'Upserting intent: {}'.format(intent['name'])
current_intent = self.get_intent(
intent['name'],
'$LATEST'
)
if current_intent:
args['checksum'] = current_intent['checksum']
return self.client.put_intent(**args)