(projectId, location, assetId, assetUri)
| 16 | 'use strict'; |
| 17 | |
| 18 | function main(projectId, location, assetId, assetUri) { |
| 19 | // [START livestream_create_asset] |
| 20 | /** |
| 21 | * TODO(developer): Uncomment these variables before running the sample. |
| 22 | */ |
| 23 | // projectId = 'my-project-id'; |
| 24 | // location = 'us-central1'; |
| 25 | // assetId = 'my-asset'; |
| 26 | // assetUri = 'gs://my-bucket/my-video.mp4'; |
| 27 | |
| 28 | // Imports the Livestream library |
| 29 | const {LivestreamServiceClient} = require('@google-cloud/livestream').v1; |
| 30 | |
| 31 | // Instantiates a client |
| 32 | const livestreamServiceClient = new LivestreamServiceClient(); |
| 33 | |
| 34 | async function createAsset() { |
| 35 | // Construct request |
| 36 | const request = { |
| 37 | parent: livestreamServiceClient.locationPath(projectId, location), |
| 38 | assetId: assetId, |
| 39 | asset: { |
| 40 | video: { |
| 41 | uri: assetUri, |
| 42 | }, |
| 43 | }, |
| 44 | }; |
| 45 | |
| 46 | // Run request |
| 47 | const [operation] = await livestreamServiceClient.createAsset(request); |
| 48 | const response = await operation.promise(); |
| 49 | const [asset] = response; |
| 50 | console.log(`Asset: ${asset.name}`); |
| 51 | } |
| 52 | |
| 53 | createAsset(); |
| 54 | // [END livestream_create_asset] |
| 55 | } |
| 56 | |
| 57 | // node createAsset.js <projectId> <location> <assetId> <assetUri> |
| 58 | process.on('unhandledRejection', err => { |
no test coverage detected