(projectId, cdnKeyId, hostname, privateKey, isMediaCdn = true)
| 16 | 'use strict'; |
| 17 | |
| 18 | function main(projectId, cdnKeyId, hostname, privateKey, isMediaCdn = true) { |
| 19 | // [START videostitcher_update_cdn_key] |
| 20 | const location = 'us-central1'; |
| 21 | const keyName = 'cdn-key'; |
| 22 | /** |
| 23 | * TODO(developer): Uncomment these variables before running the sample. |
| 24 | */ |
| 25 | // projectId = 'my-project-id'; |
| 26 | // cdnKeyId = 'my-cdn-key'; |
| 27 | // privateKey = 'my-private-key'; |
| 28 | // isMediaCdn = true; |
| 29 | |
| 30 | // Imports the Video Stitcher library |
| 31 | const {VideoStitcherServiceClient} = |
| 32 | require('@google-cloud/video-stitcher').v1; |
| 33 | // Instantiates a client |
| 34 | const stitcherClient = new VideoStitcherServiceClient(); |
| 35 | |
| 36 | async function updateCdnKey() { |
| 37 | // Construct request |
| 38 | const request = { |
| 39 | cdnKey: { |
| 40 | name: stitcherClient.cdnKeyPath(projectId, location, cdnKeyId), |
| 41 | hostname: hostname, |
| 42 | }, |
| 43 | }; |
| 44 | |
| 45 | if (isMediaCdn === 'true') { |
| 46 | request.cdnKey.mediaCdnKey = { |
| 47 | keyName: keyName, |
| 48 | privateKey: privateKey, |
| 49 | }; |
| 50 | request.updateMask = { |
| 51 | paths: ['hostname', 'media_cdn_key'], |
| 52 | }; |
| 53 | } else { |
| 54 | request.cdnKey.googleCdnKey = { |
| 55 | keyName: keyName, |
| 56 | privateKey: privateKey, |
| 57 | }; |
| 58 | request.updateMask = { |
| 59 | paths: ['hostname', 'google_cdn_key'], |
| 60 | }; |
| 61 | } |
| 62 | |
| 63 | const [operation] = await stitcherClient.updateCdnKey(request); |
| 64 | const [response] = await operation.promise(); |
| 65 | console.log(`Updated CDN key: ${response.name}`); |
| 66 | console.log(`Updated hostname: ${response.hostname}`); |
| 67 | } |
| 68 | |
| 69 | updateCdnKey().catch(err => { |
| 70 | console.error(err.message); |
| 71 | process.exitCode = 1; |
| 72 | }); |
| 73 | // [END videostitcher_update_cdn_key] |
| 74 | } |
| 75 |
no test coverage detected