From 8f9e8be1fc46ce1744ed6ff537ce2fb995fe7b58 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Thu, 15 Nov 2018 17:08:42 +0100 Subject: fix API spec on POST /videos/upload and provide Shell example --- support/doc/api/openapi.yaml | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'support/doc') diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml index c5bea99ac..666e48a41 100644 --- a/support/doc/api/openapi.yaml +++ b/support/doc/api/openapi.yaml @@ -116,12 +116,16 @@ paths: x-code-samples: - lang: JavaScript source: | - fetch('https://peertube.cpy.re/api/v1/accounts/{name}/videos') + fetch('https://peertube2.cpy.re/api/v1/accounts/{name}/videos') .then(function(response) { return response.json() }).then(function(data) { console.log(data) }) + - lang: Shell + source: | + # pip install httpie + http -b GET https://peertube2.cpy.re/api/v1/accounts/{name}/videos /accounts: get: tags: @@ -131,7 +135,7 @@ paths: '200': description: successful operation content: - 'application/jsonhttps://peertube.cpy.re/api/v1': + 'application/json': schema: type: array items: @@ -730,6 +734,8 @@ paths: previewfile: description: Video preview file type: string + privacy: + $ref: '#/components/schemas/VideoPrivacy' category: description: Video category type: string @@ -764,6 +770,36 @@ paths: required: - videofile - channelId + - name + - privacy + x-code-samples: + - lang: Shell + source: | + ## DEPENDENCIES: httpie, jq + # pip install httpie + USERNAME="" + PASSWORD="" + FILE_PATH="" + CHANNEL_ID="" + PRIVACY="1" # public: 1, unlisted: 2, private: 3 + NAME="" + + API_PATH="https://peertube2.cpy.re/api/v1" + ## AUTH + client_id=$(http -b GET "$API_PATH/oauth-clients/local" | jq -r ".client_id") + client_secret=$(http -b GET "$API_PATH/oauth-clients/local" | jq -r ".client_secret") + token=$(http -b --form POST "$API_PATH/users/token" \ + client_id="$client_id" client_secret="$client_secret" grant_type=password response_type=code \ + username=$USERNAME \ + password=$PASSWORD \ + | jq -r ".access_token") + ## VIDEO UPLOAD + http -b --form POST "$API_PATH/videos/upload" \ + videofile@$FILE_PATH \ + channelId=$CHANNEL_ID \ + name=$NAME \ + privacy=$PRIVACY \ + "Authorization:Bearer $token" /videos/abuse: get: summary: Get list of reported video abuses @@ -1060,7 +1096,7 @@ paths: items: $ref: '#/components/schemas/Video' servers: - - url: 'https://peertube.cpy.re/api/v1' + - url: 'https://peertube2.cpy.re/api/v1' description: Live Server components: parameters: -- cgit v1.2.3