Skip to content

Commit 55fa024

Browse files
Benjamin E. Coegrayside
authored andcommitted
feat: initial generation of video livestream library (#4)
Release-As: 0.1.0
1 parent b9cb172 commit 55fa024

File tree

3 files changed

+141
-0
lines changed

3 files changed

+141
-0
lines changed

media/livestream/package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "nodejs-video-live-stream",
3+
"private": true,
4+
"license": "Apache-2.0",
5+
"author": "Google LLC",
6+
"engines": {
7+
"node": ">=10"
8+
},
9+
"files": [
10+
"*.js"
11+
],
12+
"scripts": {
13+
"test": "c8 mocha --timeout 600000 test/*.js"
14+
},
15+
"dependencies": {
16+
"@google-cloud/livestream": "^0.1.0"
17+
},
18+
"devDependencies": {
19+
"c8": "^7.1.0",
20+
"chai": "^4.2.0",
21+
"mocha": "^9.0.0"
22+
}
23+
}

media/livestream/quickstart.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(parent) {
18+
// [START livestream_quickstart]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The parent location for the resource, in the form of:
24+
* `projects/{project}/locations/{location}`.
25+
*/
26+
// const parent = 'abc123'
27+
/**
28+
* The maximum number of items to return. If unspecified, server
29+
* will pick an appropriate default. Server may return fewer items than
30+
* requested. A caller should only rely on response's
31+
* next_page_token google.cloud.video.livestream.v1.ListChannelsResponse.next_page_token to
32+
* determine if there are more items left to be queried.
33+
*/
34+
// const pageSize = 1234
35+
/**
36+
* The next_page_token value returned from a previous List request, if any.
37+
*/
38+
// const pageToken = 'abc123'
39+
/**
40+
* The filter to apply to list results.
41+
*/
42+
// const filter = 'abc123'
43+
/**
44+
* Specifies the ordering of results following syntax at
45+
* https://cloud.google.com/apis/design/design_patterns#sorting_order.
46+
*/
47+
// const orderBy = 'abc123'
48+
49+
// Imports the Livestream library
50+
const {LivestreamServiceClient} = require('@google-cloud/livestream').v1;
51+
52+
// Instantiates a client
53+
const livestreamClient = new LivestreamServiceClient();
54+
55+
async function callListChannels() {
56+
// Construct request
57+
const request = {
58+
parent,
59+
};
60+
61+
// Run request
62+
const iterable = await livestreamClient.listChannelsAsync(request);
63+
for await (const response of iterable) {
64+
console.log(response);
65+
}
66+
}
67+
68+
callListChannels();
69+
// [END livestream_quickstart]
70+
}
71+
72+
process.on('unhandledRejection', err => {
73+
console.error(err.message);
74+
process.exitCode = 1;
75+
});
76+
main(...process.argv.slice(2));
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
// const path = require('path');
18+
// const cp = require('child_process');
19+
const {before, describe, it} = require('mocha');
20+
// const {LivestreamServiceClient} = require('@google-cloud/vmmigration').v1;
21+
22+
// const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
23+
24+
// const cwd = path.join(__dirname, '..');
25+
26+
// const client = new LivestreamServiceClient();
27+
28+
describe('Quickstart', () => {
29+
// let projectId;
30+
31+
before(async () => {
32+
// projectId = await client.getProjectId();
33+
});
34+
35+
it('should run quickstart', async () => {
36+
// API must be allow listed:
37+
// Should have 0 exit code, and therefore not throw:
38+
// execSync(`node ./quickstart.js projects/${projectId}/locations/global`, {
39+
// cwd,
40+
// });
41+
});
42+
});

0 commit comments

Comments
 (0)