from artists.schemas import label_artist_response from auth.auth_view import RegisteredAuthorizedView from artists.services.artists_service import ArtistsService from flask_apispec import marshal_with, doc from services.users_repository import UsersRepository from utils.exceptions import NotFound @doc(tags=['LabelArtists']) class LabelArtistsView(RegisteredAuthorizedView): artists_service = ArtistsService() users_repository = UsersRepository() @doc(description='Retrieve all artist for specific label.') @marshal_with( label_artist_response(many=True), code=200, description='List with artists for specific label.' ) @marshal_with(schema=None, code=403, description='User does not have access to the label.') @marshal_with(schema=None, code=401, description='User is not authenticated.') def get(self, label_id): if not self.users_repository.is_label_exists(label_id): raise NotFound(f"Label with id {label_id} not exist.") self.permissions.can_access_label(label_id) return self.artists_service.get_label_artists(label_id)