Skip to content

Commit

Permalink
feat(api): support Cloudflare Stream
Browse files Browse the repository at this point in the history
Adds support for the Cloudflare Stream api.

Signed-off-by: Terin Stock <terinjokes@gmail.com>
  • Loading branch information
jsoizo authored and terinjokes committed Aug 4, 2020
1 parent 9072fda commit 2079b45
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const resources = {
zoneWorkersScript: require('./lib/resources/ZoneWorkersScript'),
zoneWorkersRoutes: require('./lib/resources/ZoneWorkersRoutes'),
user: require('./lib/resources/User'),
stream: require('./lib/resources/Stream'),
};
/* eslint-enable global-require */

Expand Down
92 changes: 92 additions & 0 deletions lib/resources/Stream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright (C) 2014-present Cloudflare, Inc.
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/

'use strict';

const prototypal = require('es-class');
const auto = require('autocreate');

const Resource = require('../Resource');
const method = require('../method');

/**
* Stream represents the /accout/:id/stream API endpoint.
*
* @class Stream
* @hideconstructor
* @extends Resource
*/
module.exports = auto(
prototypal({
extends: Resource,
path: 'accounts/:accountId/stream',
hasBrokenPatch: true,

includeBasic: ['browse', 'read', 'edit', 'add', 'del'],

/**
* ListVideos retrieves all of a account's videos.
*
* @function listVideos
* @memberof Stream
* @instance
* @async
* @param {string} accountId - The account ID
* @returns {Promise<Object>} The response object
*/
listVideos: method({
method: 'GET',
}),

/**
* VideoDetails retrieves details of a account's single video.
*
* @function videoDetails
* @memberof Stream
* @instance
* @async
* @param {string} accountId - The account ID
* @param {string} id - The video ID
* @returns {Promise<Object>} The response object
*/
videoDetails: method({
method: 'GET',
path: ':id',
}),

/**
* UploadVideoFromUrl uploads a video from specific URL
*
* @function uploadVideoFromUrl
* @instance
* @async
* @param {string} accountId - The account ID
* @param {Object} video - The upload video info
* @returns {Promise<Object>} The response object
*/
uploadVideoFromUrl: method({
method: 'POST',
path: 'copy',
}),

/**
* DeleteVideo deletes a account's single video.
*
* @function deleteVideo
* @memberof Stream
* @instance
* @async
* @param {string} accountId - The account ID
* @param {string} id - The video ID
* @returns {Promise<Object>} The response object
*/
deleteVideo: method({
method: 'DELETE',
path: ':id',
}),
})
);

0 comments on commit 2079b45

Please sign in to comment.