from flask import Blueprint, Response
from app.core.response import build_response
from app.core.security import require_jwt
from app.services.hub_services.layout import get_layout_service


hub_layout_routes = Blueprint('hub_layout_routes', __name__)


# Retrieves a layout model of a certain type according to the model name
@hub_layout_routes.route(
    '/get_layout/<string:type>/<string:model_name>/',
    methods=['GET'])
@require_jwt()
def get_layout(type: str, model_name: str) -> Response:
    response, status_codes = get_layout_service(
        type=type, model_name=model_name)
    return build_response(
        data=response,
        status_codes=status_codes
    )
