Ejemplo n.º 1
0
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
    """Return a configured Flask App using the Factory method."""
    app = Flask(__name__)
    app.config.from_object(config.CONFIGURATION[run_mode])

    from pay_api.resources import API_BLUEPRINT, OPS_BLUEPRINT

    db.init_app(app)
    ma.init_app(app)

    app.register_blueprint(API_BLUEPRINT)
    app.register_blueprint(OPS_BLUEPRINT)
    app.after_request(convert_to_camel)

    setup_jwt_manager(app, jwt)

    ExceptionHandler(app)

    @app.after_request
    def add_version(response):  # pylint: disable=unused-variable
        version = get_run_version()
        response.headers['API'] = f'pay_api/{version}'
        return response

    register_shellcontext(app)

    return app
Ejemplo n.º 2
0
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
    """Return a configured Flask App using the Factory method."""
    app = Flask(__name__, template_folder='templates')
    app.config.from_object(CONFIGURATION[run_mode])

    # Configure Sentry
    if str(app.config.get('SENTRY_ENABLE')).lower() == 'true':
        if app.config.get('SENTRY_DSN', None):
            sentry_sdk.init(
                dsn=app.config.get('SENTRY_DSN'),
                integrations=[FlaskIntegration()]
            )

    from status_api.resources import API_BLUEPRINT, OPS_BLUEPRINT  # pylint: disable=import-outside-toplevel

    app.register_blueprint(API_BLUEPRINT)
    app.register_blueprint(OPS_BLUEPRINT)
    app.after_request(convert_to_camel)

    ExceptionHandler(app)

    @app.after_request
    def add_version(response):  # pylint: disable=unused-variable
        version = get_run_version()
        response.headers['API'] = f'status_api/{version}'
        return response

    register_shellcontext(app)

    return app
Ejemplo n.º 3
0
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
    """Return a configured Flask App using the Factory method."""
    app = Flask(__name__)
    app.config.from_object(config.CONFIGURATION[run_mode])  # pylint: disable=no-member

    # Configure Sentry
    if app.config.get('SENTRY_DSN', None):
        sentry_sdk.init(dsn=app.config.get('SENTRY_DSN'),
                        integrations=[FlaskIntegration()])

    from api.resources import API_BLUEPRINT, OPS_BLUEPRINT  # pylint: disable=import-outside-toplevel

    app.register_blueprint(API_BLUEPRINT)
    app.register_blueprint(OPS_BLUEPRINT)

    setup_jwt_manager(app, jwt)

    ExceptionHandler(app)

    @app.after_request
    def add_version(response):  # pylint:  disable=unused-variable
        version = get_run_version()
        response.headers['API'] = f'report_api/{version}'
        return response

    register_shellcontext(app)

    return app
Ejemplo n.º 4
0
def create_app(run_mode=os.getenv('FLASK_ENV', 'development')):
    """Return a configured Flask App using the Factory method."""   
 
    app.config.from_object(config.CONFIGURATION[run_mode])

    from request_api.resources import API_BLUEPRINT #, DEFAULT_API_BLUEPRINT #, OPS_BLUEPRINT  # pylint: disable=import-outside-toplevel

    print("environment :" + run_mode)
    
    CORS(app, supports_credentials=True)
    db.init_app(app)
    ma.init_app(app)

    app.register_blueprint(API_BLUEPRINT)

    if os.getenv('FLASK_ENV', 'production') != 'testing':
        print("JWTSET DONE!!!!!!!!!!!!!!!!")
        setup_jwt_manager(app, jwt)

    ExceptionHandler(app)


    register_shellcontext(app)
    
    return app
Ejemplo n.º 5
0
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
    """Return a configured Flask App using the Factory method."""
    app = Flask(__name__)
    app.config.from_object(config.CONFIGURATION[run_mode])

    db.init_app(app)
    ma.init_app(app)

    if run_mode != 'migration':

        # Configure Sentry
        if app.config.get('SENTRY_DSN', None):  # pragma: no cover
            sentry_sdk.init(  # pylint: disable=abstract-class-instantiated
                dsn=app.config.get('SENTRY_DSN'),
                integrations=[FlaskIntegration()])
        # pylint: disable=import-outside-toplevel
        from pay_api.resources import API_BLUEPRINT, OPS_BLUEPRINT

        app.register_blueprint(API_BLUEPRINT)
        app.register_blueprint(OPS_BLUEPRINT)
        app.after_request(convert_to_camel)

        setup_jwt_manager(app, jwt)

        ExceptionHandler(app)

        @app.after_request
        def add_version(response):  # pylint: disable=unused-variable
            version = get_run_version()
            response.headers['API'] = f'pay_api/{version}'
            return response

        register_shellcontext(app)
        build_cache(app)
    return app
Ejemplo n.º 6
0
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
    """Return a configured Flask App using the Factory method."""
    app = Flask(__name__)
    app.config.from_object(config.CONFIGURATION[run_mode])

    # Configure Sentry
    if str(app.config.get('SENTRY_ENABLE')).lower() == 'true':
        if app.config.get('SENTRY_DSN', None):
            sentry_sdk.init(  # pylint: disable=abstract-class-instantiated
                dsn=app.config.get('SENTRY_DSN'),
                integrations=[FlaskIntegration()])

    from auth_api.resources import TEST_BLUEPRINT  # pylint: disable=import-outside-toplevel
    from auth_api.resources import API_BLUEPRINT, OPS_BLUEPRINT  # pylint: disable=import-outside-toplevel

    db.init_app(app)
    ma.init_app(app)
    mail.init_app(app)

    app.register_blueprint(API_BLUEPRINT)
    app.register_blueprint(OPS_BLUEPRINT)

    if os.getenv('FLASK_ENV', 'production') in ['development', 'testing']:
        app.register_blueprint(TEST_BLUEPRINT)

    if os.getenv('FLASK_ENV', 'production') != 'testing':
        setup_jwt_manager(app, jwt)

    ExceptionHandler(app)

    @app.before_request
    def set_origin():
        g.origin_url = request.environ.get('HTTP_ORIGIN', 'localhost')

    @app.after_request
    def handle_after_request(response):  # pylint: disable=unused-variable
        add_version(response)
        camelize_json(response)
        return response

    def add_version(response):
        version = get_run_version()
        response.headers['API'] = f'auth_api/{version}'

    def camelize_json(response):
        if (response.headers['Content-Type'] == 'application/json'
                and 'swagger.json' not in request.base_url):
            response.set_data(
                json.dumps(camelize(json.loads(response.get_data()))))

    register_shellcontext(app)
    build_cache(app)

    return app
Ejemplo n.º 7
0
def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
    """Return a configured Flask App using the Factory method."""
    app = Flask(__name__)
    app.config.from_object(config.CONFIGURATION[run_mode])

    # Configure Sentry
    if app.config.get('SENTRY_DSN', None):
        sentry_sdk.init(
            dsn=app.config.get('SENTRY_DSN'),
            integrations=[FlaskIntegration()]
        )

    from auth_api.resources import API_BLUEPRINT, OPS_BLUEPRINT, \
        TEST_BLUEPRINT  # pylint: disable=import-outside-toplevel

    db.init_app(app)
    ma.init_app(app)
    mail.init_app(app)

    app.register_blueprint(API_BLUEPRINT)
    app.register_blueprint(OPS_BLUEPRINT)

    if os.getenv('FLASK_ENV', 'production') in ['development', 'testing']:
        app.register_blueprint(TEST_BLUEPRINT)

    if os.getenv('FLASK_ENV', 'production') != 'testing':
        setup_jwt_manager(app, JWT)

    ExceptionHandler(app)

    @app.after_request
    def handle_after_request(response):  # pylint: disable=unused-variable
        add_version(response)
        camelize_json(response)
        return response

    def add_version(response):
        version = get_run_version()
        response.headers['API'] = f'auth_api/{version}'

    def camelize_json(response):
        if response.headers['Content-Type'] == 'application/json':
            response.set_data(json.dumps(camelize(json.loads(response.get_data()))))

    register_shellcontext(app)
    build_cache(app)

    return app
Ejemplo n.º 8
0
API_OPS = Api(
    OPS_BLUEPRINT,
    title='Service OPS API',
    version='1.0',
    description='The Core API for the Authentication System',
    security=['apikey'],
    authorizations=AUTHORIZATIONS,
)

API_OPS.add_namespace(OPS_API, path='/')

API_BLUEPRINT = Blueprint('API', __name__, url_prefix='/api/v1')

API = Api(
    API_BLUEPRINT,
    title='Authentication API',
    version='1.0',
    description='The Core API for the Authentication System',
    security=['apikey'],
    authorizations=AUTHORIZATIONS,
)

HANDLER = ExceptionHandler(API)

API.add_namespace(META_API, path='/meta')
API.add_namespace(TOKEN_API, path='/token')
API.add_namespace(USER_API, path='/users')
API.add_namespace(LOGOUT_API, path='/logout')
API.add_namespace(ENTITY_API, path='/entities')
API.add_namespace(ORG_API, path='/orgs')
Ejemplo n.º 9
0
)

API_OPS.add_namespace(OPS_API, path='/')

API_BLUEPRINT = Blueprint('API', __name__, url_prefix='/api/v1')

API = Api(
    API_BLUEPRINT,
    title='Authentication API',
    version='1.0',
    description='The Core API for the Authentication System',
    security=['apikey'],
    authorizations=AUTHORIZATIONS,
)

HANDLER = ExceptionHandler(API)

API.add_namespace(META_API, path='/meta')
API.add_namespace(TOKEN_API, path='/token')
API.add_namespace(USER_API, path='/users')
API.add_namespace(BULK_USER_API, path='/bulk/users')
API.add_namespace(USER_SETTINGS_API, path='/users/<string:user_id>/settings')
API.add_namespace(ENTITY_API, path='/entities')
API.add_namespace(ORG_API, path='/orgs')
API.add_namespace(INVITATION_API, path='/invitations')
API.add_namespace(DOCUMENTS_API, path='/documents')
API.add_namespace(CODES_API, path='/codes')
API.add_namespace(ACCOUNTS_API, path='/accounts')
API.add_namespace(ORG_PRODUCTS_API, path='/orgs/<string:org_id>/products')
API.add_namespace(PRODUCTS_API, path='/products')
API.add_namespace(