Example #1
0
    def set_app_apikey(self, application, app_id):
        apikey = self.get_unused_apikey()

        application.apikey = apikey
        Application.save(application)

        return Application.get(app_id)
Example #2
0
    def applications_POST(self):
        """ Create new application with POST method """
        req_app = self.request.swagger_data['application']
        app = Application(
            name=req_app.name,
            apikey=self.get_unused_apikey(),
            experiment_distribution=req_app.experiment_distribution)
        if self.is_valid_application(req_app):
            Application.save(app)
            print_log(req_app.name, 'POST', '/applications',
                      'Create new application', app)
            return app.as_dict()

        print_log(req_app.name, 'POST', '/applications',
                  'Create new application', 'Failed: Invalid Application')
        return self.createResponse('Bad Request: invalid Application', 400)