From 76a98abc7dc920973e594b490125b79c572d40d3 Mon Sep 17 00:00:00 2001 From: Nicholas Cook Date: Fri, 20 Aug 2021 12:56:15 -0700 Subject: [PATCH] docs: update Transcoder API samples to v1 (#99) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: update Transcoder API samples to v1 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Address feedback. Co-authored-by: Owl Bot Co-authored-by: sofisl <55454395+sofisl@users.noreply.github.com> --- media/transcoder/createJobFromAdHoc.js | 25 +++++++++++-------- media/transcoder/createJobFromPreset.js | 3 ++- media/transcoder/createJobFromTemplate.js | 3 ++- media/transcoder/createJobTemplate.js | 25 +++++++++++-------- .../createJobWithAnimatedOverlay.js | 14 ++++++----- .../createJobWithPeriodicImagesSpritesheet.js | 14 ++++++----- ...createJobWithSetNumberImagesSpritesheet.js | 14 ++++++----- .../transcoder/createJobWithStaticOverlay.js | 14 ++++++----- media/transcoder/deleteJob.js | 3 ++- media/transcoder/deleteJobTemplate.js | 3 ++- media/transcoder/getJob.js | 3 ++- media/transcoder/getJobState.js | 3 ++- media/transcoder/getJobTemplate.js | 3 ++- media/transcoder/listJobTemplates.js | 3 ++- media/transcoder/listJobs.js | 3 ++- media/transcoder/quickstart.js | 3 ++- media/transcoder/test/transcoder.test.js | 17 ++++++++----- 17 files changed, 91 insertions(+), 62 deletions(-) diff --git a/media/transcoder/createJobFromAdHoc.js b/media/transcoder/createJobFromAdHoc.js index e6bd3d802f..10eaa3c10c 100644 --- a/media/transcoder/createJobFromAdHoc.js +++ b/media/transcoder/createJobFromAdHoc.js @@ -26,7 +26,8 @@ function main(projectId, location, inputUri, outputUri) { // outputUri = 'gs://my-bucket/my-output-folder/'; // Imports the Transcoder library - const {TranscoderServiceClient} = require('@google-cloud/video-transcoder'); + const {TranscoderServiceClient} = + require('@google-cloud/video-transcoder').v1; // Instantiates a client const transcoderServiceClient = new TranscoderServiceClient(); @@ -43,21 +44,23 @@ function main(projectId, location, inputUri, outputUri) { { key: 'video-stream0', videoStream: { - codec: 'h264', - heightPixels: 360, - widthPixels: 640, - bitrateBps: 550000, - frameRate: 60, + h264: { + heightPixels: 360, + widthPixels: 640, + bitrateBps: 550000, + frameRate: 60, + }, }, }, { key: 'video-stream1', videoStream: { - codec: 'h264', - heightPixels: 720, - widthPixels: 1280, - bitrateBps: 2500000, - frameRate: 60, + h264: { + heightPixels: 720, + widthPixels: 1280, + bitrateBps: 2500000, + frameRate: 60, + }, }, }, { diff --git a/media/transcoder/createJobFromPreset.js b/media/transcoder/createJobFromPreset.js index 23852688b9..814970d601 100644 --- a/media/transcoder/createJobFromPreset.js +++ b/media/transcoder/createJobFromPreset.js @@ -27,7 +27,8 @@ function main(projectId, location, inputUri, outputUri, preset) { // preset = 'preset/web-hd'; // Imports the Transcoder library - const {TranscoderServiceClient} = require('@google-cloud/video-transcoder'); + const {TranscoderServiceClient} = + require('@google-cloud/video-transcoder').v1; // Instantiates a client const transcoderServiceClient = new TranscoderServiceClient(); diff --git a/media/transcoder/createJobFromTemplate.js b/media/transcoder/createJobFromTemplate.js index 958e7ed607..dad57f3ff8 100644 --- a/media/transcoder/createJobFromTemplate.js +++ b/media/transcoder/createJobFromTemplate.js @@ -27,7 +27,8 @@ function main(projectId, location, inputUri, outputUri, templateId) { // templateId = 'my-job-template'; // Imports the Transcoder library - const {TranscoderServiceClient} = require('@google-cloud/video-transcoder'); + const {TranscoderServiceClient} = + require('@google-cloud/video-transcoder').v1; // Instantiates a client const transcoderServiceClient = new TranscoderServiceClient(); diff --git a/media/transcoder/createJobTemplate.js b/media/transcoder/createJobTemplate.js index 09e4b58558..959518ee7c 100644 --- a/media/transcoder/createJobTemplate.js +++ b/media/transcoder/createJobTemplate.js @@ -25,7 +25,8 @@ function main(projectId, location, templateId) { // templateId = 'my-job-template'; // Imports the Transcoder library - const {TranscoderServiceClient} = require('@google-cloud/video-transcoder'); + const {TranscoderServiceClient} = + require('@google-cloud/video-transcoder').v1; // Instantiates a client const transcoderServiceClient = new TranscoderServiceClient(); @@ -41,21 +42,23 @@ function main(projectId, location, templateId) { { key: 'video-stream0', videoStream: { - codec: 'h264', - heightPixels: 360, - widthPixels: 640, - bitrateBps: 550000, - frameRate: 60, + h264: { + heightPixels: 360, + widthPixels: 640, + bitrateBps: 550000, + frameRate: 60, + }, }, }, { key: 'video-stream1', videoStream: { - codec: 'h264', - heightPixels: 720, - widthPixels: 1280, - bitrateBps: 2500000, - frameRate: 60, + h264: { + heightPixels: 720, + widthPixels: 1280, + bitrateBps: 2500000, + frameRate: 60, + }, }, }, { diff --git a/media/transcoder/createJobWithAnimatedOverlay.js b/media/transcoder/createJobWithAnimatedOverlay.js index 05411d289e..f8350fe216 100644 --- a/media/transcoder/createJobWithAnimatedOverlay.js +++ b/media/transcoder/createJobWithAnimatedOverlay.js @@ -27,7 +27,8 @@ function main(projectId, location, inputUri, overlayImageUri, outputUri) { // outputUri = 'gs://my-bucket/my-output-folder/'; // Imports the Transcoder library - const {TranscoderServiceClient} = require('@google-cloud/video-transcoder'); + const {TranscoderServiceClient} = + require('@google-cloud/video-transcoder').v1; // Instantiates a client const transcoderServiceClient = new TranscoderServiceClient(); @@ -44,11 +45,12 @@ function main(projectId, location, inputUri, overlayImageUri, outputUri) { { key: 'video-stream0', videoStream: { - codec: 'h264', - heightPixels: 360, - widthPixels: 640, - bitrateBps: 550000, - frameRate: 60, + h264: { + heightPixels: 360, + widthPixels: 640, + bitrateBps: 550000, + frameRate: 60, + }, }, }, { diff --git a/media/transcoder/createJobWithPeriodicImagesSpritesheet.js b/media/transcoder/createJobWithPeriodicImagesSpritesheet.js index 40c286d656..ee8f781604 100644 --- a/media/transcoder/createJobWithPeriodicImagesSpritesheet.js +++ b/media/transcoder/createJobWithPeriodicImagesSpritesheet.js @@ -26,7 +26,8 @@ function main(projectId, location, inputUri, outputUri) { // outputUri = 'gs://my-bucket/my-output-folder/'; // Imports the Transcoder library - const {TranscoderServiceClient} = require('@google-cloud/video-transcoder'); + const {TranscoderServiceClient} = + require('@google-cloud/video-transcoder').v1; // Instantiates a client const transcoderServiceClient = new TranscoderServiceClient(); @@ -43,11 +44,12 @@ function main(projectId, location, inputUri, outputUri) { { key: 'video-stream0', videoStream: { - codec: 'h264', - heightPixels: 360, - widthPixels: 640, - bitrateBps: 550000, - frameRate: 60, + h264: { + heightPixels: 360, + widthPixels: 640, + bitrateBps: 550000, + frameRate: 60, + }, }, }, { diff --git a/media/transcoder/createJobWithSetNumberImagesSpritesheet.js b/media/transcoder/createJobWithSetNumberImagesSpritesheet.js index 913aff1da7..6c2f71a7e6 100644 --- a/media/transcoder/createJobWithSetNumberImagesSpritesheet.js +++ b/media/transcoder/createJobWithSetNumberImagesSpritesheet.js @@ -26,7 +26,8 @@ function main(projectId, location, inputUri, outputUri) { // outputUri = 'gs://my-bucket/my-output-folder/'; // Imports the Transcoder library - const {TranscoderServiceClient} = require('@google-cloud/video-transcoder'); + const {TranscoderServiceClient} = + require('@google-cloud/video-transcoder').v1; // Instantiates a client const transcoderServiceClient = new TranscoderServiceClient(); @@ -43,11 +44,12 @@ function main(projectId, location, inputUri, outputUri) { { key: 'video-stream0', videoStream: { - codec: 'h264', - heightPixels: 360, - widthPixels: 640, - bitrateBps: 550000, - frameRate: 60, + h264: { + heightPixels: 360, + widthPixels: 640, + bitrateBps: 550000, + frameRate: 60, + }, }, }, { diff --git a/media/transcoder/createJobWithStaticOverlay.js b/media/transcoder/createJobWithStaticOverlay.js index 9a80cc9e07..d311879281 100644 --- a/media/transcoder/createJobWithStaticOverlay.js +++ b/media/transcoder/createJobWithStaticOverlay.js @@ -27,7 +27,8 @@ function main(projectId, location, inputUri, overlayImageUri, outputUri) { // outputUri = 'gs://my-bucket/my-output-folder/'; // Imports the Transcoder library - const {TranscoderServiceClient} = require('@google-cloud/video-transcoder'); + const {TranscoderServiceClient} = + require('@google-cloud/video-transcoder').v1; // Instantiates a client const transcoderServiceClient = new TranscoderServiceClient(); @@ -44,11 +45,12 @@ function main(projectId, location, inputUri, overlayImageUri, outputUri) { { key: 'video-stream0', videoStream: { - codec: 'h264', - heightPixels: 360, - widthPixels: 640, - bitrateBps: 550000, - frameRate: 60, + h264: { + heightPixels: 360, + widthPixels: 640, + bitrateBps: 550000, + frameRate: 60, + }, }, }, { diff --git a/media/transcoder/deleteJob.js b/media/transcoder/deleteJob.js index d0ca24bede..b173e10dce 100644 --- a/media/transcoder/deleteJob.js +++ b/media/transcoder/deleteJob.js @@ -25,7 +25,8 @@ function main(projectId, location, jobId) { // jobId = 'my-job-id'; // Imports the Transcoder library - const {TranscoderServiceClient} = require('@google-cloud/video-transcoder'); + const {TranscoderServiceClient} = + require('@google-cloud/video-transcoder').v1; // Instantiates a client const transcoderServiceClient = new TranscoderServiceClient(); diff --git a/media/transcoder/deleteJobTemplate.js b/media/transcoder/deleteJobTemplate.js index 4b6b027b38..0bcb8659ff 100644 --- a/media/transcoder/deleteJobTemplate.js +++ b/media/transcoder/deleteJobTemplate.js @@ -25,7 +25,8 @@ function main(projectId, location, templateId) { // templateId = 'my-job-template'; // Imports the Transcoder library - const {TranscoderServiceClient} = require('@google-cloud/video-transcoder'); + const {TranscoderServiceClient} = + require('@google-cloud/video-transcoder').v1; // Instantiates a client const transcoderServiceClient = new TranscoderServiceClient(); diff --git a/media/transcoder/getJob.js b/media/transcoder/getJob.js index 8e16b35218..af81f04edc 100644 --- a/media/transcoder/getJob.js +++ b/media/transcoder/getJob.js @@ -25,7 +25,8 @@ function main(projectId, location, jobId) { // jobId = 'my-job-id'; // Imports the Transcoder library - const {TranscoderServiceClient} = require('@google-cloud/video-transcoder'); + const {TranscoderServiceClient} = + require('@google-cloud/video-transcoder').v1; // Instantiates a client const transcoderServiceClient = new TranscoderServiceClient(); diff --git a/media/transcoder/getJobState.js b/media/transcoder/getJobState.js index 60aad0a17c..1a40525e17 100644 --- a/media/transcoder/getJobState.js +++ b/media/transcoder/getJobState.js @@ -25,7 +25,8 @@ function main(projectId, location, jobId) { // jobId = 'my-job-id'; // Imports the Transcoder library - const {TranscoderServiceClient} = require('@google-cloud/video-transcoder'); + const {TranscoderServiceClient} = + require('@google-cloud/video-transcoder').v1; // Instantiates a client const transcoderServiceClient = new TranscoderServiceClient(); diff --git a/media/transcoder/getJobTemplate.js b/media/transcoder/getJobTemplate.js index 01dbc30674..29c7b6f732 100644 --- a/media/transcoder/getJobTemplate.js +++ b/media/transcoder/getJobTemplate.js @@ -25,7 +25,8 @@ function main(projectId, location, templateId) { // templateId = 'my-job-template'; // Imports the Transcoder library - const {TranscoderServiceClient} = require('@google-cloud/video-transcoder'); + const {TranscoderServiceClient} = + require('@google-cloud/video-transcoder').v1; // Instantiates a client const transcoderServiceClient = new TranscoderServiceClient(); diff --git a/media/transcoder/listJobTemplates.js b/media/transcoder/listJobTemplates.js index a6156a286c..f2862b7e00 100644 --- a/media/transcoder/listJobTemplates.js +++ b/media/transcoder/listJobTemplates.js @@ -24,7 +24,8 @@ function main(projectId, location) { // location = 'us-central1'; // Imports the Transcoder library - const {TranscoderServiceClient} = require('@google-cloud/video-transcoder'); + const {TranscoderServiceClient} = + require('@google-cloud/video-transcoder').v1; // Instantiates a client const transcoderServiceClient = new TranscoderServiceClient(); diff --git a/media/transcoder/listJobs.js b/media/transcoder/listJobs.js index 34fe5d2628..a5d69c0f22 100644 --- a/media/transcoder/listJobs.js +++ b/media/transcoder/listJobs.js @@ -24,7 +24,8 @@ function main(projectId, location) { // location = 'us-central1'; // Imports the Transcoder library - const {TranscoderServiceClient} = require('@google-cloud/video-transcoder'); + const {TranscoderServiceClient} = + require('@google-cloud/video-transcoder').v1; // Instantiates a client const transcoderServiceClient = new TranscoderServiceClient(); diff --git a/media/transcoder/quickstart.js b/media/transcoder/quickstart.js index 797c0523f1..78e00252eb 100644 --- a/media/transcoder/quickstart.js +++ b/media/transcoder/quickstart.js @@ -21,7 +21,8 @@ async function main(projectId, location) { */ // const projectId = 'my-project'; // const location = 'us-central1'; - const {TranscoderServiceClient} = require('@google-cloud/video-transcoder'); + const {TranscoderServiceClient} = + require('@google-cloud/video-transcoder').v1; const client = new TranscoderServiceClient(); async function listJobs() { const [jobs] = await client.listJobs({ diff --git a/media/transcoder/test/transcoder.test.js b/media/transcoder/test/transcoder.test.js index 7c3bc537c4..4a780209c3 100644 --- a/media/transcoder/test/transcoder.test.js +++ b/media/transcoder/test/transcoder.test.js @@ -105,12 +105,17 @@ after(async () => { describe('Job template functions', () => { before(() => { // Delete the job template if it already exists - execSync( - `node deleteJobTemplate.js ${projectId} ${location} ${templateId}`, - { - cwd, - } - ); + try { + execSync( + `node deleteJobTemplate.js ${projectId} ${location} ${templateId}`, + { + cwd, + } + ); + } catch (err) { + // ignore not found error + } + const output = execSync( `node createJobTemplate.js ${projectId} ${location} ${templateId}`, {cwd}