from aiohttp import web from server.dna.views import ( get_list_user_search, get_user_search, save_user_search, update_user_search, user_search_archived, user_search_delete, get_profile_info, profile_reset, get_label_profiles, get_list_labels_with_profiles, get_list_recent_searches, create_recent_search, list_favorites, add_entity_to_account_favorites, delete_entity_from_account_favorites, genres_list, countries_list, ) from server.dna.category.views import ( get_categories, get_category, create_category, update_category, delete_category, get_category_entities, create_category_entities, delete_category_entities, get_artist_categories, ) URL_PREFIX: str = "/api/dna" def init_routes(app: web.Application) -> None: app.add_routes( [ web.get( URL_PREFIX + r"/user_searches", get_list_user_search, name="get_list_user_search", allow_head=False ), web.get( URL_PREFIX + r"/user_searches/{id:\d+}", get_user_search, name="get_user_search", allow_head=False, ), web.post(URL_PREFIX + r"/user_searches", save_user_search, name="save_user_search"), web.put(URL_PREFIX + r"/user_searches/{id:\d+}", update_user_search, name="update_user_search"), web.patch( URL_PREFIX + r"/user_searches/{id:\d+}/archived", user_search_archived, name="user_search_archived", ), web.delete(URL_PREFIX + r"/user_searches/{id:\d+}", user_search_delete, name="user_search_delete"), web.get(URL_PREFIX + r"/profile/info", get_profile_info, name="profile_info", allow_head=False), web.patch(URL_PREFIX + r"/profile/reset", profile_reset, name="profile_reset"), web.get( URL_PREFIX + r"/profile/labels", get_list_labels_with_profiles, name="get_list_labels_with_profiles", allow_head=False, ), web.get( URL_PREFIX + r"/profile/labels/{id:\d+}", get_label_profiles, name="get_label_profiles", allow_head=False, ), # categories: web.get(URL_PREFIX + r"/categories", get_categories, name="get_categories", allow_head=False), web.get(URL_PREFIX + r"/categories/{id:\d+}", get_category, name="get_category", allow_head=False), web.post(URL_PREFIX + r"/categories", create_category, name="create_category"), web.put(URL_PREFIX + r"/categories/{id:\d+}", update_category, name="update_category"), web.delete(URL_PREFIX + r"/categories/{id:\d+}", delete_category, name="delete_category"), # category entities: web.get( URL_PREFIX + r"/categories/{id:\d+}/entities", get_category_entities, name="get_category_entities", allow_head=False, ), web.get( URL_PREFIX + r"/categories/{entity_type}", get_artist_categories, name="get_artist_categories", allow_head=False, ), web.post( URL_PREFIX + r"/categories/{id:\d+}/entities", create_category_entities, name="create_category_entities" ), web.delete( URL_PREFIX + r"/categories/{id:\d+}/entities/{entity_id:\d+}", delete_category_entities, name="delete_category_entities", ), web.get( URL_PREFIX + r"/recent_searches", get_list_recent_searches, name="get_list_recent_searches", ), web.post( URL_PREFIX + r"/recent_searches", create_recent_search, name="create_recent_search", ), web.get( URL_PREFIX + r"/favorites/{entity_type}", list_favorites, name="get_list_favorites", ), web.put( URL_PREFIX + r"/favorites/{entity_type}/{entity_id}", add_entity_to_account_favorites, name="add_an_entity_to_account_favorites", ), web.delete( URL_PREFIX + r"/favorites/{entity_type}/{entity_id}", delete_entity_from_account_favorites, name="delete_an_entity_from_account_favorites", ), web.get( URL_PREFIX + r"/genres", genres_list, name="genres_list", ), web.get( URL_PREFIX + r"/countries", countries_list, name="countries_list", ), ] )