@bitmovin/api-sdk
Version:
Bitmovin JS/TS API SDK
96 lines (95 loc) • 3.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const BaseAPI_1 = require("../../common/BaseAPI");
const Mapper_1 = require("../../common/Mapper");
const StopApi_1 = require("./stop/StopApi");
const StartApi_1 = require("./start/StartApi");
const StreamsLiveResponse_1 = require("../../models/StreamsLiveResponse");
const PaginationResponse_1 = require("../../models/PaginationResponse");
const StreamsLiveResponseListQueryParams_1 = require("./StreamsLiveResponseListQueryParams");
/**
* LiveApi - object-oriented interface
* @export
* @class LiveApi
* @extends {BaseAPI}
*/
class LiveApi extends BaseAPI_1.BaseAPI {
constructor(configuration) {
super(configuration);
this.stop = new StopApi_1.default(configuration);
this.start = new StartApi_1.default(configuration);
}
/**
* @summary Create new live stream
* @param {StreamsLiveCreateRequest} streamsLiveCreateRequest Create a new stream.
* @throws {BitmovinError}
* @memberof LiveApi
*/
create(streamsLiveCreateRequest) {
return this.restClient.post('/streams/live', {}, streamsLiveCreateRequest).then((response) => {
return (0, Mapper_1.map)(response, StreamsLiveResponse_1.default);
});
}
/**
* @summary Delete Stream
* @param {string} streamId Id of the stream.
* @throws {BitmovinError}
* @memberof LiveApi
*/
delete(streamId) {
const pathParamMap = {
stream_id: streamId
};
return this.restClient.delete('/streams/live/{stream_id}', pathParamMap).then((response) => {
return (0, Mapper_1.map)(response);
});
}
/**
* @summary Get live stream by id
* @param {string} streamId Id of the stream.
* @throws {BitmovinError}
* @memberof LiveApi
*/
get(streamId) {
const pathParamMap = {
stream_id: streamId
};
return this.restClient.get('/streams/live/{stream_id}', pathParamMap).then((response) => {
return (0, Mapper_1.map)(response, StreamsLiveResponse_1.default);
});
}
/**
* @summary Get paginated list of live streams
* @param {*} [queryParameters] query parameters for filtering, sorting and pagination
* @throws {BitmovinError}
* @memberof LiveApi
*/
list(queryParameters) {
let queryParams = {};
if (typeof queryParameters === 'function') {
queryParams = queryParameters(new StreamsLiveResponseListQueryParams_1.StreamsLiveResponseListQueryParamsBuilder()).buildQueryParams();
}
else if (queryParameters) {
queryParams = queryParameters;
}
return this.restClient.get('/streams/live', {}, queryParams).then((response) => {
return new PaginationResponse_1.default(response, StreamsLiveResponse_1.default);
});
}
/**
* @summary Partially update live stream by id
* @param {string} streamId Id of the stream.
* @param {StreamsLiveUpdateRequest} streamsLiveUpdateRequest Stream fields to update.
* @throws {BitmovinError}
* @memberof LiveApi
*/
patchStreamsLive(streamId, streamsLiveUpdateRequest) {
const pathParamMap = {
stream_id: streamId
};
return this.restClient.patch('/streams/live/{stream_id}', pathParamMap, streamsLiveUpdateRequest).then((response) => {
return (0, Mapper_1.map)(response, StreamsLiveResponse_1.default);
});
}
}
exports.default = LiveApi;