From a3f31c340db67fab7308fdddacf8e22ccc54286a Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Sat, 28 May 2022 06:16:07 +0000 Subject: [PATCH 01/14] feat: add templated files from docker image --- media/video-stitcher/package.json | 23 +++++++++++ media/video-stitcher/quickstart.js | 50 +++++++++++++++++++++++ media/video-stitcher/test/quickstart.js | 53 +++++++++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 media/video-stitcher/package.json create mode 100644 media/video-stitcher/quickstart.js create mode 100644 media/video-stitcher/test/quickstart.js diff --git a/media/video-stitcher/package.json b/media/video-stitcher/package.json new file mode 100644 index 0000000000..48366a7ab6 --- /dev/null +++ b/media/video-stitcher/package.json @@ -0,0 +1,23 @@ +{ + "name": "nodejs-video-stitcher", + "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/video-stitcher": "^0.1.0" + }, + "devDependencies": { + "c8": "^7.1.0", + "chai": "^4.2.0", + "mocha": "^8.0.0" + } +} diff --git a/media/video-stitcher/quickstart.js b/media/video-stitcher/quickstart.js new file mode 100644 index 0000000000..4b4fe8ef4e --- /dev/null +++ b/media/video-stitcher/quickstart.js @@ -0,0 +1,50 @@ +// 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 +// +// https://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'; + +async function main() { + + // [START nodejs_video_stitcher_quickstart] + // Imports the Google Cloud client library + + // remove this line after package is released + // eslint-disable-next-line node/no-missing-require + const {VideoStitcherServiceClient} = require('@google-cloud/video-stitcher'); + + // TODO(developer): replace with your prefered project ID. + // const projectId = 'my-project' + + // Creates a client + // eslint-disable-next-line no-unused-vars + const client = new {VideoStitcherServiceClient}(); + + //TODO(library generator): write the actual function you will be testing + async function doSomething() { + console.log('DPE! Change this code so that it shows how to use the library! See comments below on structure.') + // const [thing] = await client.methodName({ + // }); + // console.info(thing); + } + doSomething(); + // [END nodejs_video_stitcher_quickstart] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/media/video-stitcher/test/quickstart.js b/media/video-stitcher/test/quickstart.js new file mode 100644 index 0000000000..026323c693 --- /dev/null +++ b/media/video-stitcher/test/quickstart.js @@ -0,0 +1,53 @@ +// +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +const path = require('path'); +const cp = require('child_process'); +const {before, describe, it} = require('mocha'); +// eslint-disable-next-line node/no-missing-require +const {VideoStitcherServiceClient} = require('@google-cloud/video-stitcher'); +// eslint-disable-next-line no-unused-vars, node/no-missing-require +const {assert} = require('chai'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const cwd = path.join(__dirname, '..'); + +const client = new {VideoStitcherServiceClient}(); + +describe('Quickstart', () => { + //TODO: remove this if not using the projectId + // eslint-disable-next-line no-unused-vars + let projectId; + + before(async () => { + // eslint-disable-next-line no-unused-vars + projectId = await client.getProjectId(); + }); + + it('should run quickstart', async () => { + //TODO: remove this line + // eslint-disable-next-line no-unused-vars + const stdout = execSync( + `node ./quickstart.js`, + {cwd} + ); + //assert(stdout, stdout !== null); + }); +}); From b8c82d9a986d174959414e01d25656720b608ce4 Mon Sep 17 00:00:00 2001 From: sofisl <55454395+sofisl@users.noreply.github.com> Date: Thu, 9 Jun 2022 08:10:22 -0700 Subject: [PATCH 02/14] feat: add initial samples (#2) Release-As: v0.1.0 --- media/video-stitcher/quickstart.js | 76 +++++++++++++++++-------- media/video-stitcher/test/quickstart.js | 9 +-- 2 files changed, 55 insertions(+), 30 deletions(-) diff --git a/media/video-stitcher/quickstart.js b/media/video-stitcher/quickstart.js index 4b4fe8ef4e..3f07eb5165 100644 --- a/media/video-stitcher/quickstart.js +++ b/media/video-stitcher/quickstart.js @@ -1,3 +1,5 @@ +// Copyright 2022 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 @@ -10,41 +12,67 @@ // See the License for the specific language governing permissions and // limitations under the License. // +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** 'use strict'; -async function main() { - - // [START nodejs_video_stitcher_quickstart] - // Imports the Google Cloud client library +function main(parent) { + // [START videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project that contains the list of CDN keys, in the form of + * `projects/{project_number}/locations/{location}`. + */ + // const parent = 'abc123' + /** + * Requested page size. Server may return fewer items than requested. + * If unspecified, server will pick an appropriate default. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results the server should return. + */ + // const pageToken = 'abc123' + /** + * Filtering results + */ + // const filter = 'abc123' + /** + * Hint for how to order the results + */ + // const orderBy = 'abc123' - // remove this line after package is released - // eslint-disable-next-line node/no-missing-require - const {VideoStitcherServiceClient} = require('@google-cloud/video-stitcher'); + // Imports the Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; - // TODO(developer): replace with your prefered project ID. - // const projectId = 'my-project' + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); - // Creates a client - // eslint-disable-next-line no-unused-vars - const client = new {VideoStitcherServiceClient}(); + async function callListCdnKeys() { + // Construct request + const request = { + parent, + }; - //TODO(library generator): write the actual function you will be testing - async function doSomething() { - console.log('DPE! Change this code so that it shows how to use the library! See comments below on structure.') - // const [thing] = await client.methodName({ - // }); - // console.info(thing); + // Run request + const iterable = await stitcherClient.listCdnKeysAsync(request); + for await (const response of iterable) { + console.log(response); + } + console.log(iterable); } - doSomething(); - // [END nodejs_video_stitcher_quickstart] + + callListCdnKeys(); + // [END videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_async] } -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); process.on('unhandledRejection', err => { console.error(err.message); process.exitCode = 1; }); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/test/quickstart.js b/media/video-stitcher/test/quickstart.js index 026323c693..073e774bc3 100644 --- a/media/video-stitcher/test/quickstart.js +++ b/media/video-stitcher/test/quickstart.js @@ -29,10 +29,9 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); const cwd = path.join(__dirname, '..'); -const client = new {VideoStitcherServiceClient}(); +const client = new VideoStitcherServiceClient(); describe('Quickstart', () => { - //TODO: remove this if not using the projectId // eslint-disable-next-line no-unused-vars let projectId; @@ -42,12 +41,10 @@ describe('Quickstart', () => { }); it('should run quickstart', async () => { - //TODO: remove this line - // eslint-disable-next-line no-unused-vars const stdout = execSync( - `node ./quickstart.js`, + `node ./quickstart.js projects/${projectId}/locations/us-central1`, {cwd} ); - //assert(stdout, stdout !== null); + assert(stdout, stdout !== null); }); }); From 49d6b2294eeb15aa9ef3a3ca7938cffa750fd107 Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Fri, 10 Jun 2022 15:20:10 -0700 Subject: [PATCH 03/14] docs(samples): add Video Stitcher slate and CDN key code samples and tests (#6) Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [X] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/nodejs-video-stitcher/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [X] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes b:202972969 --- media/video-stitcher/createCdnKey.js | 79 ++++++++ media/video-stitcher/createSlate.js | 56 ++++++ media/video-stitcher/deleteCdnKey.js | 51 ++++++ media/video-stitcher/deleteSlate.js | 51 ++++++ media/video-stitcher/getCdnKey.js | 51 ++++++ media/video-stitcher/getSlate.js | 51 ++++++ media/video-stitcher/listCdnKeys.js | 51 ++++++ media/video-stitcher/listSlates.js | 51 ++++++ media/video-stitcher/package.json | 3 +- media/video-stitcher/test/stitcher.test.js | 202 +++++++++++++++++++++ media/video-stitcher/updateCdnKey.js | 84 +++++++++ media/video-stitcher/updateSlate.js | 59 ++++++ 12 files changed, 788 insertions(+), 1 deletion(-) create mode 100644 media/video-stitcher/createCdnKey.js create mode 100644 media/video-stitcher/createSlate.js create mode 100644 media/video-stitcher/deleteCdnKey.js create mode 100644 media/video-stitcher/deleteSlate.js create mode 100644 media/video-stitcher/getCdnKey.js create mode 100644 media/video-stitcher/getSlate.js create mode 100644 media/video-stitcher/listCdnKeys.js create mode 100644 media/video-stitcher/listSlates.js create mode 100644 media/video-stitcher/test/stitcher.test.js create mode 100644 media/video-stitcher/updateCdnKey.js create mode 100644 media/video-stitcher/updateSlate.js diff --git a/media/video-stitcher/createCdnKey.js b/media/video-stitcher/createCdnKey.js new file mode 100644 index 0000000000..bb456575be --- /dev/null +++ b/media/video-stitcher/createCdnKey.js @@ -0,0 +1,79 @@ +/** + * Copyright 2022, Google, Inc. + * 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( + projectId, + location, + cdnKeyId, + hostname, + gCdnKeyname, + gCdnPrivateKey, + akamaiTokenKey = '' +) { + // [START video_stitcher_create_cdn_key] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // cdnKeyId = 'my-cdn-key'; + // hostname = 'cdn.example.com'; + // gCdnKeyname = 'gcdn-key'; + // gCdnPrivateKey = 'VGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg=='; + // akamaiTokenKey = 'VGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg=='; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function createCdnKey() { + // Construct request + const request = { + parent: stitcherClient.locationPath(projectId, location), + cdnKey: { + hostname: hostname, + }, + cdnKeyId: cdnKeyId, + }; + + if (akamaiTokenKey !== '') { + request.cdnKey.akamaiCdnKey = { + tokenKey: akamaiTokenKey, + }; + } else { + request.cdnKey.googleCdnKey = { + keyName: gCdnKeyname, + privateKey: gCdnPrivateKey, + }; + } + + const [cdnKey] = await stitcherClient.createCdnKey(request); + console.log(`CDN key: ${cdnKey.name}`); + } + + createCdnKey(); + // [END video_stitcher_create_cdn_key] +} + +// node createCdnKey.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/createSlate.js b/media/video-stitcher/createSlate.js new file mode 100644 index 0000000000..763aaed14c --- /dev/null +++ b/media/video-stitcher/createSlate.js @@ -0,0 +1,56 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location, slateId, slateUri) { + // [START video_stitcher_create_slate] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // slateId = 'my-slate'; + // slateUri = 'https://my-slate-uri/test.mp4'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function createSlate() { + // Construct request + const request = { + parent: stitcherClient.locationPath(projectId, location), + slate: { + uri: slateUri, + }, + slateId: slateId, + }; + const [slate] = await stitcherClient.createSlate(request); + console.log(`Slate: ${slate.name}`); + } + + createSlate(); + // [END video_stitcher_create_slate] +} + +// node createSlate.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/deleteCdnKey.js b/media/video-stitcher/deleteCdnKey.js new file mode 100644 index 0000000000..2e71cac996 --- /dev/null +++ b/media/video-stitcher/deleteCdnKey.js @@ -0,0 +1,51 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location, cdnKeyId) { + // [START video_stitcher_delete_cdn_key] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // cdnKeyId = 'my-cdn-key'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function deleteCdnKey() { + // Construct request + const request = { + name: stitcherClient.cdnKeyPath(projectId, location, cdnKeyId), + }; + await stitcherClient.deleteCdnKey(request); + console.log('Deleted CDN key'); + } + + deleteCdnKey(); + // [END video_stitcher_delete_cdn_key] +} + +// node deleteCdnKey.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/deleteSlate.js b/media/video-stitcher/deleteSlate.js new file mode 100644 index 0000000000..0dd0536b0a --- /dev/null +++ b/media/video-stitcher/deleteSlate.js @@ -0,0 +1,51 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location, slateId) { + // [START video_stitcher_delete_slate] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // slateId = 'my-slate'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function deleteSlate() { + // Construct request + const request = { + name: stitcherClient.slatePath(projectId, location, slateId), + }; + await stitcherClient.deleteSlate(request); + console.log('Deleted slate'); + } + + deleteSlate(); + // [END video_stitcher_delete_slate] +} + +// node deleteSlate.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/getCdnKey.js b/media/video-stitcher/getCdnKey.js new file mode 100644 index 0000000000..57a27c6de2 --- /dev/null +++ b/media/video-stitcher/getCdnKey.js @@ -0,0 +1,51 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location, cdnKeyId) { + // [START video_stitcher_get_cdn_key] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // cdnKeyId = 'my-cdn-key'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function getCdnKey() { + // Construct request + const request = { + name: stitcherClient.cdnKeyPath(projectId, location, cdnKeyId), + }; + const [cdnKey] = await stitcherClient.getCdnKey(request); + console.log(`CDN key: ${cdnKey.name}`); + } + + getCdnKey(); + // [END video_stitcher_get_cdn_key] +} + +// node getCdnKey.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/getSlate.js b/media/video-stitcher/getSlate.js new file mode 100644 index 0000000000..36908d8f41 --- /dev/null +++ b/media/video-stitcher/getSlate.js @@ -0,0 +1,51 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location, slateId) { + // [START video_stitcher_get_slate] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // slateId = 'my-slate'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function getSlate() { + // Construct request + const request = { + name: stitcherClient.slatePath(projectId, location, slateId), + }; + const [slate] = await stitcherClient.getSlate(request); + console.log(`Slate: ${slate.name}`); + } + + getSlate(); + // [END video_stitcher_get_slate] +} + +// node getSlate.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/listCdnKeys.js b/media/video-stitcher/listCdnKeys.js new file mode 100644 index 0000000000..70372888e0 --- /dev/null +++ b/media/video-stitcher/listCdnKeys.js @@ -0,0 +1,51 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location) { + // [START video_stitcher_list_cdn_keys] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function listCdnKeys() { + const iterable = await stitcherClient.listCdnKeysAsync({ + parent: stitcherClient.locationPath(projectId, location), + }); + console.info('CDN keys:'); + for await (const response of iterable) { + console.log(response.name); + } + } + + listCdnKeys(); + // [END video_stitcher_list_cdn_keys] +} + +// node listCdnKeys.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/listSlates.js b/media/video-stitcher/listSlates.js new file mode 100644 index 0000000000..bffbd917d0 --- /dev/null +++ b/media/video-stitcher/listSlates.js @@ -0,0 +1,51 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location) { + // [START video_stitcher_list_slates] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function listSlates() { + const iterable = await stitcherClient.listSlatesAsync({ + parent: stitcherClient.locationPath(projectId, location), + }); + console.info('Slates:'); + for await (const response of iterable) { + console.log(response.name); + } + } + + listSlates(); + // [END video_stitcher_list_slates] +} + +// node listSlates.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/package.json b/media/video-stitcher/package.json index 48366a7ab6..e970e12593 100644 --- a/media/video-stitcher/package.json +++ b/media/video-stitcher/package.json @@ -18,6 +18,7 @@ "devDependencies": { "c8": "^7.1.0", "chai": "^4.2.0", - "mocha": "^8.0.0" + "mocha": "^8.0.0", + "uuid": "^8.0.0" } } diff --git a/media/video-stitcher/test/stitcher.test.js b/media/video-stitcher/test/stitcher.test.js new file mode 100644 index 0000000000..66a0b99adb --- /dev/null +++ b/media/video-stitcher/test/stitcher.test.js @@ -0,0 +1,202 @@ +/** + * Copyright 2022, Google, Inc. + * 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 assert = require('assert'); +const {v4: uuidv4} = require('uuid'); +const {execSync} = require('child_process'); +const {describe, it, before, after} = require('mocha'); + +const uniqueId = uuidv4().split('-')[0]; +const bucketName = 'cloud-samples-data/media'; + +const projectId = process.env.GCLOUD_PROJECT; +const location = 'us-central1'; +const slateId = `nodejs-test-stitcher-slate-${uniqueId}`; +const slateUri = `https://storage.googleapis.com/${bucketName}/ForBiggerEscapes.mp4`; +const slateName = `/locations/${location}/slates/${slateId}`; + +const akamaiCdnKeyId = `nodejs-test-stitcher-akamai-key-${uniqueId}`; +const akamaiCdnKeyName = `/locations/${location}/cdnKeys/${akamaiCdnKeyId}`; +const googleCdnKeyId = `nodejs-test-stitcher-google-key-${uniqueId}`; +const googleCdnKeyName = `/locations/${location}/cdnKeys/${googleCdnKeyId}`; + +const hostname = 'cdn.example.com'; +const gCdnKeyname = 'gcdn-test-key'; +const gCdnPrivateKey = 'VGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg=='; +const akamaiTokenKey = 'VGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg=='; +const cwd = path.join(__dirname, '..'); + +before(async () => { + // Delete the slate if it already exists + try { + execSync(`node deleteSlate.js ${projectId} ${location} ${slateId}`, { + cwd, + }); + } catch (err) { + // Ignore not found error + } + // Delete the Akamai CDN key if it already exists + try { + execSync( + `node deleteCdnKey.js ${projectId} ${location} ${akamaiCdnKeyId}`, + { + cwd, + } + ); + } catch (err) { + // Ignore not found error + } + // Delete the Google CDN key if it already exists + try { + execSync( + `node deleteCdnKey.js ${projectId} ${location} ${googleCdnKeyId}`, + { + cwd, + } + ); + } catch (err) { + // Ignore not found error + } +}); + +after(async () => {}); + +describe('Slate functions', () => { + it('should create a slate', () => { + const output = execSync( + `node createSlate.js ${projectId} ${location} ${slateId} ${slateUri}`, + {cwd} + ); + assert.ok(output.includes(slateName)); + }); + + it('should show a list of slates', () => { + const output = execSync(`node listSlates.js ${projectId} ${location}`, { + cwd, + }); + assert.ok(output.includes(slateName)); + }); + + it('should update a slate', () => { + const output = execSync( + `node updateSlate.js ${projectId} ${location} ${slateId} ${slateUri}`, + {cwd} + ); + assert.ok(output.includes(slateName)); + }); + + it('should get a slate', () => { + const output = execSync( + `node getSlate.js ${projectId} ${location} ${slateId}`, + {cwd} + ); + assert.ok(output.includes(slateName)); + }); + + it('should delete a slate', () => { + const output = execSync( + `node deleteSlate.js ${projectId} ${location} ${slateId}`, + {cwd} + ); + assert.ok(output.includes('Deleted slate')); + }); +}); + +describe('CDN key functions', () => { + // Google CDN + + it('should create a Google CDN key', () => { + const output = execSync( + `node createCdnKey.js ${projectId} ${location} ${googleCdnKeyId} ${hostname} ${gCdnKeyname} ${gCdnPrivateKey} ''`, + {cwd} + ); + assert.ok(output.includes(googleCdnKeyName)); + }); + + it('should show a list of CDN keys', () => { + const output = execSync(`node listCdnKeys.js ${projectId} ${location}`, { + cwd, + }); + assert.ok(output.includes(googleCdnKeyName)); + }); + + it('should update a Google CDN key', () => { + const output = execSync( + `node updateCdnKey.js ${projectId} ${location} ${googleCdnKeyId} ${hostname} ${gCdnKeyname} ${gCdnPrivateKey} ''`, + {cwd} + ); + assert.ok(output.includes(googleCdnKeyName)); + }); + + it('should get a Google CDN key', () => { + const output = execSync( + `node getCdnKey.js ${projectId} ${location} ${googleCdnKeyId}`, + {cwd} + ); + assert.ok(output.includes(googleCdnKeyName)); + }); + + it('should delete a Google CDN key', () => { + const output = execSync( + `node deleteCdnKey.js ${projectId} ${location} ${googleCdnKeyId}`, + {cwd} + ); + assert.ok(output.includes('Deleted CDN key')); + }); + + // Akamai CDN + + it('should create an Akamai CDN key', () => { + const output = execSync( + `node createCdnKey.js ${projectId} ${location} ${akamaiCdnKeyId} ${hostname} '' '' ${akamaiTokenKey}`, + {cwd} + ); + assert.ok(output.includes(akamaiCdnKeyName)); + }); + + it('should show a list of CDN keys', () => { + const output = execSync(`node listCdnKeys.js ${projectId} ${location}`, { + cwd, + }); + assert.ok(output.includes(akamaiCdnKeyName)); + }); + + it('should update an Akamai CDN key', () => { + const output = execSync( + `node updateCdnKey.js ${projectId} ${location} ${akamaiCdnKeyId} ${hostname} '' '' ${akamaiTokenKey}`, + {cwd} + ); + assert.ok(output.includes(akamaiCdnKeyName)); + }); + + it('should get an Akamai CDN key', () => { + const output = execSync( + `node getCdnKey.js ${projectId} ${location} ${akamaiCdnKeyId}`, + {cwd} + ); + assert.ok(output.includes(akamaiCdnKeyName)); + }); + + it('should delete an Akamai CDN key', () => { + const output = execSync( + `node deleteCdnKey.js ${projectId} ${location} ${akamaiCdnKeyId}`, + {cwd} + ); + assert.ok(output.includes('Deleted CDN key')); + }); +}); diff --git a/media/video-stitcher/updateCdnKey.js b/media/video-stitcher/updateCdnKey.js new file mode 100644 index 0000000000..5d1cfe9256 --- /dev/null +++ b/media/video-stitcher/updateCdnKey.js @@ -0,0 +1,84 @@ +/** + * Copyright 2022, Google, Inc. + * 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( + projectId, + location, + cdnKeyId, + hostname, + gCdnKeyname, + gCdnPrivateKey, + akamaiTokenKey = '' +) { + // [START video_stitcher_update_cdn_key] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // cdnKeyId = 'my-cdn-key'; + // hostname = 'cdn.example.com'; + // gCdnKeyname = 'gcdn-key'; + // gCdnPrivateKey = 'VGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg=='; + // akamaiTokenKey = 'VGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg=='; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function updateCdnKey() { + // Construct request + const request = { + cdnKey: { + name: stitcherClient.cdnKeyPath(projectId, location, cdnKeyId), + hostname: hostname, + }, + }; + + if (akamaiTokenKey !== '') { + request.cdnKey.akamaiCdnKey = { + tokenKey: akamaiTokenKey, + }; + request.updateMask = { + paths: ['hostname', 'akamai_cdn_key'], + }; + } else { + request.cdnKey.googleCdnKey = { + keyName: gCdnKeyname, + privateKey: gCdnPrivateKey, + }; + request.updateMask = { + paths: ['hostname', 'google_cdn_key'], + }; + } + + const [cdnKey] = await stitcherClient.updateCdnKey(request); + console.log(`Updated CDN key: ${cdnKey.name}`); + } + + updateCdnKey(); + // [END video_stitcher_update_cdn_key] +} + +// node updateCdnKey.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/updateSlate.js b/media/video-stitcher/updateSlate.js new file mode 100644 index 0000000000..bd15424ebf --- /dev/null +++ b/media/video-stitcher/updateSlate.js @@ -0,0 +1,59 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location, slateId, slateUri) { + // [START video_stitcher_update_slate] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // slateId = 'my-slate'; + // slateUri = 'https://my-slate-uri/test.mp4'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function updateSlate() { + // Construct request + const request = { + slate: { + name: stitcherClient.slatePath(projectId, location, slateId), + uri: slateUri, + }, + updateMask: { + paths: ['uri'], + }, + }; + + const [slate] = await stitcherClient.updateSlate(request); + console.log(`Updated slate: ${slate.name}`); + } + + updateSlate(); + // [END video_stitcher_update_slate] +} + +// node updateSlate.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); From f4fe7e1b3eb509cb2aafde916ff778565018c6fe Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Tue, 14 Jun 2022 17:06:57 -0700 Subject: [PATCH 04/14] =?UTF-8?q?docs(samples):=20add=20Video=20Stitcher?= =?UTF-8?q?=20VOD=20and=20live=20session=20code=20samples=20a=E2=80=A6=20(?= =?UTF-8?q?#9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs(samples): add Video Stitcher VOD and live session code samples and tests * Remove async from slate and live session before and after hooks * clean out old slates and CDN keys * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * update SHA Co-authored-by: sofisl <55454395+sofisl@users.noreply.github.com> Co-authored-by: Owl Bot --- media/video-stitcher/createLiveSession.js | 66 +++++ media/video-stitcher/createVodSession.js | 58 ++++ media/video-stitcher/getLiveAdTagDetail.js | 57 ++++ media/video-stitcher/getLiveSession.js | 51 ++++ media/video-stitcher/getVodAdTagDetail.js | 57 ++++ media/video-stitcher/getVodSession.js | 51 ++++ media/video-stitcher/getVodStitchDetail.js | 57 ++++ media/video-stitcher/listLiveAdTagDetails.js | 54 ++++ media/video-stitcher/listVodAdTagDetails.js | 54 ++++ media/video-stitcher/listVodStitchDetails.js | 54 ++++ media/video-stitcher/test/stitcher.test.js | 267 ++++++++++++++++--- 11 files changed, 793 insertions(+), 33 deletions(-) create mode 100644 media/video-stitcher/createLiveSession.js create mode 100644 media/video-stitcher/createVodSession.js create mode 100644 media/video-stitcher/getLiveAdTagDetail.js create mode 100644 media/video-stitcher/getLiveSession.js create mode 100644 media/video-stitcher/getVodAdTagDetail.js create mode 100644 media/video-stitcher/getVodSession.js create mode 100644 media/video-stitcher/getVodStitchDetail.js create mode 100644 media/video-stitcher/listLiveAdTagDetails.js create mode 100644 media/video-stitcher/listVodAdTagDetails.js create mode 100644 media/video-stitcher/listVodStitchDetails.js diff --git a/media/video-stitcher/createLiveSession.js b/media/video-stitcher/createLiveSession.js new file mode 100644 index 0000000000..4b9ee5c0f3 --- /dev/null +++ b/media/video-stitcher/createLiveSession.js @@ -0,0 +1,66 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location, sourceUri, adTagUri, slateId) { + // [START video_stitcher_create_live_session] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // sourceUri = 'https://storage.googleapis.com/my-bucket/main.mpd'; + // Single Inline Linear (https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags) + // (https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags) + // adTagUri = 'https://pubads.g.doubleclick.net/gampad/ads...'; + // slateId = 'my-slate'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function createLiveSession() { + // Construct request + const request = { + parent: stitcherClient.locationPath(projectId, location), + liveSession: { + sourceUri: sourceUri, + adTagMap: { + default: { + uri: adTagUri, + }, + }, + defaultSlateId: slateId, + }, + }; + + const [session] = await stitcherClient.createLiveSession(request); + console.log(`Live session: ${session.name}`); + console.log(`Play URI: ${session.playUri}`); + } + + createLiveSession(); + // [END video_stitcher_create_live_session] +} + +// node createLiveSession.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/createVodSession.js b/media/video-stitcher/createVodSession.js new file mode 100644 index 0000000000..728a8b1a94 --- /dev/null +++ b/media/video-stitcher/createVodSession.js @@ -0,0 +1,58 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location, sourceUri, adTagUri) { + // [START video_stitcher_create_vod_session] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // sourceUri = 'https://storage.googleapis.com/my-bucket/main.mpd'; + // See VMAP Pre-roll + // (https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags) + // adTagUri = 'https://pubads.g.doubleclick.net/gampad/ads...'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function createVodSession() { + // Construct request + const request = { + parent: stitcherClient.locationPath(projectId, location), + vodSession: { + sourceUri: sourceUri, + adTagUri: adTagUri, + }, + }; + const [session] = await stitcherClient.createVodSession(request); + console.log(`VOD session: ${session.name}`); + } + + createVodSession(); + // [END video_stitcher_create_vod_session] +} + +// node createVodSession.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/getLiveAdTagDetail.js b/media/video-stitcher/getLiveAdTagDetail.js new file mode 100644 index 0000000000..bd0489cefd --- /dev/null +++ b/media/video-stitcher/getLiveAdTagDetail.js @@ -0,0 +1,57 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location, sessionId, adTagDetailId) { + // [START video_stitcher_get_live_ad_tag_detail] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // sessionId = 'my-session-id'; + // adTagDetailId = 'my-ad-tag-detail-id'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function getLiveAdTagDetail() { + // Construct request + const request = { + name: stitcherClient.liveAdTagDetailPath( + projectId, + location, + sessionId, + adTagDetailId + ), + }; + const [adTagDetail] = await stitcherClient.getLiveAdTagDetail(request); + console.log(`Live ad tag detail: ${adTagDetail.name}`); + } + + getLiveAdTagDetail(); + // [END video_stitcher_get_live_ad_tag_detail] +} + +// node getLiveAdTagDetail.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/getLiveSession.js b/media/video-stitcher/getLiveSession.js new file mode 100644 index 0000000000..99ea1c6016 --- /dev/null +++ b/media/video-stitcher/getLiveSession.js @@ -0,0 +1,51 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location, sessionId) { + // [START video_stitcher_get_live_session] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // sessionId = 'my-session-id'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function getLiveSession() { + // Construct request + const request = { + name: stitcherClient.liveSessionPath(projectId, location, sessionId), + }; + const [session] = await stitcherClient.getLiveSession(request); + console.log(`Live session: ${session.name}`); + } + + getLiveSession(); + // [END video_stitcher_get_live_session] +} + +// node getLiveSession.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/getVodAdTagDetail.js b/media/video-stitcher/getVodAdTagDetail.js new file mode 100644 index 0000000000..ec1fcdabea --- /dev/null +++ b/media/video-stitcher/getVodAdTagDetail.js @@ -0,0 +1,57 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location, sessionId, adTagDetailId) { + // [START video_stitcher_get_vod_ad_tag_detail] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // sessionId = 'my-session-id'; + // adTagDetailId = 'my-ad-tag-detail-id'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function getVodAdTagDetail() { + // Construct request + const request = { + name: stitcherClient.vodAdTagDetailPath( + projectId, + location, + sessionId, + adTagDetailId + ), + }; + const [adTagDetail] = await stitcherClient.getVodAdTagDetail(request); + console.log(`VOD ad tag detail: ${adTagDetail.name}`); + } + + getVodAdTagDetail(); + // [END video_stitcher_get_vod_ad_tag_detail] +} + +// node getVodAdTagDetail.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/getVodSession.js b/media/video-stitcher/getVodSession.js new file mode 100644 index 0000000000..9ad4fe3a01 --- /dev/null +++ b/media/video-stitcher/getVodSession.js @@ -0,0 +1,51 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location, sessionId) { + // [START video_stitcher_get_vod_session] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // sessionId = 'my-session-id'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function getVodSession() { + // Construct request + const request = { + name: stitcherClient.vodSessionPath(projectId, location, sessionId), + }; + const [session] = await stitcherClient.getVodSession(request); + console.log(`VOD session: ${session.name}`); + } + + getVodSession(); + // [END video_stitcher_get_vod_session] +} + +// node getVodSession.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/getVodStitchDetail.js b/media/video-stitcher/getVodStitchDetail.js new file mode 100644 index 0000000000..1480189787 --- /dev/null +++ b/media/video-stitcher/getVodStitchDetail.js @@ -0,0 +1,57 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location, sessionId, stitchDetailId) { + // [START video_stitcher_get_vod_stitch_detail] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // sessionId = 'my-session-id'; + // stitchDetailId = 'my-stitch-detail-id'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function getVodStitchDetail() { + // Construct request + const request = { + name: stitcherClient.vodStitchDetailPath( + projectId, + location, + sessionId, + stitchDetailId + ), + }; + const [stitchDetail] = await stitcherClient.getVodStitchDetail(request); + console.log(`VOD stitch detail: ${stitchDetail.name}`); + } + + getVodStitchDetail(); + // [END video_stitcher_get_vod_stitch_detail] +} + +// node getVodStitchDetail.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/listLiveAdTagDetails.js b/media/video-stitcher/listLiveAdTagDetails.js new file mode 100644 index 0000000000..0316d2eec7 --- /dev/null +++ b/media/video-stitcher/listLiveAdTagDetails.js @@ -0,0 +1,54 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location, sessionId) { + // [START video_stitcher_list_live_ad_tag_details] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // sessionId = 'my-session-id'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function listLiveAdTagDetails() { + // Construct request + const request = { + parent: stitcherClient.liveSessionPath(projectId, location, sessionId), + }; + const iterable = await stitcherClient.listLiveAdTagDetailsAsync(request); + console.log('Live ad tag details:'); + for await (const response of iterable) { + console.log(response.name); + } + } + + listLiveAdTagDetails(); + // [END video_stitcher_list_live_ad_tag_details] +} + +// node listLiveAdTagDetails.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/listVodAdTagDetails.js b/media/video-stitcher/listVodAdTagDetails.js new file mode 100644 index 0000000000..eaedc91be8 --- /dev/null +++ b/media/video-stitcher/listVodAdTagDetails.js @@ -0,0 +1,54 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location, sessionId) { + // [START video_stitcher_list_vod_ad_tag_details] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // sessionId = 'my-session-id'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function listVodAdTagDetails() { + // Construct request + const request = { + parent: stitcherClient.vodSessionPath(projectId, location, sessionId), + }; + const iterable = await stitcherClient.listVodAdTagDetailsAsync(request); + console.log('VOD ad tag details:'); + for await (const response of iterable) { + console.log(response.name); + } + } + + listVodAdTagDetails(); + // [END video_stitcher_list_vod_ad_tag_details] +} + +// node listVodAdTagDetails.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/listVodStitchDetails.js b/media/video-stitcher/listVodStitchDetails.js new file mode 100644 index 0000000000..6e84f40673 --- /dev/null +++ b/media/video-stitcher/listVodStitchDetails.js @@ -0,0 +1,54 @@ +/** + * Copyright 2022, Google, Inc. + * 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(projectId, location, sessionId) { + // [START video_stitcher_list_vod_stitch_details] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // projectId = 'my-project-id'; + // location = 'us-central1'; + // sessionId = 'my-session-id'; + + // Imports the Video Stitcher library + const {VideoStitcherServiceClient} = + require('@google-cloud/video-stitcher').v1; + // Instantiates a client + const stitcherClient = new VideoStitcherServiceClient(); + + async function listVodStitchDetails() { + // Construct request + const request = { + parent: stitcherClient.vodSessionPath(projectId, location, sessionId), + }; + const iterable = await stitcherClient.listVodStitchDetailsAsync(request); + console.log('VOD stitch details:'); + for await (const response of iterable) { + console.log(response.name); + } + } + + listVodStitchDetails(); + // [END video_stitcher_list_vod_stitch_details] +} + +// node listVodStitchDetails.js +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/media/video-stitcher/test/stitcher.test.js b/media/video-stitcher/test/stitcher.test.js index 66a0b99adb..fa109189a6 100644 --- a/media/video-stitcher/test/stitcher.test.js +++ b/media/video-stitcher/test/stitcher.test.js @@ -23,59 +23,101 @@ const {describe, it, before, after} = require('mocha'); const uniqueId = uuidv4().split('-')[0]; const bucketName = 'cloud-samples-data/media'; +const vodFileName = 'hls-vod/manifest.m3u8'; +const liveFileName = 'hls-live/manifest.m3u8'; const projectId = process.env.GCLOUD_PROJECT; const location = 'us-central1'; -const slateId = `nodejs-test-stitcher-slate-${uniqueId}`; +const slateIdPrefix = 'nodejs-test-stitcher-slate-'; +const slateId = `${slateIdPrefix}${uniqueId}`; const slateUri = `https://storage.googleapis.com/${bucketName}/ForBiggerEscapes.mp4`; const slateName = `/locations/${location}/slates/${slateId}`; -const akamaiCdnKeyId = `nodejs-test-stitcher-akamai-key-${uniqueId}`; +const akamaiCdnKeyIdPrefix = 'nodejs-test-stitcher-akamai-key-'; +const akamaiCdnKeyId = `${akamaiCdnKeyIdPrefix}${uniqueId}`; const akamaiCdnKeyName = `/locations/${location}/cdnKeys/${akamaiCdnKeyId}`; -const googleCdnKeyId = `nodejs-test-stitcher-google-key-${uniqueId}`; +const googleCdnKeyIdPrefix = 'nodejs-test-stitcher-google-key-'; +const googleCdnKeyId = `${googleCdnKeyIdPrefix}${uniqueId}`; const googleCdnKeyName = `/locations/${location}/cdnKeys/${googleCdnKeyId}`; const hostname = 'cdn.example.com'; const gCdnKeyname = 'gcdn-test-key'; const gCdnPrivateKey = 'VGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg=='; const akamaiTokenKey = 'VGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg=='; + +const vodUri = `https://storage.googleapis.com/${bucketName}/${vodFileName}`; +// VMAP Pre-roll (https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags) +const vodAdTagUri = + "'https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpreonly&ciu_szs=300x250%2C728x90&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator='"; +const vodSessionPrefix = `/locations/${location}/vodSessions/`; + +const liveUri = `https://storage.googleapis.com/${bucketName}/${liveFileName}`; +// Single Inline Linear (https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags) +const liveAdTagUri = + "'https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator='"; +const liveSessionPrefix = `/locations/${location}/liveSessions/`; + +const https = require('https'); const cwd = path.join(__dirname, '..'); -before(async () => { - // Delete the slate if it already exists - try { - execSync(`node deleteSlate.js ${projectId} ${location} ${slateId}`, { - cwd, +async function getPage(url) { + let data = ''; + return new Promise(resolve => { + https.get(url, res => { + res.on('data', chunk => { + data += chunk; + }); + res.on('end', () => { + resolve(data); + }); }); - } catch (err) { - // Ignore not found error - } - // Delete the Akamai CDN key if it already exists - try { - execSync( - `node deleteCdnKey.js ${projectId} ${location} ${akamaiCdnKeyId}`, - { - cwd, + }); +} + +before(() => { + // Delete existing test slates + const slates = execSync(`node listSlates.js ${projectId} ${location}`, {cwd}); + + slates + .toString() + .split(/\r?\n/) + .forEach(line => { + if (line.includes(`locations/${location}/slates/${slateIdPrefix}`)) { + this.nextId = line.split('/').pop(); + execSync( + `node deleteSlate.js ${projectId} ${location} ${this.nextId}`, + { + cwd, + } + ); } - ); - } catch (err) { - // Ignore not found error - } - // Delete the Google CDN key if it already exists - try { - execSync( - `node deleteCdnKey.js ${projectId} ${location} ${googleCdnKeyId}`, - { - cwd, + }); + + // Delete existing test CDN keys + const keys = execSync(`node listCdnKeys.js ${projectId} ${location}`, {cwd}); + + keys + .toString() + .split(/\r?\n/) + .forEach(line => { + if ( + line.includes( + `locations/${location}/cdnKeys/${googleCdnKeyIdPrefix}` + ) || + line.includes(`locations/${location}/cdnKeys/${akamaiCdnKeyIdPrefix}`) + ) { + this.nextId = line.split('/').pop(); + + execSync( + `node deleteCdnKey.js ${projectId} ${location} ${this.nextId}`, + { + cwd, + } + ); } - ); - } catch (err) { - // Ignore not found error - } + }); }); -after(async () => {}); - describe('Slate functions', () => { it('should create a slate', () => { const output = execSync( @@ -200,3 +242,162 @@ describe('CDN key functions', () => { assert.ok(output.includes('Deleted CDN key')); }); }); + +describe('VOD session functions', () => { + it('should create a VOD session', () => { + const output = execSync( + `node createVodSession.js ${projectId} ${location} ${vodUri} ${vodAdTagUri}`, + {cwd} + ); + assert.ok(output.includes(vodSessionPrefix)); + this.vodSessionId = output.toString().split('/').pop(); + this.vodSessionId = this.vodSessionId.replace(/\r?\n|\r/g, ''); + }); + + it('should get a VOD session', () => { + const output = execSync( + `node getVodSession.js ${projectId} ${location} ${this.vodSessionId}`, + {cwd} + ); + assert.ok(output.includes(`${vodSessionPrefix}${this.vodSessionId}`)); + }); + + // No list or delete methods for VOD sessions + + // Ad tag details + + it('should show a list of ad tag details for a VOD session', () => { + const output = execSync( + `node listVodAdTagDetails.js ${projectId} ${location} ${this.vodSessionId}`, + { + cwd, + } + ); + this.adTagDetailsNamePrefix = `${vodSessionPrefix}${this.vodSessionId}/vodAdTagDetails/`; + assert.ok(output.includes(this.adTagDetailsNamePrefix)); + this.vodAdTagDetailsId = output.toString().split('/').pop(); + this.vodAdTagDetailsId = this.vodAdTagDetailsId.replace(/\r?\n|\r/g, ''); + }); + + it('should get an ad tag detail', () => { + const output = execSync( + `node getVodAdTagDetail.js ${projectId} ${location} ${this.vodSessionId} ${this.vodAdTagDetailsId}`, + {cwd} + ); + assert.ok( + output.includes(`${this.adTagDetailsNamePrefix}${this.vodAdTagDetailsId}`) + ); + }); + + // Stitch details + + it('should show a list of stitch details for a VOD session', () => { + const output = execSync( + `node listVodStitchDetails.js ${projectId} ${location} ${this.vodSessionId}`, + { + cwd, + } + ); + this.stitchDetailsNamePrefix = `${vodSessionPrefix}${this.vodSessionId}/vodStitchDetails/`; + assert.ok(output.includes(this.stitchDetailsNamePrefix)); + this.stitchDetailsId = output.toString().split('/').pop(); + this.stitchDetailsId = this.stitchDetailsId.replace(/\r?\n|\r/g, ''); + }); + + it('should get a stitch detail', () => { + const output = execSync( + `node getVodStitchDetail.js ${projectId} ${location} ${this.vodSessionId} ${this.stitchDetailsId}`, + {cwd} + ); + assert.ok( + output.includes(`${this.stitchDetailsNamePrefix}${this.stitchDetailsId}`) + ); + }); +}); + +describe('Live session functions', () => { + before(() => { + // Delete the slate if it already exists + try { + execSync(`node deleteSlate.js ${projectId} ${location} ${slateId}`, { + cwd, + }); + } catch (err) { + // Ignore not found error + } + execSync( + `node createSlate.js ${projectId} ${location} ${slateId} ${slateUri}`, + {cwd} + ); + }); + + after(() => { + execSync(`node deleteSlate.js ${projectId} ${location} ${slateId}`, {cwd}); + }); + + it('should create and get a live session and list and get ad tag details', async function () { + let output = execSync( + `node createLiveSession.js ${projectId} ${location} ${liveUri} ${liveAdTagUri} ${slateId}`, + {cwd} + ); + assert.ok(output.includes(liveSessionPrefix)); + + let match = new RegExp('Live session:.(.*)', 'g').exec(output); + this.liveSessionId = match[1].toString().split('/').pop(); + this.liveSessionId = this.liveSessionId.replace(/\r?\n|\r/g, ''); + match = new RegExp('Play URI:.(.*)', 'g').exec(output); + this.playUri = match[1].replace(/\r?\n|\r/g, ''); + + output = execSync( + `node getLiveSession.js ${projectId} ${location} ${this.liveSessionId}`, + {cwd} + ); + assert.ok(output.includes(`${liveSessionPrefix}${this.liveSessionId}`)); + + // No list or delete methods for live sessions + + // Ad tag details + + // To get ad tag details, you need to curl the main manifest and + // a rendition first. This supplies media player information to the API. + // + // Curl the playUri first. The last line of the response will contain a + // renditions location. Curl the live session name with the rendition + // location appended. + + let data = await getPage(this.playUri); + assert.ok(data.includes('renditions/')); + + match = new RegExp('renditions/.*', 'g').exec(data); + this.renditions = match[0].replace(/\r?\n|\r/g, ''); + + // playUri will be in the following format: + // .../projects/{project}/locations/{location}/liveSessions/{session-id}/manifest.m3u8?signature=... + // Replace manifest.m3u8?signature=... with the /renditions location. + + const arr = this.playUri.split('/'); + arr.pop(); + const str = arr.join('/'); + this.renditionsUrl = `${str}/${this.renditions}`; + data = await getPage(this.renditionsUrl); + + output = execSync( + `node listLiveAdTagDetails.js ${projectId} ${location} ${this.liveSessionId}`, + {cwd} + ); + this.liveAdTagDetailsNamePrefix = `${liveSessionPrefix}${this.liveSessionId}/liveAdTagDetails/`; + assert.ok(output.includes(this.liveAdTagDetailsNamePrefix)); + this.liveAdTagDetailsId = output.toString().split('/').pop(); + this.liveAdTagDetailsId = this.liveAdTagDetailsId.replace(/\r?\n|\r/g, ''); + + output = execSync( + `node getLiveAdTagDetail.js ${projectId} ${location} ${this.liveSessionId} ${this.liveAdTagDetailsId}`, + {cwd} + ); + assert.ok( + output.includes( + `${this.liveAdTagDetailsNamePrefix}${this.liveAdTagDetailsId}` + ) + ); + }); +}); From 4288c061c1b141389a4426770c4281f98c953bb8 Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Thu, 23 Jun 2022 12:09:15 -0700 Subject: [PATCH 05/14] docs(samples): add try/catch to delete operations in testing (#19) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add try/catch to delete operations in testing * refactor test file; use timestamp for resource names, clean up resources over an hour old, move create and delete operations to before and after hooks in each test suite * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- media/video-stitcher/package.json | 3 +- media/video-stitcher/test/stitcher.test.js | 192 ++++++++++++--------- 2 files changed, 115 insertions(+), 80 deletions(-) diff --git a/media/video-stitcher/package.json b/media/video-stitcher/package.json index e970e12593..48366a7ab6 100644 --- a/media/video-stitcher/package.json +++ b/media/video-stitcher/package.json @@ -18,7 +18,6 @@ "devDependencies": { "c8": "^7.1.0", "chai": "^4.2.0", - "mocha": "^8.0.0", - "uuid": "^8.0.0" + "mocha": "^8.0.0" } } diff --git a/media/video-stitcher/test/stitcher.test.js b/media/video-stitcher/test/stitcher.test.js index fa109189a6..0b63d90083 100644 --- a/media/video-stitcher/test/stitcher.test.js +++ b/media/video-stitcher/test/stitcher.test.js @@ -17,11 +17,9 @@ const path = require('path'); const assert = require('assert'); -const {v4: uuidv4} = require('uuid'); const {execSync} = require('child_process'); const {describe, it, before, after} = require('mocha'); -const uniqueId = uuidv4().split('-')[0]; const bucketName = 'cloud-samples-data/media'; const vodFileName = 'hls-vod/manifest.m3u8'; const liveFileName = 'hls-live/manifest.m3u8'; @@ -29,16 +27,10 @@ const liveFileName = 'hls-live/manifest.m3u8'; const projectId = process.env.GCLOUD_PROJECT; const location = 'us-central1'; const slateIdPrefix = 'nodejs-test-stitcher-slate-'; -const slateId = `${slateIdPrefix}${uniqueId}`; const slateUri = `https://storage.googleapis.com/${bucketName}/ForBiggerEscapes.mp4`; -const slateName = `/locations/${location}/slates/${slateId}`; const akamaiCdnKeyIdPrefix = 'nodejs-test-stitcher-akamai-key-'; -const akamaiCdnKeyId = `${akamaiCdnKeyIdPrefix}${uniqueId}`; -const akamaiCdnKeyName = `/locations/${location}/cdnKeys/${akamaiCdnKeyId}`; const googleCdnKeyIdPrefix = 'nodejs-test-stitcher-google-key-'; -const googleCdnKeyId = `${googleCdnKeyIdPrefix}${uniqueId}`; -const googleCdnKeyName = `/locations/${location}/cdnKeys/${googleCdnKeyId}`; const hostname = 'cdn.example.com'; const gCdnKeyname = 'gcdn-test-key'; @@ -75,7 +67,11 @@ async function getPage(url) { } before(() => { - // Delete existing test slates + // Delete existing test slates more than an hour old. + + const DATE_NOW_SEC = Math.floor(Date.now() / 1000); + const ONE_HOUR_IN_SEC = 60 * 60 * 1; + const slates = execSync(`node listSlates.js ${projectId} ${location}`, {cwd}); slates @@ -84,12 +80,27 @@ before(() => { .forEach(line => { if (line.includes(`locations/${location}/slates/${slateIdPrefix}`)) { this.nextId = line.split('/').pop(); - execSync( - `node deleteSlate.js ${projectId} ${location} ${this.nextId}`, - { - cwd, + let createTime = this.nextId.split('-').pop(); + createTime = parseInt(createTime); + if ( + isNaN(createTime) === false && + createTime < DATE_NOW_SEC - ONE_HOUR_IN_SEC + ) { + try { + execSync( + `node deleteSlate.js ${projectId} ${location} ${this.nextId}`, + { + cwd, + } + ); + } catch (err) { + if (err.message.includes('NOT_FOUND')) { + // Ignore not found error + } else { + throw err; // re-throw the error unchanged + } } - ); + } } }); @@ -107,139 +118,163 @@ before(() => { line.includes(`locations/${location}/cdnKeys/${akamaiCdnKeyIdPrefix}`) ) { this.nextId = line.split('/').pop(); - - execSync( - `node deleteCdnKey.js ${projectId} ${location} ${this.nextId}`, - { - cwd, + let createTime = this.nextId.split('-').pop(); + createTime = parseInt(createTime); + if ( + isNaN(createTime) === false && + createTime < DATE_NOW_SEC - ONE_HOUR_IN_SEC + ) { + try { + execSync( + `node deleteCdnKey.js ${projectId} ${location} ${this.nextId}`, + { + cwd, + } + ); + } catch (err) { + if (err.message.includes('NOT_FOUND')) { + // Ignore not found error + } else { + throw err; // re-throw the error unchanged + } } - ); + } } }); }); describe('Slate functions', () => { - it('should create a slate', () => { + before(() => { + const DATE_NOW_SEC = Math.floor(Date.now() / 1000); + this.slateId = `${slateIdPrefix}${DATE_NOW_SEC}`; + this.slateName = `/locations/${location}/slates/${this.slateId}`; + const output = execSync( - `node createSlate.js ${projectId} ${location} ${slateId} ${slateUri}`, + `node createSlate.js ${projectId} ${location} ${this.slateId} ${slateUri}`, {cwd} ); - assert.ok(output.includes(slateName)); + assert.ok(output.includes(this.slateName)); + }); + + after(() => { + const output = execSync( + `node deleteSlate.js ${projectId} ${location} ${this.slateId}`, + {cwd} + ); + assert.ok(output.includes('Deleted slate')); }); it('should show a list of slates', () => { const output = execSync(`node listSlates.js ${projectId} ${location}`, { cwd, }); - assert.ok(output.includes(slateName)); + assert.ok(output.includes(this.slateName)); }); it('should update a slate', () => { const output = execSync( - `node updateSlate.js ${projectId} ${location} ${slateId} ${slateUri}`, + `node updateSlate.js ${projectId} ${location} ${this.slateId} ${slateUri}`, {cwd} ); - assert.ok(output.includes(slateName)); + assert.ok(output.includes(this.slateName)); }); it('should get a slate', () => { const output = execSync( - `node getSlate.js ${projectId} ${location} ${slateId}`, + `node getSlate.js ${projectId} ${location} ${this.slateId}`, {cwd} ); - assert.ok(output.includes(slateName)); + assert.ok(output.includes(this.slateName)); }); +}); + +describe('Google CDN key functions', () => { + before(() => { + const DATE_NOW_SEC = Math.floor(Date.now() / 1000); + this.googleCdnKeyId = `${googleCdnKeyIdPrefix}${DATE_NOW_SEC}`; + this.googleCdnKeyName = `/locations/${location}/cdnKeys/${this.googleCdnKeyId}`; - it('should delete a slate', () => { const output = execSync( - `node deleteSlate.js ${projectId} ${location} ${slateId}`, + `node createCdnKey.js ${projectId} ${location} ${this.googleCdnKeyId} ${hostname} ${gCdnKeyname} ${gCdnPrivateKey} ''`, {cwd} ); - assert.ok(output.includes('Deleted slate')); + assert.ok(output.includes(this.googleCdnKeyName)); }); -}); - -describe('CDN key functions', () => { - // Google CDN - it('should create a Google CDN key', () => { + after(() => { const output = execSync( - `node createCdnKey.js ${projectId} ${location} ${googleCdnKeyId} ${hostname} ${gCdnKeyname} ${gCdnPrivateKey} ''`, + `node deleteCdnKey.js ${projectId} ${location} ${this.googleCdnKeyId}`, {cwd} ); - assert.ok(output.includes(googleCdnKeyName)); + assert.ok(output.includes('Deleted CDN key')); }); - it('should show a list of CDN keys', () => { + it('should show a list of Google CDN keys', () => { const output = execSync(`node listCdnKeys.js ${projectId} ${location}`, { cwd, }); - assert.ok(output.includes(googleCdnKeyName)); + assert.ok(output.includes(this.googleCdnKeyName)); }); it('should update a Google CDN key', () => { const output = execSync( - `node updateCdnKey.js ${projectId} ${location} ${googleCdnKeyId} ${hostname} ${gCdnKeyname} ${gCdnPrivateKey} ''`, + `node updateCdnKey.js ${projectId} ${location} ${this.googleCdnKeyId} ${hostname} ${gCdnKeyname} ${gCdnPrivateKey} ''`, {cwd} ); - assert.ok(output.includes(googleCdnKeyName)); + assert.ok(output.includes(this.googleCdnKeyName)); }); it('should get a Google CDN key', () => { const output = execSync( - `node getCdnKey.js ${projectId} ${location} ${googleCdnKeyId}`, + `node getCdnKey.js ${projectId} ${location} ${this.googleCdnKeyId}`, {cwd} ); - assert.ok(output.includes(googleCdnKeyName)); + assert.ok(output.includes(this.googleCdnKeyName)); }); +}); + +describe('Akamai CDN key functions', () => { + before(() => { + const DATE_NOW_SEC = Math.floor(Date.now() / 1000); + this.akamaiCdnKeyId = `${akamaiCdnKeyIdPrefix}${DATE_NOW_SEC}`; + this.akamaiCdnKeyName = `/locations/${location}/cdnKeys/${this.akamaiCdnKeyId}`; - it('should delete a Google CDN key', () => { const output = execSync( - `node deleteCdnKey.js ${projectId} ${location} ${googleCdnKeyId}`, + `node createCdnKey.js ${projectId} ${location} ${this.akamaiCdnKeyId} ${hostname} '' '' ${akamaiTokenKey}`, {cwd} ); - assert.ok(output.includes('Deleted CDN key')); + assert.ok(output.includes(this.akamaiCdnKeyName)); }); - // Akamai CDN - - it('should create an Akamai CDN key', () => { + after(() => { const output = execSync( - `node createCdnKey.js ${projectId} ${location} ${akamaiCdnKeyId} ${hostname} '' '' ${akamaiTokenKey}`, + `node deleteCdnKey.js ${projectId} ${location} ${this.akamaiCdnKeyId}`, {cwd} ); - assert.ok(output.includes(akamaiCdnKeyName)); + assert.ok(output.includes('Deleted CDN key')); }); - it('should show a list of CDN keys', () => { + it('should show a list of Akamai CDN keys', () => { const output = execSync(`node listCdnKeys.js ${projectId} ${location}`, { cwd, }); - assert.ok(output.includes(akamaiCdnKeyName)); + assert.ok(output.includes(this.akamaiCdnKeyName)); }); it('should update an Akamai CDN key', () => { const output = execSync( - `node updateCdnKey.js ${projectId} ${location} ${akamaiCdnKeyId} ${hostname} '' '' ${akamaiTokenKey}`, + `node updateCdnKey.js ${projectId} ${location} ${this.akamaiCdnKeyId} ${hostname} '' '' ${akamaiTokenKey}`, {cwd} ); - assert.ok(output.includes(akamaiCdnKeyName)); + assert.ok(output.includes(this.akamaiCdnKeyName)); }); it('should get an Akamai CDN key', () => { const output = execSync( - `node getCdnKey.js ${projectId} ${location} ${akamaiCdnKeyId}`, - {cwd} - ); - assert.ok(output.includes(akamaiCdnKeyName)); - }); - - it('should delete an Akamai CDN key', () => { - const output = execSync( - `node deleteCdnKey.js ${projectId} ${location} ${akamaiCdnKeyId}`, + `node getCdnKey.js ${projectId} ${location} ${this.akamaiCdnKeyId}`, {cwd} ); - assert.ok(output.includes('Deleted CDN key')); + assert.ok(output.includes(this.akamaiCdnKeyName)); }); }); @@ -317,27 +352,28 @@ describe('VOD session functions', () => { describe('Live session functions', () => { before(() => { - // Delete the slate if it already exists - try { - execSync(`node deleteSlate.js ${projectId} ${location} ${slateId}`, { - cwd, - }); - } catch (err) { - // Ignore not found error - } - execSync( - `node createSlate.js ${projectId} ${location} ${slateId} ${slateUri}`, + const DATE_NOW_SEC = Math.floor(Date.now() / 1000); + this.slateId = `${slateIdPrefix}${DATE_NOW_SEC}`; + this.slateName = `/locations/${location}/slates/${this.slateId}`; + + const output = execSync( + `node createSlate.js ${projectId} ${location} ${this.slateId} ${slateUri}`, {cwd} ); + assert.ok(output.includes(this.slateName)); }); after(() => { - execSync(`node deleteSlate.js ${projectId} ${location} ${slateId}`, {cwd}); + const output = execSync( + `node deleteSlate.js ${projectId} ${location} ${this.slateId}`, + {cwd} + ); + assert.ok(output.includes('Deleted slate')); }); it('should create and get a live session and list and get ad tag details', async function () { let output = execSync( - `node createLiveSession.js ${projectId} ${location} ${liveUri} ${liveAdTagUri} ${slateId}`, + `node createLiveSession.js ${projectId} ${location} ${liveUri} ${liveAdTagUri} ${this.slateId}`, {cwd} ); assert.ok(output.includes(liveSessionPrefix)); From bcb4ca85c8da5b358a0aaf70e536481929899d20 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 30 Jun 2022 19:08:20 +0000 Subject: [PATCH 06/14] chore(main): release 0.1.1 (#16) :robot: I have created a release *beep* *boop* --- ## [0.1.1](https://github.com/googleapis/nodejs-video-stitcher/compare/v0.1.0...v0.1.1) (2022-06-23) ### Bug Fixes * **deps:** update dependency google-gax to v3 ([#15](https://github.com/googleapis/nodejs-video-stitcher/issues/15)) ([345085f](https://github.com/googleapis/nodejs-video-stitcher/commit/345085f378b7ab6299a593cd8f8d200160b6106e)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- media/video-stitcher/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/video-stitcher/package.json b/media/video-stitcher/package.json index 48366a7ab6..d626a2123e 100644 --- a/media/video-stitcher/package.json +++ b/media/video-stitcher/package.json @@ -13,7 +13,7 @@ "test": "c8 mocha --timeout 600000 test/*.js" }, "dependencies": { - "@google-cloud/video-stitcher": "^0.1.0" + "@google-cloud/video-stitcher": "^0.1.1" }, "devDependencies": { "c8": "^7.1.0", From c56e63ff74f049b74d5daeb4dbce4b6f51b627a6 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 4 Jul 2022 14:41:41 -0400 Subject: [PATCH 07/14] chore(main): release 0.2.0 (#21) See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Owl Bot --- media/video-stitcher/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/video-stitcher/package.json b/media/video-stitcher/package.json index d626a2123e..1847de3918 100644 --- a/media/video-stitcher/package.json +++ b/media/video-stitcher/package.json @@ -13,7 +13,7 @@ "test": "c8 mocha --timeout 600000 test/*.js" }, "dependencies": { - "@google-cloud/video-stitcher": "^0.1.1" + "@google-cloud/video-stitcher": "^0.2.0" }, "devDependencies": { "c8": "^7.1.0", From e0ecf60bb665b24db5cdeada0a61d4a6f67e05a8 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Fri, 26 Aug 2022 12:11:26 -0700 Subject: [PATCH 08/14] chore(main): release 0.2.1 (#25) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(main): release 0.2.1 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Owl Bot --- media/video-stitcher/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/video-stitcher/package.json b/media/video-stitcher/package.json index 1847de3918..01e31a924f 100644 --- a/media/video-stitcher/package.json +++ b/media/video-stitcher/package.json @@ -13,7 +13,7 @@ "test": "c8 mocha --timeout 600000 test/*.js" }, "dependencies": { - "@google-cloud/video-stitcher": "^0.2.0" + "@google-cloud/video-stitcher": "^0.2.1" }, "devDependencies": { "c8": "^7.1.0", From d347f08c14199dfc0f6dd5744edc11853e42d95f Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 7 Sep 2022 17:52:43 -0400 Subject: [PATCH 09/14] chore(main): release 0.2.2 (#29) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(main): release 0.2.2 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Owl Bot --- media/video-stitcher/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/video-stitcher/package.json b/media/video-stitcher/package.json index 01e31a924f..617faa43e4 100644 --- a/media/video-stitcher/package.json +++ b/media/video-stitcher/package.json @@ -13,7 +13,7 @@ "test": "c8 mocha --timeout 600000 test/*.js" }, "dependencies": { - "@google-cloud/video-stitcher": "^0.2.1" + "@google-cloud/video-stitcher": "^0.2.2" }, "devDependencies": { "c8": "^7.1.0", From 800dbccebd308c297b85a3b8a0cc38c15f91bdd7 Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Wed, 12 Oct 2022 12:58:34 -0700 Subject: [PATCH 10/14] docs(samples): Fix Video Stitcher region tag prefix (#36) --- media/video-stitcher/createCdnKey.js | 4 ++-- media/video-stitcher/createLiveSession.js | 4 ++-- media/video-stitcher/createSlate.js | 4 ++-- media/video-stitcher/createVodSession.js | 4 ++-- media/video-stitcher/deleteCdnKey.js | 4 ++-- media/video-stitcher/deleteSlate.js | 4 ++-- media/video-stitcher/getCdnKey.js | 4 ++-- media/video-stitcher/getLiveAdTagDetail.js | 4 ++-- media/video-stitcher/getLiveSession.js | 4 ++-- media/video-stitcher/getSlate.js | 4 ++-- media/video-stitcher/getVodAdTagDetail.js | 4 ++-- media/video-stitcher/getVodSession.js | 4 ++-- media/video-stitcher/getVodStitchDetail.js | 4 ++-- media/video-stitcher/listCdnKeys.js | 4 ++-- media/video-stitcher/listLiveAdTagDetails.js | 4 ++-- media/video-stitcher/listSlates.js | 4 ++-- media/video-stitcher/listVodAdTagDetails.js | 4 ++-- media/video-stitcher/listVodStitchDetails.js | 4 ++-- media/video-stitcher/updateCdnKey.js | 4 ++-- media/video-stitcher/updateSlate.js | 4 ++-- 20 files changed, 40 insertions(+), 40 deletions(-) diff --git a/media/video-stitcher/createCdnKey.js b/media/video-stitcher/createCdnKey.js index bb456575be..debcf573ec 100644 --- a/media/video-stitcher/createCdnKey.js +++ b/media/video-stitcher/createCdnKey.js @@ -24,7 +24,7 @@ function main( gCdnPrivateKey, akamaiTokenKey = '' ) { - // [START video_stitcher_create_cdn_key] + // [START videostitcher_create_cdn_key] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -68,7 +68,7 @@ function main( } createCdnKey(); - // [END video_stitcher_create_cdn_key] + // [END videostitcher_create_cdn_key] } // node createCdnKey.js diff --git a/media/video-stitcher/createLiveSession.js b/media/video-stitcher/createLiveSession.js index 4b9ee5c0f3..2f9dc62e7a 100644 --- a/media/video-stitcher/createLiveSession.js +++ b/media/video-stitcher/createLiveSession.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location, sourceUri, adTagUri, slateId) { - // [START video_stitcher_create_live_session] + // [START videostitcher_create_live_session] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -55,7 +55,7 @@ function main(projectId, location, sourceUri, adTagUri, slateId) { } createLiveSession(); - // [END video_stitcher_create_live_session] + // [END videostitcher_create_live_session] } // node createLiveSession.js diff --git a/media/video-stitcher/createSlate.js b/media/video-stitcher/createSlate.js index 763aaed14c..d273e33e3e 100644 --- a/media/video-stitcher/createSlate.js +++ b/media/video-stitcher/createSlate.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location, slateId, slateUri) { - // [START video_stitcher_create_slate] + // [START videostitcher_create_slate] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -45,7 +45,7 @@ function main(projectId, location, slateId, slateUri) { } createSlate(); - // [END video_stitcher_create_slate] + // [END videostitcher_create_slate] } // node createSlate.js diff --git a/media/video-stitcher/createVodSession.js b/media/video-stitcher/createVodSession.js index 728a8b1a94..acc9d29de4 100644 --- a/media/video-stitcher/createVodSession.js +++ b/media/video-stitcher/createVodSession.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location, sourceUri, adTagUri) { - // [START video_stitcher_create_vod_session] + // [START videostitcher_create_vod_session] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -47,7 +47,7 @@ function main(projectId, location, sourceUri, adTagUri) { } createVodSession(); - // [END video_stitcher_create_vod_session] + // [END videostitcher_create_vod_session] } // node createVodSession.js diff --git a/media/video-stitcher/deleteCdnKey.js b/media/video-stitcher/deleteCdnKey.js index 2e71cac996..6c179ffe76 100644 --- a/media/video-stitcher/deleteCdnKey.js +++ b/media/video-stitcher/deleteCdnKey.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location, cdnKeyId) { - // [START video_stitcher_delete_cdn_key] + // [START videostitcher_delete_cdn_key] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -40,7 +40,7 @@ function main(projectId, location, cdnKeyId) { } deleteCdnKey(); - // [END video_stitcher_delete_cdn_key] + // [END videostitcher_delete_cdn_key] } // node deleteCdnKey.js diff --git a/media/video-stitcher/deleteSlate.js b/media/video-stitcher/deleteSlate.js index 0dd0536b0a..f295653b3f 100644 --- a/media/video-stitcher/deleteSlate.js +++ b/media/video-stitcher/deleteSlate.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location, slateId) { - // [START video_stitcher_delete_slate] + // [START videostitcher_delete_slate] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -40,7 +40,7 @@ function main(projectId, location, slateId) { } deleteSlate(); - // [END video_stitcher_delete_slate] + // [END videostitcher_delete_slate] } // node deleteSlate.js diff --git a/media/video-stitcher/getCdnKey.js b/media/video-stitcher/getCdnKey.js index 57a27c6de2..9666b944ff 100644 --- a/media/video-stitcher/getCdnKey.js +++ b/media/video-stitcher/getCdnKey.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location, cdnKeyId) { - // [START video_stitcher_get_cdn_key] + // [START videostitcher_get_cdn_key] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -40,7 +40,7 @@ function main(projectId, location, cdnKeyId) { } getCdnKey(); - // [END video_stitcher_get_cdn_key] + // [END videostitcher_get_cdn_key] } // node getCdnKey.js diff --git a/media/video-stitcher/getLiveAdTagDetail.js b/media/video-stitcher/getLiveAdTagDetail.js index bd0489cefd..00b3913307 100644 --- a/media/video-stitcher/getLiveAdTagDetail.js +++ b/media/video-stitcher/getLiveAdTagDetail.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location, sessionId, adTagDetailId) { - // [START video_stitcher_get_live_ad_tag_detail] + // [START videostitcher_get_live_ad_tag_detail] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -46,7 +46,7 @@ function main(projectId, location, sessionId, adTagDetailId) { } getLiveAdTagDetail(); - // [END video_stitcher_get_live_ad_tag_detail] + // [END videostitcher_get_live_ad_tag_detail] } // node getLiveAdTagDetail.js diff --git a/media/video-stitcher/getLiveSession.js b/media/video-stitcher/getLiveSession.js index 99ea1c6016..b933b63e4a 100644 --- a/media/video-stitcher/getLiveSession.js +++ b/media/video-stitcher/getLiveSession.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location, sessionId) { - // [START video_stitcher_get_live_session] + // [START videostitcher_get_live_session] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -40,7 +40,7 @@ function main(projectId, location, sessionId) { } getLiveSession(); - // [END video_stitcher_get_live_session] + // [END videostitcher_get_live_session] } // node getLiveSession.js diff --git a/media/video-stitcher/getSlate.js b/media/video-stitcher/getSlate.js index 36908d8f41..5cc2161001 100644 --- a/media/video-stitcher/getSlate.js +++ b/media/video-stitcher/getSlate.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location, slateId) { - // [START video_stitcher_get_slate] + // [START videostitcher_get_slate] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -40,7 +40,7 @@ function main(projectId, location, slateId) { } getSlate(); - // [END video_stitcher_get_slate] + // [END videostitcher_get_slate] } // node getSlate.js diff --git a/media/video-stitcher/getVodAdTagDetail.js b/media/video-stitcher/getVodAdTagDetail.js index ec1fcdabea..2004c6609b 100644 --- a/media/video-stitcher/getVodAdTagDetail.js +++ b/media/video-stitcher/getVodAdTagDetail.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location, sessionId, adTagDetailId) { - // [START video_stitcher_get_vod_ad_tag_detail] + // [START videostitcher_get_vod_ad_tag_detail] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -46,7 +46,7 @@ function main(projectId, location, sessionId, adTagDetailId) { } getVodAdTagDetail(); - // [END video_stitcher_get_vod_ad_tag_detail] + // [END videostitcher_get_vod_ad_tag_detail] } // node getVodAdTagDetail.js diff --git a/media/video-stitcher/getVodSession.js b/media/video-stitcher/getVodSession.js index 9ad4fe3a01..17e2bb7f12 100644 --- a/media/video-stitcher/getVodSession.js +++ b/media/video-stitcher/getVodSession.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location, sessionId) { - // [START video_stitcher_get_vod_session] + // [START videostitcher_get_vod_session] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -40,7 +40,7 @@ function main(projectId, location, sessionId) { } getVodSession(); - // [END video_stitcher_get_vod_session] + // [END videostitcher_get_vod_session] } // node getVodSession.js diff --git a/media/video-stitcher/getVodStitchDetail.js b/media/video-stitcher/getVodStitchDetail.js index 1480189787..e31f5bbba3 100644 --- a/media/video-stitcher/getVodStitchDetail.js +++ b/media/video-stitcher/getVodStitchDetail.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location, sessionId, stitchDetailId) { - // [START video_stitcher_get_vod_stitch_detail] + // [START videostitcher_get_vod_stitch_detail] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -46,7 +46,7 @@ function main(projectId, location, sessionId, stitchDetailId) { } getVodStitchDetail(); - // [END video_stitcher_get_vod_stitch_detail] + // [END videostitcher_get_vod_stitch_detail] } // node getVodStitchDetail.js diff --git a/media/video-stitcher/listCdnKeys.js b/media/video-stitcher/listCdnKeys.js index 70372888e0..9ec5f97f9f 100644 --- a/media/video-stitcher/listCdnKeys.js +++ b/media/video-stitcher/listCdnKeys.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location) { - // [START video_stitcher_list_cdn_keys] + // [START videostitcher_list_cdn_keys] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -40,7 +40,7 @@ function main(projectId, location) { } listCdnKeys(); - // [END video_stitcher_list_cdn_keys] + // [END videostitcher_list_cdn_keys] } // node listCdnKeys.js diff --git a/media/video-stitcher/listLiveAdTagDetails.js b/media/video-stitcher/listLiveAdTagDetails.js index 0316d2eec7..1fe9d06c70 100644 --- a/media/video-stitcher/listLiveAdTagDetails.js +++ b/media/video-stitcher/listLiveAdTagDetails.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location, sessionId) { - // [START video_stitcher_list_live_ad_tag_details] + // [START videostitcher_list_live_ad_tag_details] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -43,7 +43,7 @@ function main(projectId, location, sessionId) { } listLiveAdTagDetails(); - // [END video_stitcher_list_live_ad_tag_details] + // [END videostitcher_list_live_ad_tag_details] } // node listLiveAdTagDetails.js diff --git a/media/video-stitcher/listSlates.js b/media/video-stitcher/listSlates.js index bffbd917d0..3a49b6bd89 100644 --- a/media/video-stitcher/listSlates.js +++ b/media/video-stitcher/listSlates.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location) { - // [START video_stitcher_list_slates] + // [START videostitcher_list_slates] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -40,7 +40,7 @@ function main(projectId, location) { } listSlates(); - // [END video_stitcher_list_slates] + // [END videostitcher_list_slates] } // node listSlates.js diff --git a/media/video-stitcher/listVodAdTagDetails.js b/media/video-stitcher/listVodAdTagDetails.js index eaedc91be8..3b80e1d2bd 100644 --- a/media/video-stitcher/listVodAdTagDetails.js +++ b/media/video-stitcher/listVodAdTagDetails.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location, sessionId) { - // [START video_stitcher_list_vod_ad_tag_details] + // [START videostitcher_list_vod_ad_tag_details] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -43,7 +43,7 @@ function main(projectId, location, sessionId) { } listVodAdTagDetails(); - // [END video_stitcher_list_vod_ad_tag_details] + // [END videostitcher_list_vod_ad_tag_details] } // node listVodAdTagDetails.js diff --git a/media/video-stitcher/listVodStitchDetails.js b/media/video-stitcher/listVodStitchDetails.js index 6e84f40673..842d63fe7a 100644 --- a/media/video-stitcher/listVodStitchDetails.js +++ b/media/video-stitcher/listVodStitchDetails.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location, sessionId) { - // [START video_stitcher_list_vod_stitch_details] + // [START videostitcher_list_vod_stitch_details] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -43,7 +43,7 @@ function main(projectId, location, sessionId) { } listVodStitchDetails(); - // [END video_stitcher_list_vod_stitch_details] + // [END videostitcher_list_vod_stitch_details] } // node listVodStitchDetails.js diff --git a/media/video-stitcher/updateCdnKey.js b/media/video-stitcher/updateCdnKey.js index 5d1cfe9256..2ae161be71 100644 --- a/media/video-stitcher/updateCdnKey.js +++ b/media/video-stitcher/updateCdnKey.js @@ -24,7 +24,7 @@ function main( gCdnPrivateKey, akamaiTokenKey = '' ) { - // [START video_stitcher_update_cdn_key] + // [START videostitcher_update_cdn_key] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -73,7 +73,7 @@ function main( } updateCdnKey(); - // [END video_stitcher_update_cdn_key] + // [END videostitcher_update_cdn_key] } // node updateCdnKey.js diff --git a/media/video-stitcher/updateSlate.js b/media/video-stitcher/updateSlate.js index bd15424ebf..9b6b0aa92d 100644 --- a/media/video-stitcher/updateSlate.js +++ b/media/video-stitcher/updateSlate.js @@ -16,7 +16,7 @@ 'use strict'; function main(projectId, location, slateId, slateUri) { - // [START video_stitcher_update_slate] + // [START videostitcher_update_slate] /** * TODO(developer): Uncomment these variables before running the sample. */ @@ -48,7 +48,7 @@ function main(projectId, location, slateId, slateUri) { } updateSlate(); - // [END video_stitcher_update_slate] + // [END videostitcher_update_slate] } // node updateSlate.js From d1e8fc9e4079ad4e492c934c58055ce9cf5978c7 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 20 Dec 2022 17:10:15 +0000 Subject: [PATCH 11/14] chore(main): release 0.3.0 (#30) :robot: I have created a release *beep* *boop* --- ## [0.3.0](https://togithub.com/googleapis/nodejs-video-stitcher/compare/v0.2.2...v0.3.0) (2022-12-20) ### Features * Add support for Media CDN ([83f1257](https://togithub.com/googleapis/nodejs-video-stitcher/commit/83f1257b790abc8ef7acedb8e009ef5e94a0c710)) ### Bug Fixes * **deps:** Use google-gax v3.5.2 ([#40](https://togithub.com/googleapis/nodejs-video-stitcher/issues/40)) ([effa481](https://togithub.com/googleapis/nodejs-video-stitcher/commit/effa4814da8b7d81b6c5be6b6e580a683f02c50e)) * Do not import the whole google-gax from proto JS ([#1553](https://togithub.com/googleapis/nodejs-video-stitcher/issues/1553)) ([#27](https://togithub.com/googleapis/nodejs-video-stitcher/issues/27)) ([b7fe723](https://togithub.com/googleapis/nodejs-video-stitcher/commit/b7fe723d1a2dfb229b69640ca749398805573e56)) * Preserve default values in x-goog-request-params header ([#32](https://togithub.com/googleapis/nodejs-video-stitcher/issues/32)) ([28c3214](https://togithub.com/googleapis/nodejs-video-stitcher/commit/28c32148f4707550c6c6a143c7556560d6b21230)) * Regenerated protos JS and TS definitions ([#43](https://togithub.com/googleapis/nodejs-video-stitcher/issues/43)) ([8f7481e](https://togithub.com/googleapis/nodejs-video-stitcher/commit/8f7481ed1f5fc054abe6430e43570851c39740d0)) --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please). --- media/video-stitcher/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/video-stitcher/package.json b/media/video-stitcher/package.json index 617faa43e4..cbb4283721 100644 --- a/media/video-stitcher/package.json +++ b/media/video-stitcher/package.json @@ -13,7 +13,7 @@ "test": "c8 mocha --timeout 600000 test/*.js" }, "dependencies": { - "@google-cloud/video-stitcher": "^0.2.2" + "@google-cloud/video-stitcher": "^0.3.0" }, "devDependencies": { "c8": "^7.1.0", From 63c6947589de9c67e0ffc3f6348f827920d16df0 Mon Sep 17 00:00:00 2001 From: Nick Cook Date: Fri, 13 Jan 2023 14:26:03 -0800 Subject: [PATCH 12/14] add workflows and owners --- .github/workflows/media-video-stitcher.yaml | 71 +++++++++++++++++++++ .github/workflows/workflows.json | 1 + CODEOWNERS | 1 + 3 files changed, 73 insertions(+) create mode 100644 .github/workflows/media-video-stitcher.yaml diff --git a/.github/workflows/media-video-stitcher.yaml b/.github/workflows/media-video-stitcher.yaml new file mode 100644 index 0000000000..26a384f684 --- /dev/null +++ b/.github/workflows/media-video-stitcher.yaml @@ -0,0 +1,71 @@ +name: media-video-stitcher +on: + push: + branches: + - main + paths: + - 'media/video-stitcher/**' + - '.github/workflows/media-video-stitcher.yaml' + pull_request: + paths: + - 'media/video-stitcher/**' + - '.github/workflows/media-video-stitcher.yaml' + pull_request_target: + types: [labeled] + paths: + - 'media/video-stitcher/**' + - '.github/workflows/media-video-stitcher.yaml' + schedule: + - cron: '0 0 * * 0' +jobs: + test: + if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} + runs-on: ubuntu-latest + timeout-minutes: 60 + permissions: + contents: 'write' + pull-requests: 'write' + id-token: 'write' + steps: + - uses: actions/checkout@v3.1.0 + with: + ref: ${{github.event.pull_request.head.sha}} + - uses: 'google-github-actions/auth@v1.0.0' + with: + workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' + service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' + create_credentials_file: 'true' + access_token_lifetime: 600s + - uses: actions/setup-node@v3.5.1 + with: + node-version: 16 + - run: npm install + working-directory: media/video-stitcher + - run: npm test + working-directory: media/video-stitcher + env: + MOCHA_REPORTER_SUITENAME: media_video_stitcher + MOCHA_REPORTER_OUTPUT: media_video_stitcher_sponge_log.xml + MOCHA_REPORTER: xunit + - if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }} + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + try { + await github.rest.issues.removeLabel({ + name: 'actions:force-run', + owner: 'GoogleCloudPlatform', + repo: 'nodejs-docs-samples', + issue_number: context.payload.pull_request.number + }); + } catch (e) { + if (!e.message.includes('Label does not exist')) { + throw e; + } + } + - if: ${{ github.event_name == 'schedule' && always() }} + run: | + curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L + chmod +x ./flakybot + ./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} diff --git a/.github/workflows/workflows.json b/.github/workflows/workflows.json index a920b52213..6f5ca40618 100644 --- a/.github/workflows/workflows.json +++ b/.github/workflows/workflows.json @@ -69,6 +69,7 @@ "healthcare/hl7v2", "iam", "kms", + "media/video-stitcher", "mediatranslation", "monitoring/opencensus", "monitoring/prometheus", diff --git a/CODEOWNERS b/CODEOWNERS index 638ba27838..1687a17d13 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -76,3 +76,4 @@ vision @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-revi # Self-service retail @GoogleCloudPlatform/cloud-retail-team @GoogleCloudPlatform/nodejs-samples-reviewers +media @GoogleCloudPlatform/cloud-media-team @GoogleCloudPlatform/nodejs-samples-reviewers \ No newline at end of file From 23f28716208dcc5cf4402d3501a87d861100cfbe Mon Sep 17 00:00:00 2001 From: Nick Cook Date: Fri, 13 Jan 2023 14:36:33 -0800 Subject: [PATCH 13/14] add newline --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index 1687a17d13..750ba5cc87 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -76,4 +76,4 @@ vision @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-revi # Self-service retail @GoogleCloudPlatform/cloud-retail-team @GoogleCloudPlatform/nodejs-samples-reviewers -media @GoogleCloudPlatform/cloud-media-team @GoogleCloudPlatform/nodejs-samples-reviewers \ No newline at end of file +media @GoogleCloudPlatform/cloud-media-team @GoogleCloudPlatform/nodejs-samples-reviewers From c76cbb501ba4f9bb75709eab5bc7b96f2b2f2dfc Mon Sep 17 00:00:00 2001 From: Nick Cook Date: Fri, 13 Jan 2023 15:14:59 -0800 Subject: [PATCH 14/14] remove quickstart sample and test; not used in documentation --- media/video-stitcher/quickstart.js | 78 ------------------------- media/video-stitcher/test/quickstart.js | 50 ---------------- 2 files changed, 128 deletions(-) delete mode 100644 media/video-stitcher/quickstart.js delete mode 100644 media/video-stitcher/test/quickstart.js diff --git a/media/video-stitcher/quickstart.js b/media/video-stitcher/quickstart.js deleted file mode 100644 index 3f07eb5165..0000000000 --- a/media/video-stitcher/quickstart.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -function main(parent) { - // [START videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project that contains the list of CDN keys, in the form of - * `projects/{project_number}/locations/{location}`. - */ - // const parent = 'abc123' - /** - * Requested page size. Server may return fewer items than requested. - * If unspecified, server will pick an appropriate default. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results the server should return. - */ - // const pageToken = 'abc123' - /** - * Filtering results - */ - // const filter = 'abc123' - /** - * Hint for how to order the results - */ - // const orderBy = 'abc123' - - // Imports the Stitcher library - const {VideoStitcherServiceClient} = - require('@google-cloud/video-stitcher').v1; - - // Instantiates a client - const stitcherClient = new VideoStitcherServiceClient(); - - async function callListCdnKeys() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await stitcherClient.listCdnKeysAsync(request); - for await (const response of iterable) { - console.log(response); - } - console.log(iterable); - } - - callListCdnKeys(); - // [END videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/media/video-stitcher/test/quickstart.js b/media/video-stitcher/test/quickstart.js deleted file mode 100644 index 073e774bc3..0000000000 --- a/media/video-stitcher/test/quickstart.js +++ /dev/null @@ -1,50 +0,0 @@ -// -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -const path = require('path'); -const cp = require('child_process'); -const {before, describe, it} = require('mocha'); -// eslint-disable-next-line node/no-missing-require -const {VideoStitcherServiceClient} = require('@google-cloud/video-stitcher'); -// eslint-disable-next-line no-unused-vars, node/no-missing-require -const {assert} = require('chai'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const cwd = path.join(__dirname, '..'); - -const client = new VideoStitcherServiceClient(); - -describe('Quickstart', () => { - // eslint-disable-next-line no-unused-vars - let projectId; - - before(async () => { - // eslint-disable-next-line no-unused-vars - projectId = await client.getProjectId(); - }); - - it('should run quickstart', async () => { - const stdout = execSync( - `node ./quickstart.js projects/${projectId}/locations/us-central1`, - {cwd} - ); - assert(stdout, stdout !== null); - }); -});