Crear y administrar extremos de entrada

En esta página, se muestra cómo crear y administrar los extremos de entrada de la API de Live Stream. Envías transmisiones de video de entrada a estos extremos.

Configura el proyecto de Google Cloud y la autenticación

Si no creaste un proyecto de Google Cloud ni credenciales, consulta Antes de comenzar.

Crea un extremo de entrada

Para crear un extremo de entrada, usa el método projects.locations.inputs.create.

REST

Antes de usar cualquiera de los datos de solicitud a continuación, realiza los siguientes reemplazos:

  • PROJECT_NUMBER: El número de tu proyecto de Google Cloud, que se encuentra en el campo Número de proyecto de la página Configuración de IAM
  • LOCATION: Es la ubicación en la que se creará el extremo de entrada. Usa una de las regiones compatibles.
    Mostrar ubicaciones
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • INPUT_ID: Es un identificador definido por el usuario para el nuevo extremo de entrada que se creará (al que envías el flujo de entrada). Este valor debe tener entre 1 y 63 caracteres, comenzar y terminar con [a-z0-9] y puede contener guiones (-) entre los caracteres. Por ejemplo, my-input.

Para enviar tu solicitud, expande una de estas opciones:

Deberías recibir una respuesta JSON similar a la que se muestra a continuación:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.video.livestream.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_NUMBER/locations/LOCATION/inputs/INPUT_ID",
    "verb": "create",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}
Este comando crea una operación de larga duración (LRO) que puedes usar para realizar un seguimiento del progreso de tu solicitud. Consulta Cómo administrar operaciones de larga duración para obtener más información.

C#

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de C# de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.


using Google.Api.Gax.ResourceNames;
using Google.Cloud.Video.LiveStream.V1;
using Google.LongRunning;
using System.Threading.Tasks;

public class CreateInputSample
{
    public async Task<Input> CreateInputAsync(
         string projectId, string locationId, string inputId)
    {
        // Create the client.
        LivestreamServiceClient client = LivestreamServiceClient.Create();

        CreateInputRequest request = new CreateInputRequest
        {
            ParentAsLocationName = LocationName.FromProjectLocation(projectId, locationId),
            InputId = inputId,
            Input = new Input
            {
                Type = Input.Types.Type.RtmpPush
            }
        };

        // Make the request.
        Operation<Input, OperationMetadata> response = await client.CreateInputAsync(request);

        // Poll until the returned long-running operation is complete.
        Operation<Input, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();

        // Retrieve the operation result.
        return completedResponse.Result;
    }
}

Go

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Go de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

import (
	"context"
	"fmt"
	"io"

	livestream "cloud.google.com/go/video/livestream/apiv1"
	"cloud.google.com/go/video/livestream/apiv1/livestreampb"
)

// createInput creates an input endpoint. You send an input video stream to this
// endpoint.
func createInput(w io.Writer, projectID, location, inputID string) error {
	// projectID := "my-project-id"
	// location := "us-central1"
	// inputID := "my-input"
	ctx := context.Background()
	client, err := livestream.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient: %w", err)
	}
	defer client.Close()

	req := &livestreampb.CreateInputRequest{
		Parent:  fmt.Sprintf("projects/%s/locations/%s", projectID, location),
		InputId: inputID,
		Input: &livestreampb.Input{
			Type: livestreampb.Input_RTMP_PUSH,
		},
	}
	// Creates the input.
	op, err := client.CreateInput(ctx, req)
	if err != nil {
		return fmt.Errorf("CreateInput: %w", err)
	}
	response, err := op.Wait(ctx)
	if err != nil {
		return fmt.Errorf("Wait: %w", err)
	}

	fmt.Fprintf(w, "Input: %v", response.Name)
	return nil
}

Java

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Java de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.


import com.google.cloud.video.livestream.v1.CreateInputRequest;
import com.google.cloud.video.livestream.v1.Input;
import com.google.cloud.video.livestream.v1.LivestreamServiceClient;
import com.google.cloud.video.livestream.v1.LocationName;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class CreateInput {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "my-project-id";
    String location = "us-central1";
    String inputId = "my-input-id";

    createInput(projectId, location, inputId);
  }

  public static void createInput(String projectId, String location, String inputId)
      throws InterruptedException, ExecutionException, TimeoutException, IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create();
    var createInputRequest =
        CreateInputRequest.newBuilder()
            .setParent(LocationName.of(projectId, location).toString())
            .setInputId(inputId)
            .setInput(Input.newBuilder().setType(Input.Type.RTMP_PUSH).build())
            .build();
    // First API call in a project can take up to 15 minutes.
    Input result =
        livestreamServiceClient.createInputAsync(createInputRequest).get(15, TimeUnit.MINUTES);
    System.out.println("Input: " + result.getName());
    livestreamServiceClient.close();
  }
}

Node.js

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Node.js de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// projectId = 'my-project-id';
// location = 'us-central1';
// inputId = 'my-input';

// Imports the Livestream library
const {LivestreamServiceClient} = require('@google-cloud/livestream').v1;

// Instantiates a client
const livestreamServiceClient = new LivestreamServiceClient();

async function createInput() {
  // Construct request
  const request = {
    parent: livestreamServiceClient.locationPath(projectId, location),
    inputId: inputId,
    input: {
      type: 'RTMP_PUSH',
    },
  };

  // Run request
  const [operation] = await livestreamServiceClient.createInput(request);
  const response = await operation.promise();
  const [input] = response;
  console.log(`Input: ${input.name}`);
}

createInput();

PHP

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de PHP de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

use Google\Cloud\Video\LiveStream\V1\Input;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\CreateInputRequest;

/**
 * Creates an input. You send an input video stream to this endpoint.
 *
 * @param string  $callingProjectId   The project ID to run the API call under
 * @param string  $location           The location of the input
 * @param string  $inputId            The ID of the input to be created
 */
function create_input(
    string $callingProjectId,
    string $location,
    string $inputId
): void {
    // Instantiate a client.
    $livestreamClient = new LivestreamServiceClient();

    $parent = $livestreamClient->locationName($callingProjectId, $location);
    $input = (new Input())
        ->setType(Input\Type::RTMP_PUSH);

    // Run the input creation request. The response is a long-running operation ID.
    $request = (new CreateInputRequest())
        ->setParent($parent)
        ->setInput($input)
        ->setInputId($inputId);
    $operationResponse = $livestreamClient->createInput($request);
    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        $result = $operationResponse->getResult();
        // Print results
        printf('Input: %s' . PHP_EOL, $result->getName());
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }
}

Python

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Python de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.


import argparse

from google.cloud.video import live_stream_v1
from google.cloud.video.live_stream_v1.services.livestream_service import (
    LivestreamServiceClient,
)

def create_input(
    project_id: str, location: str, input_id: str
) -> live_stream_v1.types.Input:
    """Creates an input.
    Args:
        project_id: The GCP project ID.
        location: The location in which to create the input.
        input_id: The user-defined input ID."""

    client = LivestreamServiceClient()

    parent = f"projects/{project_id}/locations/{location}"

    input = live_stream_v1.types.Input(
        type_="RTMP_PUSH",
    )
    operation = client.create_input(parent=parent, input=input, input_id=input_id)
    response = operation.result(900)
    print(f"Input: {response.name}")

    return response

Ruby

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Ruby de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

require "google/cloud/video/live_stream"

##
# Create an input endpoint
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
# @param input_id [String] Your input name (e.g. "my-input")
#
def create_input project_id:, location:, input_id:
  # Create a Live Stream client.
  client = Google::Cloud::Video::LiveStream.livestream_service

  # Build the resource name of the parent.
  parent = client.location_path project: project_id, location: location

  # Set the input fields.
  new_input = {
    type: Google::Cloud::Video::LiveStream::V1::Input::Type::RTMP_PUSH
  }

  operation = client.create_input parent: parent, input: new_input, input_id: input_id

  # The returned object is of type Gapic::Operation. You can use this
  # object to check the status of an operation, cancel it, or wait
  # for results. Here is how to block until completion:
  operation.wait_until_done!

  # Print the input name.
  puts "Input: #{operation.response.name}"
end

Obtén detalles del extremo de entrada

Para obtener los detalles del extremo de entrada, usa el método projects.locations.inputs.get.

REST

Antes de usar cualquiera de los datos de solicitud a continuación, realiza los siguientes reemplazos:

  • PROJECT_NUMBER: El número de tu proyecto de Google Cloud, que se encuentra en el campo Número de proyecto de la página Configuración de IAM
  • LOCATION: Es la ubicación en la que se encuentra el extremo de entrada. Usa una de las regiones compatibles.
    Mostrar ubicaciones
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • INPUT_ID: Es el identificador definido por el usuario para el extremo de entrada.

Para enviar tu solicitud, expande una de estas opciones:

Deberías recibir una respuesta JSON similar a la que se muestra a continuación:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/inputs/INPUT_ID",
  "createTime": CREATE_TIME,
  "updateTime": UPDATE_TIME,
  "type": "RTMP_PUSH",
  "uri":  INPUT_STREAM_URI, # For example, "rtmp://1.2.3.4/live/b8ebdd94-c8d9-4d88-a16e-b963c43a953b",
  "tier": "HD"
}

C#

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de C# de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.


using Google.Cloud.Video.LiveStream.V1;

public class GetInputSample
{
    public Input GetInput(
         string projectId, string locationId, string inputId)
    {
        // Create the client.
        LivestreamServiceClient client = LivestreamServiceClient.Create();

        GetInputRequest request = new GetInputRequest
        {
            InputName = InputName.FromProjectLocationInput(projectId, locationId, inputId)
        };

        // Make the request.
        Input response = client.GetInput(request);
        return response;
    }
}

Go

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Go de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

import (
	"context"
	"fmt"
	"io"

	livestream "cloud.google.com/go/video/livestream/apiv1"
	"cloud.google.com/go/video/livestream/apiv1/livestreampb"
)

// getInput gets a previously-created input endpoint.
func getInput(w io.Writer, projectID, location, inputID string) error {
	// projectID := "my-project-id"
	// location := "us-central1"
	// inputID := "my-input-id"
	ctx := context.Background()
	client, err := livestream.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient: %w", err)
	}
	defer client.Close()

	req := &livestreampb.GetInputRequest{
		Name: fmt.Sprintf("projects/%s/locations/%s/inputs/%s", projectID, location, inputID),
	}

	response, err := client.GetInput(ctx, req)
	if err != nil {
		return fmt.Errorf("GetInput: %w", err)
	}

	fmt.Fprintf(w, "Input: %v", response.Name)
	return nil
}

Java

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Java de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.


import com.google.cloud.video.livestream.v1.Input;
import com.google.cloud.video.livestream.v1.InputName;
import com.google.cloud.video.livestream.v1.LivestreamServiceClient;
import java.io.IOException;

public class GetInput {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "my-project-id";
    String location = "us-central1";
    String inputId = "my-input-id";

    getInput(projectId, location, inputId);
  }

  public static void getInput(String projectId, String location, String inputId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. In this example, try-with-resources is used
    // which automatically calls close() on the client to clean up resources.
    try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
      InputName name = InputName.of(projectId, location, inputId);
      Input response = livestreamServiceClient.getInput(name);
      System.out.println("Input: " + response.getName());
    }
  }
}

Node.js

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Node.js de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// projectId = 'my-project-id';
// location = 'us-central1';
// inputId = 'my-input';

// Imports the Livestream library
const {LivestreamServiceClient} = require('@google-cloud/livestream').v1;

// Instantiates a client
const livestreamServiceClient = new LivestreamServiceClient();

async function getInput() {
  // Construct request
  const request = {
    name: livestreamServiceClient.inputPath(projectId, location, inputId),
  };
  const [input] = await livestreamServiceClient.getInput(request);
  console.log(`Input: ${input.name}`);
}

getInput();

PHP

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de PHP de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\GetInputRequest;

/**
 * Gets an input.
 *
 * @param string  $callingProjectId   The project ID to run the API call under
 * @param string  $location           The location of the input
 * @param string  $inputId            The ID of the input
 */
function get_input(
    string $callingProjectId,
    string $location,
    string $inputId
): void {
    // Instantiate a client.
    $livestreamClient = new LivestreamServiceClient();
    $formattedName = $livestreamClient->inputName($callingProjectId, $location, $inputId);

    // Get the input.
    $request = (new GetInputRequest())
        ->setName($formattedName);
    $response = $livestreamClient->getInput($request);
    // Print results
    printf('Input: %s' . PHP_EOL, $response->getName());
}

Python

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Python de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.


import argparse

from google.cloud.video import live_stream_v1
from google.cloud.video.live_stream_v1.services.livestream_service import (
    LivestreamServiceClient,
)

def get_input(
    project_id: str, location: str, input_id: str
) -> live_stream_v1.types.Input:
    """Gets an input.
    Args:
        project_id: The GCP project ID.
        location: The location of the input.
        input_id: The user-defined input ID."""

    client = LivestreamServiceClient()

    name = f"projects/{project_id}/locations/{location}/inputs/{input_id}"
    response = client.get_input(name=name)
    print(f"Input: {response.name}")

    return response

Ruby

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Ruby de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

require "google/cloud/video/live_stream"

##
# Get an input endpoint
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
# @param input_id [String] Your input name (e.g. "my-input")
#
def get_input project_id:, location:, input_id:
  # Create a Live Stream client.
  client = Google::Cloud::Video::LiveStream.livestream_service

  # Build the resource name of the input.
  name = client.input_path project: project_id, location: location, input: input_id

  # Get the input.
  input = client.get_input name: name

  # Print the input name.
  puts "Input: #{input.name}"
end

Actualiza un extremo de entrada

Para actualizar un extremo de entrada, usa el método projects.locations.inputs.patch.

En el siguiente ejemplo, se actualizan los campos de recorte de video. No todos los campos se pueden actualizar; consulta la lista de campos admitidos.

REST

Antes de usar cualquiera de los datos de solicitud a continuación, realiza los siguientes reemplazos:

  • PROJECT_NUMBER: El número de tu proyecto de Google Cloud, que se encuentra en el campo Número de proyecto de la página Configuración de IAM
  • LOCATION: Es la ubicación en la que se creará el extremo de entrada. Usa una de las regiones compatibles.
    Mostrar ubicaciones
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • INPUT_ID: Es el identificador definido por el usuario para el extremo de entrada.

Para enviar tu solicitud, expande una de estas opciones:

Deberías recibir una respuesta JSON similar a la que se muestra a continuación:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.video.livestream.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_NUMBER/locations/LOCATION/inputs/INPUT_ID",
    "verb": "update",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}
Este comando crea una operación de larga duración (LRO) que puedes usar para realizar un seguimiento del progreso de tu solicitud. Consulta Cómo administrar operaciones de larga duración para obtener más información.

C#

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de C# de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.


using Google.Cloud.Video.LiveStream.V1;
using Google.LongRunning;
using Google.Protobuf.WellKnownTypes;
using System.Threading.Tasks;

public class UpdateInputSample
{
    public async Task<Input> UpdateInputAsync(
         string projectId, string locationId, string inputId)
    {
        // Create the client.
        LivestreamServiceClient client = LivestreamServiceClient.Create();

        UpdateInputRequest request = new UpdateInputRequest
        {
            Input = new Input
            {
                InputName = InputName.FromProjectLocationInput(projectId, locationId, inputId),
                PreprocessingConfig = new PreprocessingConfig
                {
                    Crop = new PreprocessingConfig.Types.Crop
                    {
                        TopPixels = 5,
                        BottomPixels = 5
                    }
                }
            },
            UpdateMask = new FieldMask { Paths = { "preprocessing_config" } }
        };

        // Make the request.
        Operation<Input, OperationMetadata> response = await client.UpdateInputAsync(request);

        // Poll until the returned long-running operation is complete.
        Operation<Input, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();

        // Retrieve the operation result.
        return completedResponse.Result;
    }
}

Go

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Go de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

import (
	"context"
	"fmt"
	"io"

	livestream "cloud.google.com/go/video/livestream/apiv1"
	"cloud.google.com/go/video/livestream/apiv1/livestreampb"
	"google.golang.org/protobuf/types/known/fieldmaskpb"
)

// updateInput updates an existing input endpoint. This sample adds a
// preprocessing configuration to an existing input.
func updateInput(w io.Writer, projectID, location, inputID string) error {
	// projectID := "my-project-id"
	// location := "us-central1"
	// inputID := "my-input"
	ctx := context.Background()
	client, err := livestream.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient: %w", err)
	}
	defer client.Close()

	req := &livestreampb.UpdateInputRequest{
		Input: &livestreampb.Input{
			Name: fmt.Sprintf("projects/%s/locations/%s/inputs/%s", projectID, location, inputID),
			PreprocessingConfig: &livestreampb.PreprocessingConfig{
				Crop: &livestreampb.PreprocessingConfig_Crop{
					TopPixels:    5,
					BottomPixels: 5,
				},
			},
		},
		UpdateMask: &fieldmaskpb.FieldMask{
			Paths: []string{
				"preprocessing_config",
			},
		},
	}
	// Updates the input.
	op, err := client.UpdateInput(ctx, req)
	if err != nil {
		return fmt.Errorf("UpdateInput: %w", err)
	}
	response, err := op.Wait(ctx)
	if err != nil {
		return fmt.Errorf("Wait: %w", err)
	}

	fmt.Fprintf(w, "Updated input: %v", response.Name)
	return nil
}

Java

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Java de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.


import com.google.cloud.video.livestream.v1.Input;
import com.google.cloud.video.livestream.v1.InputName;
import com.google.cloud.video.livestream.v1.LivestreamServiceClient;
import com.google.cloud.video.livestream.v1.PreprocessingConfig;
import com.google.cloud.video.livestream.v1.PreprocessingConfig.Crop;
import com.google.cloud.video.livestream.v1.UpdateInputRequest;
import com.google.protobuf.FieldMask;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class UpdateInput {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "my-project-id";
    String location = "us-central1";
    String inputId = "my-input-id";

    updateInput(projectId, location, inputId);
  }

  public static void updateInput(String projectId, String location, String inputId)
      throws InterruptedException, ExecutionException, TimeoutException, IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create();
    var updateInputRequest =
        UpdateInputRequest.newBuilder()
            .setInput(
                Input.newBuilder()
                    .setName(InputName.of(projectId, location, inputId).toString())
                    .setPreprocessingConfig(
                        PreprocessingConfig.newBuilder()
                            .setCrop(Crop.newBuilder().setTopPixels(5).setBottomPixels(5).build())
                            .build())
                    .build())
            .setUpdateMask(FieldMask.newBuilder().addPaths("preprocessing_config").build())
            .build();
    // First API call in a project can take up to 10 minutes.
    Input result =
        livestreamServiceClient.updateInputAsync(updateInputRequest).get(10, TimeUnit.MINUTES);
    System.out.println("Updated input: " + result.getName());
    livestreamServiceClient.close();
  }
}

Node.js

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Node.js de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// projectId = 'my-project-id';
// location = 'us-central1';
// inputId = 'my-input';

// Imports the Livestream library
const {LivestreamServiceClient} = require('@google-cloud/livestream').v1;

// Instantiates a client
const livestreamServiceClient = new LivestreamServiceClient();

async function updateInput() {
  // Construct request
  const request = {
    input: {
      name: livestreamServiceClient.inputPath(projectId, location, inputId),
      preprocessingConfig: {
        crop: {
          topPixels: 5,
          bottomPixels: 5,
        },
      },
    },
    updateMask: {
      paths: ['preprocessing_config'],
    },
  };

  // Run request
  const [operation] = await livestreamServiceClient.updateInput(request);
  const response = await operation.promise();
  const [input] = response;
  console.log(`Updated input: ${input.name}`);
}

updateInput();

PHP

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de PHP de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

use Google\Cloud\Video\LiveStream\V1\Input;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\PreprocessingConfig;
use Google\Cloud\Video\LiveStream\V1\UpdateInputRequest;
use Google\Protobuf\FieldMask;

/**
 * Updates an input.
 *
 * @param string  $callingProjectId   The project ID to run the API call under
 * @param string  $location           The location of the input
 * @param string  $inputId            The ID of the input to be updated
 */
function update_input(
    string $callingProjectId,
    string $location,
    string $inputId
): void {
    // Instantiate a client.
    $livestreamClient = new LivestreamServiceClient();

    $formattedName = $livestreamClient->inputName($callingProjectId, $location, $inputId);
    $crop = (new PreprocessingConfig\Crop())
        ->setTopPixels(5)
        ->setBottomPixels(5);
    $config = (new PreprocessingConfig())
        ->setCrop($crop);
    $input = (new Input())
        ->setName($formattedName)
        ->setPreprocessingConfig($config);

    $updateMask = new FieldMask([
        'paths' => ['preprocessing_config']
    ]);

    // Run the input update request. The response is a long-running operation ID.
    $request = (new UpdateInputRequest())
        ->setInput($input)
        ->setUpdateMask($updateMask);
    $operationResponse = $livestreamClient->updateInput($request);

    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        $result = $operationResponse->getResult();
        // Print results
        printf('Updated input: %s' . PHP_EOL, $result->getName());
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }
}

Python

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Python de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.


import argparse

from google.cloud.video import live_stream_v1
from google.cloud.video.live_stream_v1.services.livestream_service import (
    LivestreamServiceClient,
)
from google.protobuf import field_mask_pb2 as field_mask

def update_input(
    project_id: str, location: str, input_id: str
) -> live_stream_v1.types.Input:
    """Updates an input.
    Args:
        project_id: The GCP project ID.
        location: The location of the input.
        input_id: The user-defined input ID."""

    client = LivestreamServiceClient()

    name = f"projects/{project_id}/locations/{location}/inputs/{input_id}"

    input = live_stream_v1.types.Input(
        name=name,
        preprocessing_config=live_stream_v1.types.PreprocessingConfig(
            crop=live_stream_v1.types.PreprocessingConfig.Crop(
                top_pixels=5,
                bottom_pixels=5,
            )
        ),
    )
    update_mask = field_mask.FieldMask(paths=["preprocessing_config"])

    operation = client.update_input(input=input, update_mask=update_mask)
    response = operation.result(600)
    print(f"Updated input: {response.name}")

    return response

Ruby

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Ruby de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

require "google/cloud/video/live_stream"

##
# Update an input endpoint
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
# @param input_id [String] Your input name (e.g. "my-input")
#
def update_input project_id:, location:, input_id:
  # Create a Live Stream client.
  client = Google::Cloud::Video::LiveStream.livestream_service

  # Build the resource name of the input.
  name = client.input_path project: project_id, location: location, input: input_id

  # Set the update mask.
  update_mask = { paths: ["preprocessing_config"] }

  # Update the input pre-processing config field.
  update_input = {
    name: name,
    preprocessing_config: {
      crop: {
        top_pixels: 5,
        bottom_pixels: 5
      }
    }
  }

  operation = client.update_input update_mask: update_mask, input: update_input

  # The returned object is of type Gapic::Operation. You can use this
  # object to check the status of an operation, cancel it, or wait
  # for results. Here is how to block until completion:
  operation.wait_until_done!

  # Print the input name.
  puts "Updated input: #{operation.response.name}"
  puts "Updated pre-processing config: #{operation.response.preprocessing_config.crop.top_pixels}"
end

Enumerar extremos de entrada

Para enumerar todos los extremos de entrada que creaste en una ubicación, usa el método projects.locations.inputs.list.

REST

Antes de usar cualquiera de los datos de solicitud a continuación, realiza los siguientes reemplazos:

  • PROJECT_NUMBER: El número de tu proyecto de Google Cloud, que se encuentra en el campo Número de proyecto de la página Configuración de IAM
  • LOCATION: Es la ubicación en la que se encuentra el extremo de entrada. Usa una de las regiones compatibles.
    Mostrar ubicaciones
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4

Para enviar tu solicitud, expande una de estas opciones:

Deberías recibir una respuesta JSON similar a la que se muestra a continuación:

{
  "inputs": [
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/inputs/my-input",
      "createTime": CREATE_TIME,
      "updateTime": UPDATE_TIME,
      "type": "RTMP_PUSH",
      "uri":  INPUT_STREAM_URI, # For example, "rtmp://1.2.3.4/live/b8ebdd94-c8d9-4d88-a16e-b963c43a953b",
      "tier": "HD"
    },
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/inputs/my-input2",
      "createTime": CREATE_TIME,
      "updateTime": UPDATE_TIME,
      "type": "RTMP_PUSH",
      "uri":  INPUT_STREAM_URI, # For example, "rtmp://1.2.3.4/live/b8ebdd94-c8d9-4d88-a16e-b963c43a953b",
      "tier": "HD"
    }
  ]
}

C#

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de C# de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.


using Google.Api.Gax;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.Video.LiveStream.V1;
using System.Collections.Generic;
using System.Linq;

public class ListInputsSample
{
    public IList<Input> ListInputs(
        string projectId, string regionId)
    {
        // Create the client.
        LivestreamServiceClient client = LivestreamServiceClient.Create();

        ListInputsRequest request = new ListInputsRequest
        {
            ParentAsLocationName = LocationName.FromProjectLocation(projectId, regionId)
        };

        // Make the request.
        PagedEnumerable<ListInputsResponse, Input> response = client.ListInputs(request);

        // The returned sequence will lazily perform RPCs as it's being iterated over.
        return response.ToList();
    }
}

Go

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Go de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

import (
	"context"
	"fmt"
	"io"

	"google.golang.org/api/iterator"

	livestream "cloud.google.com/go/video/livestream/apiv1"
	"cloud.google.com/go/video/livestream/apiv1/livestreampb"
)

// listInputs lists all inputs for a given location.
func listInputs(w io.Writer, projectID, location string) error {
	// projectID := "my-project-id"
	// location := "us-central1"
	ctx := context.Background()
	client, err := livestream.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient: %w", err)
	}
	defer client.Close()

	req := &livestreampb.ListInputsRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s", projectID, location),
	}

	it := client.ListInputs(ctx, req)
	fmt.Fprintln(w, "Inputs:")

	for {
		response, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("ListInputs: %w", err)
		}
		fmt.Fprintln(w, response.GetName())
	}
	return nil
}

Java

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Java de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.


import com.google.cloud.video.livestream.v1.Input;
import com.google.cloud.video.livestream.v1.ListInputsRequest;
import com.google.cloud.video.livestream.v1.LivestreamServiceClient;
import com.google.cloud.video.livestream.v1.LocationName;
import java.io.IOException;

public class ListInputs {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "my-project-id";
    String location = "us-central1";

    listInputs(projectId, location);
  }

  public static void listInputs(String projectId, String location) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. In this example, try-with-resources is used
    // which automatically calls close() on the client to clean up resources.
    try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
      var listInputsRequest =
          ListInputsRequest.newBuilder()
              .setParent(LocationName.of(projectId, location).toString())
              .build();

      LivestreamServiceClient.ListInputsPagedResponse response =
          livestreamServiceClient.listInputs(listInputsRequest);
      System.out.println("Inputs:");

      for (Input input : response.iterateAll()) {
        System.out.println(input.getName());
      }
    }
  }
}

Node.js

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Node.js de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// projectId = 'my-project-id';
// location = 'us-central1';

// Imports the Livestream library
const {LivestreamServiceClient} = require('@google-cloud/livestream').v1;

// Instantiates a client
const livestreamServiceClient = new LivestreamServiceClient();

async function listInputs() {
  const iterable = await livestreamServiceClient.listInputsAsync({
    parent: livestreamServiceClient.locationPath(projectId, location),
  });
  console.info('Inputs:');
  for await (const response of iterable) {
    console.log(response.name);
  }
}

listInputs();

PHP

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de PHP de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\ListInputsRequest;

/**
 * Lists the inputs for a given location.
 *
 * @param string  $callingProjectId   The project ID to run the API call under
 * @param string  $location           The location of the inputs
 */
function list_inputs(
    string $callingProjectId,
    string $location
): void {
    // Instantiate a client.
    $livestreamClient = new LivestreamServiceClient();
    $parent = $livestreamClient->locationName($callingProjectId, $location);
    $request = (new ListInputsRequest())
        ->setParent($parent);

    $response = $livestreamClient->listInputs($request);
    // Print the input list.
    $inputs = $response->iterateAllElements();
    print('Inputs:' . PHP_EOL);
    foreach ($inputs as $input) {
        printf('%s' . PHP_EOL, $input->getName());
    }
}

Python

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Python de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.


import argparse

from google.cloud.video.live_stream_v1.services.livestream_service import (
    LivestreamServiceClient,
    pagers,
)

def list_inputs(project_id: str, location: str) -> pagers.ListInputsPager:
    """Lists all inputs in a location.
    Args:
        project_id: The GCP project ID.
        location: The location of the inputs."""

    client = LivestreamServiceClient()

    parent = f"projects/{project_id}/locations/{location}"
    page_result = client.list_inputs(parent=parent)
    print("Inputs:")

    responses = []
    for response in page_result:
        print(response.name)
        responses.append(response)

    return responses

Ruby

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Ruby de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

require "google/cloud/video/live_stream"

##
# List the input endpoints
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
#
def list_inputs project_id:, location:
  # Create a Live Stream client.
  client = Google::Cloud::Video::LiveStream.livestream_service

  # Build the resource name of the parent.
  parent = client.location_path project: project_id, location: location

  # Get the list of inputs.
  response = client.list_inputs parent: parent

  puts "Inputs:"
  # Print out all inputs.
  response.each do |input|
    puts input.name
  end
end

Borra un extremo de entrada

Para borrar un extremo de entrada, usa el método projects.locations.inputs.delete.

REST

Antes de usar cualquiera de los datos de solicitud a continuación, realiza los siguientes reemplazos:

  • PROJECT_NUMBER: El número de tu proyecto de Google Cloud, que se encuentra en el campo Número de proyecto de la página Configuración de IAM
  • LOCATION: Es la ubicación en la que se encuentra el extremo de entrada. Usa una de las regiones compatibles.
    Mostrar ubicaciones
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • INPUT_ID: Es el identificador definido por el usuario para el extremo de entrada.

Para enviar tu solicitud, expande una de estas opciones:

Deberías recibir una respuesta JSON similar a la que se muestra a continuación:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.video.livestream.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_NUMBER/locations/LOCATION/inputs/INPUT_ID",
    "verb": "delete",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}
Este comando crea una operación de larga duración (LRO) que puedes usar para realizar un seguimiento del progreso de tu solicitud. Consulta Cómo administrar operaciones de larga duración para obtener más información.

C#

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de C# de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.


using Google.Cloud.Video.LiveStream.V1;
using Google.LongRunning;
using Google.Protobuf.WellKnownTypes;
using System.Threading.Tasks;

public class DeleteInputSample
{
    public async Task DeleteInputAsync(
         string projectId, string locationId, string inputId)
    {
        // Create the client.
        LivestreamServiceClient client = LivestreamServiceClient.Create();

        DeleteInputRequest request = new DeleteInputRequest
        {
            InputName = InputName.FromProjectLocationInput(projectId, locationId, inputId)
        };

        // Make the request.
        Operation<Empty, OperationMetadata> response = await client.DeleteInputAsync(request);

        // Poll until the returned long-running operation is complete.
        await response.PollUntilCompletedAsync();
    }
}

Go

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Go de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

import (
	"context"
	"fmt"
	"io"

	livestream "cloud.google.com/go/video/livestream/apiv1"
	"cloud.google.com/go/video/livestream/apiv1/livestreampb"
)

// deleteInput deletes a previously-created input endpoint.
func deleteInput(w io.Writer, projectID, location, inputID string) error {
	// projectID := "my-project-id"
	// location := "us-central1"
	// inputID := "my-input"
	ctx := context.Background()
	client, err := livestream.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient: %w", err)
	}
	defer client.Close()

	req := &livestreampb.DeleteInputRequest{
		Name: fmt.Sprintf("projects/%s/locations/%s/inputs/%s", projectID, location, inputID),
	}

	op, err := client.DeleteInput(ctx, req)
	if err != nil {
		return fmt.Errorf("DeleteInput: %w", err)
	}
	err = op.Wait(ctx)
	if err != nil {
		return fmt.Errorf("Wait: %w", err)
	}

	fmt.Fprintf(w, "Deleted input")
	return nil
}

Java

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Java de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.


import com.google.cloud.video.livestream.v1.DeleteInputRequest;
import com.google.cloud.video.livestream.v1.InputName;
import com.google.cloud.video.livestream.v1.LivestreamServiceClient;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class DeleteInput {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "my-project-id";
    String location = "us-central1";
    String inputId = "my-input-id";

    deleteInput(projectId, location, inputId);
  }

  public static void deleteInput(String projectId, String location, String inputId)
      throws InterruptedException, ExecutionException, TimeoutException, IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create();
    var deleteInputRequest =
        DeleteInputRequest.newBuilder()
            .setName(InputName.of(projectId, location, inputId).toString())
            .build();
    // First API call in a project can take up to 10 minutes.
    livestreamServiceClient.deleteInputAsync(deleteInputRequest).get(10, TimeUnit.MINUTES);
    System.out.println("Deleted input");
    livestreamServiceClient.close();
  }
}

Node.js

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Node.js de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// projectId = 'my-project-id';
// location = 'us-central1';
// inputId = 'my-input';

// Imports the Livestream library
const {LivestreamServiceClient} = require('@google-cloud/livestream').v1;

// Instantiates a client
const livestreamServiceClient = new LivestreamServiceClient();

async function deleteInput() {
  // Construct request
  const request = {
    name: livestreamServiceClient.inputPath(projectId, location, inputId),
  };

  // Run request
  const [operation] = await livestreamServiceClient.deleteInput(request);
  await operation.promise();
  console.log('Deleted input');
}

deleteInput();

PHP

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de PHP de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\DeleteInputRequest;

/**
 * Deletes an input.
 *
 * @param string  $callingProjectId   The project ID to run the API call under
 * @param string  $location           The location of the input
 * @param string  $inputId            The ID of the input to be deleted
 */
function delete_input(
    string $callingProjectId,
    string $location,
    string $inputId
): void {
    // Instantiate a client.
    $livestreamClient = new LivestreamServiceClient();
    $formattedName = $livestreamClient->inputName($callingProjectId, $location, $inputId);

    // Run the input deletion request. The response is a long-running operation ID.
    $request = (new DeleteInputRequest())
        ->setName($formattedName);
    $operationResponse = $livestreamClient->deleteInput($request);
    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        // Print status
        printf('Deleted input %s' . PHP_EOL, $inputId);
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }
}

Python

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Python de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.


import argparse

from google.cloud.video.live_stream_v1.services.livestream_service import (
    LivestreamServiceClient,
)
from google.protobuf import empty_pb2 as empty

def delete_input(project_id: str, location: str, input_id: str) -> empty.Empty:
    """Deletes an input.
    Args:
        project_id: The GCP project ID.
        location: The location of the input.
        input_id: The user-defined input ID."""

    client = LivestreamServiceClient()

    name = f"projects/{project_id}/locations/{location}/inputs/{input_id}"
    operation = client.delete_input(name=name)
    response = operation.result(600)
    print("Deleted input")

    return response

Ruby

Para obtener información sobre cómo instalar y usar la biblioteca cliente de la API de Live Stream, consulta Bibliotecas cliente de la API de Live Stream. Si quieres obtener más información, consulta la documentación de referencia de la API de Ruby de la API de Live Stream.

Para autenticarte en la API de Live Stream, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.

require "google/cloud/video/live_stream"

##
# Delete an input endpoint
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
# @param input_id [String] Your input name (e.g. "my-input")
#
def delete_input project_id:, location:, input_id:
  # Create a Live Stream client.
  client = Google::Cloud::Video::LiveStream.livestream_service

  # Build the resource name of the input.
  name = client.input_path project: project_id, location: location, input: input_id

  # Delete the input.
  operation = client.delete_input name: name

  # The returned object is of type Gapic::Operation. You can use this
  # object to check the status of an operation, cancel it, or wait
  # for results. Here is how to block until completion:
  operation.wait_until_done!

  # Print a success message.
  puts "Deleted input"
end

¿Qué sigue?

Aprende a crear y administrar canales que usan el extremo de entrada.