def upsert()

in lex/__init__.py [0:0]


    def upsert(self, bot):
        args = {}
        for l in bot.keys():
            args[l] = bot[l]
        for i in bot['intents']:
            if i['intentVersion'] == '$LATEST':
                print i['intentVersion']
                intents = self.client.get_intent_versions(
                    name=i['intentName'], maxResults=50)['intents']
                if len(intents) > 0:
                    latestVersion = intents[len(intents)-1]['version']
                    print 'Latest intent version = {}'.format(latestVersion)
                    i['intentVersion'] = latestVersion
        print 'Creating bot: {}'.format(bot['name'])
        current_bot = self.get_bot(
            Name=bot['name']
        )
        if current_bot:
            args['checksum'] = current_bot['checksum']
        resp = self.client.put_bot(**args)
        while resp['status'] == 'BUILDING':
            print 'Bot is building . . .'
            time.sleep(10)
            resp = self.get_bot(Name=bot['name'])
        print 'Status: {}'.format(resp['status'])
        if resp['status'] == 'FAILED':
            pprint.pprint(resp)
        return resp['status'], bot