Skip to content

Commit 4e44039

Browse files
sofislirataxy
authored andcommitted
feat: add initial samples (#2)
Release-As: v0.1.0
1 parent 76fd71f commit 4e44039

File tree

2 files changed

+55
-30
lines changed

2 files changed

+55
-30
lines changed

media/video-stitcher/quickstart.js

+52-24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright 2022 Google LLC
2+
//
13
// Licensed under the Apache License, Version 2.0 (the "License");
24
// you may not use this file except in compliance with the License.
35
// You may obtain a copy of the License at
@@ -10,41 +12,67 @@
1012
// See the License for the specific language governing permissions and
1113
// limitations under the License.
1214
//
15+
// ** This file is automatically generated by gapic-generator-typescript. **
16+
// ** https://github.com/googleapis/gapic-generator-typescript **
17+
// ** All changes to this file may be overwritten. **
1318

1419
'use strict';
1520

16-
async function main() {
17-
18-
// [START nodejs_video_stitcher_quickstart]
19-
// Imports the Google Cloud client library
21+
function main(parent) {
22+
// [START videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_async]
23+
/**
24+
* TODO(developer): Uncomment these variables before running the sample.
25+
*/
26+
/**
27+
* Required. The project that contains the list of CDN keys, in the form of
28+
* `projects/{project_number}/locations/{location}`.
29+
*/
30+
// const parent = 'abc123'
31+
/**
32+
* Requested page size. Server may return fewer items than requested.
33+
* If unspecified, server will pick an appropriate default.
34+
*/
35+
// const pageSize = 1234
36+
/**
37+
* A token identifying a page of results the server should return.
38+
*/
39+
// const pageToken = 'abc123'
40+
/**
41+
* Filtering results
42+
*/
43+
// const filter = 'abc123'
44+
/**
45+
* Hint for how to order the results
46+
*/
47+
// const orderBy = 'abc123'
2048

21-
// remove this line after package is released
22-
// eslint-disable-next-line node/no-missing-require
23-
const {VideoStitcherServiceClient} = require('@google-cloud/video-stitcher');
49+
// Imports the Stitcher library
50+
const {VideoStitcherServiceClient} =
51+
require('@google-cloud/video-stitcher').v1;
2452

25-
// TODO(developer): replace with your prefered project ID.
26-
// const projectId = 'my-project'
53+
// Instantiates a client
54+
const stitcherClient = new VideoStitcherServiceClient();
2755

28-
// Creates a client
29-
// eslint-disable-next-line no-unused-vars
30-
const client = new {VideoStitcherServiceClient}();
56+
async function callListCdnKeys() {
57+
// Construct request
58+
const request = {
59+
parent,
60+
};
3161

32-
//TODO(library generator): write the actual function you will be testing
33-
async function doSomething() {
34-
console.log('DPE! Change this code so that it shows how to use the library! See comments below on structure.')
35-
// const [thing] = await client.methodName({
36-
// });
37-
// console.info(thing);
62+
// Run request
63+
const iterable = await stitcherClient.listCdnKeysAsync(request);
64+
for await (const response of iterable) {
65+
console.log(response);
66+
}
67+
console.log(iterable);
3868
}
39-
doSomething();
40-
// [END nodejs_video_stitcher_quickstart]
69+
70+
callListCdnKeys();
71+
// [END videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_async]
4172
}
4273

43-
main(...process.argv.slice(2)).catch(err => {
44-
console.error(err.message);
45-
process.exitCode = 1;
46-
});
4774
process.on('unhandledRejection', err => {
4875
console.error(err.message);
4976
process.exitCode = 1;
5077
});
78+
main(...process.argv.slice(2));

media/video-stitcher/test/quickstart.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
2929

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

32-
const client = new {VideoStitcherServiceClient}();
32+
const client = new VideoStitcherServiceClient();
3333

3434
describe('Quickstart', () => {
35-
//TODO: remove this if not using the projectId
3635
// eslint-disable-next-line no-unused-vars
3736
let projectId;
3837

@@ -42,12 +41,10 @@ describe('Quickstart', () => {
4241
});
4342

4443
it('should run quickstart', async () => {
45-
//TODO: remove this line
46-
// eslint-disable-next-line no-unused-vars
4744
const stdout = execSync(
48-
`node ./quickstart.js`,
45+
`node ./quickstart.js projects/${projectId}/locations/us-central1`,
4946
{cwd}
5047
);
51-
//assert(stdout, stdout !== null);
48+
assert(stdout, stdout !== null);
5249
});
5350
});

0 commit comments

Comments
 (0)