syntax = "proto3";

package music;

option go_package = "github.com/echofi-ai/schema/v2/types/music";

import "music/artist.proto";
import "music/album.proto";
import "music/track.proto";
import "music/genre.proto";
import "music/playlist.proto";

// MusicService defines the gRPC service for music operations
service MusicService {
  // GetArtist retrieves an artist by ID
  rpc GetArtist(GetArtistRequest) returns (GetArtistResponse) {}
  
  // ListArtists retrieves artists with pagination
  rpc ListArtists(ListArtistsRequest) returns (ListArtistsResponse) {}
  
  // GetAlbum retrieves an album by ID
  rpc GetAlbum(GetAlbumRequest) returns (GetAlbumResponse) {}
  
  // ListAlbums retrieves albums with pagination
  rpc ListAlbums(ListAlbumsRequest) returns (ListAlbumsResponse) {}
  
  // GetTrack retrieves a track by ID
  rpc GetTrack(GetTrackRequest) returns (GetTrackResponse) {}
  
  // ListTracks retrieves tracks with pagination
  rpc ListTracks(ListTracksRequest) returns (ListTracksResponse) {}
  
  // GetGenre retrieves a genre by ID
  rpc GetGenre(GetGenreRequest) returns (GetGenreResponse) {}

  // ListGenres retrieves genres with pagination
  rpc ListGenres(ListGenresRequest) returns (ListGenresResponse) {}

  // GetPlaylist retrieves a playlist by ID
  rpc GetPlaylist(GetPlaylistRequest) returns (GetPlaylistResponse) {}

  // ListPlaylists retrieves playlists with pagination
  rpc ListPlaylists(ListPlaylistsRequest) returns (ListPlaylistsResponse) {}

  // GetUserPlaylists retrieves playlists of authenticated user with pagination
  rpc GetUserPlaylists(GetUserPlaylistsRequest) returns (GetUserPlaylistsResponse) {}

  // GetPublicPlaylists retrieves public playlists with pagination
  rpc GetPublicPlaylists(GetPublicPlaylistsRequest) returns (GetPublicPlaylistsResponse) {}

  // ListPlaylistTracks retrieves tracks in a playlist with pagination
  rpc ListPlaylistTracks(ListPlaylistTracksRequest) returns (ListPlaylistTracksResponse) {}

  // GetPlaylistTracks retrieves tracks in a playlist (authenticated)
  rpc GetPlaylistTracks(GetPlaylistTracksRequest) returns (GetPlaylistTracksResponse) {}

  // CreatePlaylist creates a new playlist (authenticated)
  rpc CreatePlaylist(CreatePlaylistRequest) returns (CreatePlaylistResponse) {}

  // UpdatePlaylist updates an existing playlist (authenticated)
  rpc UpdatePlaylist(UpdatePlaylistRequest) returns (UpdatePlaylistResponse) {}

  // DeletePlaylist deletes a playlist (authenticated)
  rpc DeletePlaylist(DeletePlaylistRequest) returns (DeletePlaylistResponse) {}

  // UpdatePlaylistTracks updates tracks in a playlist (authenticated)
  rpc UpdatePlaylistTracks(UpdatePlaylistTracksRequest) returns (UpdatePlaylistTracksResponse) {}
}

// Artist requests and responses
message GetArtistRequest {
  int32 artist_id = 1;
}

message GetArtistResponse {
  Artist artist = 1;
}

message ListArtistsRequest {
  int32 offset = 1;
  int32 limit = 2;
}

message ListArtistsResponse {
  repeated Artist artists = 1;
  int64 total = 2;
  int32 offset = 3;
  int32 limit = 4;
}

// Album requests and responses
message GetAlbumRequest {
  int32 album_id = 1;
}

message GetAlbumResponse {
  Album album = 1;
}

message ListAlbumsRequest {
  int32 offset = 1;
  int32 limit = 2;
  optional int32 artist_id = 3; // Filter by artist
}

message ListAlbumsResponse {
  repeated Album albums = 1;
  int64 total = 2;
  int32 offset = 3;
  int32 limit = 4;
}

// Track requests and responses
message GetTrackRequest {
  int32 track_id = 1;
}

message GetTrackResponse {
  Track track = 1;
}

message ListTracksRequest {
  int32 offset = 1;
  int32 limit = 2;
  optional int32 artist_id = 3; // Filter by artist
  optional int32 album_id = 4;  // Filter by album
  optional int32 genre_id = 5;  // Filter by genre
}

message ListTracksResponse {
  repeated Track tracks = 1;
  int64 total = 2;
  int32 offset = 3;
  int32 limit = 4;
}

// Genre requests and responses
message GetGenreRequest {
  int32 genre_id = 1;
}

message GetGenreResponse {
  Genre genre = 1;
}

message ListGenresRequest {
  int32 offset = 1;
  int32 limit = 2;
}

message ListGenresResponse {
  repeated Genre genres = 1;
  int64 total = 2;
  int32 offset = 3;
  int32 limit = 4;
}

// Playlist requests and responses
message GetPlaylistRequest {
  string playlist_id = 1;
}

message GetPlaylistResponse {
  Playlist playlist = 1;
}

message ListPlaylistsRequest {
  int32 offset = 1;
  int32 limit = 2;
  optional string created_by = 3; // Filter by creator
  optional bool is_public = 4;    // Filter by public status
}

message ListPlaylistsResponse {
  repeated Playlist playlists = 1;
  int64 total = 2;
  int32 offset = 3;
  int32 limit = 4;
}

// Get User Playlists requests and responses (authenticated)
message GetUserPlaylistsRequest {
  int32 offset = 1;
  int32 limit = 2;
  optional bool is_public = 3; // Filter by public/private status
}

message GetUserPlaylistsResponse {
  repeated Playlist playlists = 1;
  int64 total = 2;
  int32 offset = 3;
  int32 limit = 4;
}

// Get Public Playlists requests and responses
message GetPublicPlaylistsRequest {
  int32 offset = 1;
  int32 limit = 2;
  optional bool is_featured = 3; // Filter by featured status
  optional bool is_official = 4; // Filter by official status
}

message GetPublicPlaylistsResponse {
  repeated Playlist playlists = 1;
  int64 total = 2;
  int32 offset = 3;
  int32 limit = 4;
}

// Playlist Tracks requests and responses
message ListPlaylistTracksRequest {
  string playlist_id = 1;
  int32 offset = 2;
  int32 limit = 3;
}

message ListPlaylistTracksResponse {
  repeated PlaylistTrackWithDetails tracks = 1;
  int64 total = 2;
  int32 offset = 3;
  int32 limit = 4;
}

// Get Playlist Tracks requests and responses (authenticated)
message GetPlaylistTracksRequest {
  string playlist_id = 1;
  int32 offset = 2;
  int32 limit = 3;
}

message GetPlaylistTracksResponse {
  repeated PlaylistTrackWithDetails tracks = 1;
  int64 total = 2;
  int32 offset = 3;
  int32 limit = 4;
}

// Playlist CRUD requests and responses
message CreatePlaylistRequest {
  string title = 1;
  string description = 2;
  string image_url = 3;
  bool is_public = 4;
}

message CreatePlaylistResponse {
  Playlist playlist = 1;
}

message UpdatePlaylistRequest {
  string playlist_id = 1;
  optional string title = 2;
  optional string description = 3;
  optional string image_url = 4;
  optional bool is_public = 5;
}

message UpdatePlaylistResponse {
  Playlist playlist = 1;
}

message DeletePlaylistRequest {
  string playlist_id = 1;
}

message DeletePlaylistResponse {
  bool success = 1;
}

// Update Playlist Tracks requests and responses
message UpdatePlaylistTracksRequest {
  string playlist_id = 1;
  repeated int32 track_ids = 2;
}

message UpdatePlaylistTracksResponse {
  bool success = 1;
  int32 tracks_count = 2;
}
