From 36526a15c76657ae273f27e317cf82b8e25f3ccd Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Tue, 12 Sep 2023 20:29:29 +0200 Subject: [PATCH] make paths optional --- docs/api.md | 14 ++++++++++++-- docs/playlist_gen.md | 4 +--- ffplayout-api/src/api/routes.rs | 24 ++++++++++++++++++------ 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/docs/api.md b/docs/api.md index d67144bc..38c76b11 100644 --- a/docs/api.md +++ b/docs/api.md @@ -253,7 +253,7 @@ curl -X GET http://127.0.0.1:8787/api/playlist/1?date=2022-06-20 ```BASH curl -X POST http://127.0.0.1:8787/api/playlist/1/ -H 'Content-Type: application/json' -H 'Authorization: Bearer ' --- data "{}" +--data "{}" ``` **Generate Playlist** @@ -261,8 +261,18 @@ curl -X POST http://127.0.0.1:8787/api/playlist/1/ A new playlist will be generated and response. ```BASH -curl -X GET http://127.0.0.1:8787/api/playlist/1/generate/2022-06-20 +curl -X POST http://127.0.0.1:8787/api/playlist/1/generate/2022-06-20 -H 'Content-Type: application/json' -H 'Authorization: Bearer ' +/// --data '{ "paths": [] }' # <- data is optional +``` + +Or with template: +```BASH +curl -X POST http://127.0.0.1:8787/api/playlist/1/generate/2023-00-05 +-H 'Content-Type: application/json' -H 'Authorization: Bearer ' +--data '{"template": {"sources": [\ + {"start": "00:00:00", "duration": "10:00:00", "shuffle": true, "paths": ["path/1", "path/2"]}, \ + {"start": "10:00:00", "duration": "14:00:00", "shuffle": false, "paths": ["path/3", "path/4"]}]}}' ``` **Delete Playlist** diff --git a/docs/playlist_gen.md b/docs/playlist_gen.md index 80e7d893..09c81c22 100644 --- a/docs/playlist_gen.md +++ b/docs/playlist_gen.md @@ -1,4 +1,3 @@ - ## Playlist generation template It is possible to generate playlists based on templates. A template could look like: @@ -64,8 +63,7 @@ Or through API: ```BASH curl -X POST http://127.0.0.1:8787/api/playlist/1/generate/2023-00-05 -H 'Content-Type: application/json' -H 'Authorization: Bearer ' - --data '{ "paths": "template": {"sources": [\ + --data '{"template": {"sources": [\ {"start": "00:00:00", "duration": "10:00:00", "shuffle": true, "paths": ["path/1", "path/2"]}, \ {"start": "10:00:00", "duration": "14:00:00", "shuffle": false, "paths": ["path/3", "path/4"]}]}}' ``` - diff --git a/ffplayout-api/src/api/routes.rs b/ffplayout-api/src/api/routes.rs index 45601d18..776ab6fb 100644 --- a/ffplayout-api/src/api/routes.rs +++ b/ffplayout-api/src/api/routes.rs @@ -79,7 +79,7 @@ struct FileObj { #[derive(Debug, Default, Deserialize, Serialize)] pub struct PathsObj { #[serde(default)] - paths: Vec, + paths: Option>, template: Option