Update input (v1)

Update the tier of an existing input.

Code sample

Node.js

To learn how to install and use the client library for Live Stream API, see Live Stream API client libraries. For more information, see the Live Stream API Node.js API reference documentation.

To authenticate to Live Stream API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

'use strict';

const {LivestreamServiceClient} = require('@google-cloud/livestream');
const {status} = require('@grpc/grpc-js');

const client = new LivestreamServiceClient();

/**
 * Use the updateInput method
 *
 * @param {string} projectId - The Google Cloud project ID.
 * @param {string} locationId - The Google Cloud region where the Input resource is located.
 * @param {string} inputId - The identifier of the Input resource to update.
 */
async function updateInput(projectId, locationId, inputId) {
  try {
    const input = {
      name: client.inputPath(projectId, locationId, inputId),
      tier: 'SD',
    };
    const updateMask = {
      paths: ['tier'],
    };

    const [operation] = await client.updateInput({
      input,
      updateMask,
    });

    const [response] = await operation.promise();
    console.log(`Updated input: ${response.name}`);
    console.log(`Tier: ${response.tier}`);
  } catch (err) {
    if (err.code === status.NOT_FOUND) {
      console.error(`Input not found: ${err.message}`);
    } else if (err.code === status.INVALID_ARGUMENT) {
      console.error(`Invalid argument: ${err.message}`);
    } else {
      console.error(`API error (${err.code}): ${err.message}`);
    }
  }
}

module.exports = { updateInput };

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.