Skip to content

Commit

Permalink
feat: initial generation of video livestream library (#4)
Browse files Browse the repository at this point in the history
Release-As: 0.1.0
  • Loading branch information
bcoe authored Feb 11, 2022
0 parents commit 67558a6
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 0 deletions.
23 changes: 23 additions & 0 deletions media/livestream/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "nodejs-video-live-stream",
"private": true,
"license": "Apache-2.0",
"author": "Google LLC",
"engines": {
"node": ">=10"
},
"files": [
"*.js"
],
"scripts": {
"test": "c8 mocha --timeout 600000 test/*.js"
},
"dependencies": {
"@google-cloud/livestream": "^0.1.0"
},
"devDependencies": {
"c8": "^7.1.0",
"chai": "^4.2.0",
"mocha": "^9.0.0"
}
}
76 changes: 76 additions & 0 deletions media/livestream/quickstart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

function main(parent) {
// [START livestream_quickstart]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The parent location for the resource, in the form of:
* `projects/{project}/locations/{location}`.
*/
// const parent = 'abc123'
/**
* The maximum number of items to return. If unspecified, server
* will pick an appropriate default. Server may return fewer items than
* requested. A caller should only rely on response's
* next_page_token google.cloud.video.livestream.v1.ListChannelsResponse.next_page_token to
* determine if there are more items left to be queried.
*/
// const pageSize = 1234
/**
* The next_page_token value returned from a previous List request, if any.
*/
// const pageToken = 'abc123'
/**
* The filter to apply to list results.
*/
// const filter = 'abc123'
/**
* Specifies the ordering of results following syntax at
* https://cloud.google.com/apis/design/design_patterns#sorting_order.
*/
// const orderBy = 'abc123'

// Imports the Livestream library
const {LivestreamServiceClient} = require('@google-cloud/livestream').v1;

// Instantiates a client
const livestreamClient = new LivestreamServiceClient();

async function callListChannels() {
// Construct request
const request = {
parent,
};

// Run request
const iterable = await livestreamClient.listChannelsAsync(request);
for await (const response of iterable) {
console.log(response);
}
}

callListChannels();
// [END livestream_quickstart]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
42 changes: 42 additions & 0 deletions media/livestream/test/quickstart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

// const path = require('path');
// const cp = require('child_process');
const {before, describe, it} = require('mocha');
// const {LivestreamServiceClient} = require('@google-cloud/vmmigration').v1;

// const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

// const cwd = path.join(__dirname, '..');

// const client = new LivestreamServiceClient();

describe('Quickstart', () => {
// let projectId;

before(async () => {
// projectId = await client.getProjectId();
});

it('should run quickstart', async () => {
// API must be allow listed:
// Should have 0 exit code, and therefore not throw:
// execSync(`node ./quickstart.js projects/${projectId}/locations/global`, {
// cwd,
// });
});
});

0 comments on commit 67558a6

Please sign in to comment.