using System.Collections.Generic; using Nancy; using Nancy.Metadata.Modules; using Nancy.Metadata.Swagger.Core; using Nancy.Metadata.Swagger.Fluent; using Sony.Filtr.Contracts.Entities; using Sony.Filtr.PlaylistSynchronization; namespace Sony.Filtr.AdminAPI.Modules { public class PlaylistSyncMetadataModule : MetadataModule { public PlaylistSyncMetadataModule() { var tag = "Playlist Synchronization"; Describe["GetAllPlaylistSyncs"] = description => new SwaggerRouteMetadata(description).With(c => c.WithDescription("Get all available playlist syncs", tag) .WithDefaultResponse>()); Describe["GetPlaylistSyncsMarket"] = description => new SwaggerRouteMetadata(description).With(c => c.WithDescription("Get the available playlists syncs in the market", tag) .WithRequestParameter("countryCode", description: "Market Id") .WithDefaultResponse>() .WithResponse(HttpStatusCode.BadRequest, "Missing or invalid market id")); Describe["GetSinglePlaylistSync"] = description => new SwaggerRouteMetadata(description).With(c => c.WithDescription("Get the specified playlist sync", tag) .WithRequestParameter("countryCode", description: "Market Id") .WithRequestParameter("playlistSyncId") .WithDefaultResponse() .WithResponse(HttpStatusCode.BadRequest, "Missing or invalid market id") .WithResponse(HttpStatusCode.BadRequest, "Missing or invalid playlist sync id") .WithResponse(HttpStatusCode.BadRequest, "Playlist sync does not match specified market id")); Describe["AddPlaylistSync"] = description => new SwaggerRouteMetadata(description).With(c => c.WithDescription("Add a new playlist sync", tag) .WithRequestParameter("countryCode", description: "Market Id") .WithRequestModel() .WithDefaultResponse() .WithResponse(HttpStatusCode.BadRequest, "Missing or invalid market id") .WithResponse(HttpStatusCode.BadRequest, "Missing or invalid playlist sync") .WithResponse(HttpStatusCode.Conflict, "Existing playlist sync with same toPlaylistId already exists") .WithResponse(HttpStatusCode.Forbidden, "Specified Service account does not belong to specified market") .WithResponse(HttpStatusCode.BadRequest, "Missing or invalid service account specified") ); Describe["UpdatePlaylistSync"] = description => new SwaggerRouteMetadata(description).With(c => c.WithDescription("Update an existing playlist sync", tag) .WithRequestParameter("countryCode", description: "Market Id") .WithRequestParameter("playlistSyncId") .WithRequestModel() .WithDefaultResponse() .WithResponse(HttpStatusCode.BadRequest, "Missing or invalid market id") .WithResponse(HttpStatusCode.BadRequest, "Missing or invalid playlist sync") .WithResponse(HttpStatusCode.Conflict, "Existing playlist sync with same toPlaylistId already exists") .WithResponse(HttpStatusCode.Forbidden, "Specified Service account does not belong to specified market") .WithResponse(HttpStatusCode.BadRequest, "Missing or invalid service account specified")); Describe["DeletePlaylistSync"] = description => new SwaggerRouteMetadata(description).With(c => c.WithDescription("Delete an existing playlist sync", tag) .WithRequestParameter("countryCode", description: "Market Id") .WithRequestParameter("playlistSyncId") .WithResponse(HttpStatusCode.Accepted, "Playlist sync has been deleted") .WithResponse(HttpStatusCode.BadRequest, "Specified market id does not match playlist syncs market id") .WithResponse(HttpStatusCode.NotFound, "Specified playlist sync could not be found") ); Describe["ExecutePlaylistSync"] = description => new SwaggerRouteMetadata(description).With(c => c.WithDescription("Execute the playlist sync manually", tag) .WithRequestParameter("countryCode", description: "Market Id") .WithRequestParameter("playlistSyncId") .WithResponse(HttpStatusCode.OK, "Playlist sync has been started in background") .WithResponse(HttpStatusCode.BadRequest, "Specified market id does not match playlist syncs market id") .WithResponse(HttpStatusCode.NotFound, "Specified playlist sync could not be found")); Describe["GetWhitelistedYoutubeChannels"] = description => new SwaggerRouteMetadata(description).With(c => c.WithDescription("Get all YouTube channels which have been whitelisted", tag) .WithDefaultResponse>()); Describe["AddWhitelistedYoutubeChannel"] = description => new SwaggerRouteMetadata(description).With(c => c.WithDescription("Add a new YouTube channel to the whitelist", tag) .WithRequestParameter("channel") .WithResponse(HttpStatusCode.OK, "Channel has been added")); Describe["DeleteWhitelistedYoutubeChannel"] = description => new SwaggerRouteMetadata(description).With(c => c.WithDescription("Delete a YouTube channel from the whitelist", tag) .WithRequestParameter("channel") .WithResponse(HttpStatusCode.OK, "Channel has been deleted")); Describe["GetBlacklistedYoutubeChannels"] = description => new SwaggerRouteMetadata(description).With(c => c.WithDescription("Get all YouTube channels which have been blacklisted", tag) .WithDefaultResponse>()); Describe["UpdateBlacklistedYoutubeChannel"] = description => new SwaggerRouteMetadata(description).With(c => c.WithDescription("Add a new YouTube channel to the blacklist", tag) .WithRequestParameter("channel") .WithResponse(HttpStatusCode.OK, "Channel has been added")); Describe["DeleteBlacklistedYoutubeChannel"] = description => new SwaggerRouteMetadata(description).With(c => c.WithDescription("Delete a YouTube channel from the blacklist", tag) .WithRequestParameter("channel") .WithResponse(HttpStatusCode.OK, "Channel has been deleted")); Describe["GetLogForPlaylistSync"] = description => new SwaggerRouteMetadata(description).With(c => c.WithDescription("Get the log history for the specific playlist sync", tag) .WithRequestParameter("limit", type: "string", description: "Limit", loc: "query", required: false) .WithRequestParameter("offset", type: "string", description: "Offset", loc: "query", required: false) .WithRequestParameter("playlistSyncId") .WithDefaultResponse>()); } } }