Crear y gestionar pizarras

Las cartelas son contenido que se puede servir cuando, durante una emisión en directo, hay huecos en una pausa publicitaria que no se pueden rellenar con un anuncio servido de forma dinámica. Un anuncio puede no estar disponible por varios motivos, entre los que se incluyen los siguientes:

  • Se producen errores al obtener recursos de las CDNs (redes de distribución de contenido)
  • Se producen errores durante el procesamiento de los recursos al unir las imágenes

Para que la API Video Stitcher pueda insertar una cartela, el recurso de vídeo de la cartela debe registrarse. Es necesario registrarse para que la API Video Stitcher pueda preparar el recurso de pizarra para insertarlo cuando no haya anuncios.

En este documento se describe cómo gestionar las pizarras. Para obtener más información, consulta la documentación de REST.

Registrar una cartela

Para registrar una pizarra, utiliza el método projects.locations.slates.create.

REST

Antes de usar los datos de la solicitud, haz las siguientes sustituciones:

  • PROJECT_NUMBER: tu número de proyecto; se encuentra en el campo Número de proyecto de la página Configuración de gestión de identidades y accesos. Google Cloud
  • LOCATION: la ubicación en la que quieres crear tu pizarra. Usa una de las regiones admitidas.
    Mostrar ubicaciones
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • SLATE_ID: identificador definido por el usuario de la pizarra. Este ID solo puede contener letras minúsculas, números y guiones. El primer carácter debe ser una letra, el último carácter debe ser una letra o un número, y el ID completo puede tener un máximo de 63 caracteres.
  • SLATE_URL: el URI público de un vídeo MP4 con al menos una pista de audio (vídeo de ejemplo)

Para enviar tu solicitud, despliega una de estas opciones:

Deberías recibir una respuesta JSON similar a la siguiente:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.common.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID",
    "verb": "create",
    "cancelRequested": false,
    "apiVersion": "v1"
  },
  "done": false
}
Este comando crea una operación de larga duración (OLD) que puedes consultar para monitorizar el progreso. Copia el valor devuelto OPERATION_ID, que es la última parte del campo name, para usarlo en la siguiente sección.

C#

Antes de probar este ejemplo, sigue las C# instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API C# Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.


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

public class CreateSlateSample
{
    public async Task<Slate> CreateSlateAsync(
        string projectId, string location, string slateId, string slateUri)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

        CreateSlateRequest request = new CreateSlateRequest
        {
            ParentAsLocationName = LocationName.FromProjectLocation(projectId, location),
            SlateId = slateId,
            Slate = new Slate
            {
                Uri = slateUri
            }
        };

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

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

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

Go

Antes de probar este ejemplo, sigue las Go instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Go Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

import (
	"context"
	"fmt"
	"io"

	stitcher "cloud.google.com/go/video/stitcher/apiv1"
	stitcherstreampb "cloud.google.com/go/video/stitcher/apiv1/stitcherpb"
)

// createSlate creates a slate. A slate is displayed when ads are not available.
func createSlate(w io.Writer, projectID, slateID, slateURI string) error {
	// projectID := "my-project-id"
	// slateID := "my-slate-id"
	// slateURI := "https://my-slate-uri/test.mp4"
	location := "us-central1"
	ctx := context.Background()
	client, err := stitcher.NewVideoStitcherClient(ctx)
	if err != nil {
		return fmt.Errorf("stitcher.NewVideoStitcherClient: %w", err)
	}
	defer client.Close()

	req := &stitcherstreampb.CreateSlateRequest{
		Parent:  fmt.Sprintf("projects/%s/locations/%s", projectID, location),
		SlateId: slateID,
		Slate: &stitcherstreampb.Slate{
			Uri: slateURI,
		},
	}
	// Creates the slate.
	op, err := client.CreateSlate(ctx, req)
	if err != nil {
		return fmt.Errorf("client.CreateSlate: %w", err)
	}
	response, err := op.Wait(ctx)
	if err != nil {
		return err
	}

	fmt.Fprintf(w, "Slate: %v", response.GetName())
	return nil
}

Java

Antes de probar este ejemplo, sigue las Java instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Java Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.


import com.google.cloud.video.stitcher.v1.CreateSlateRequest;
import com.google.cloud.video.stitcher.v1.LocationName;
import com.google.cloud.video.stitcher.v1.Slate;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class CreateSlate {

  private static final int TIMEOUT_IN_MINUTES = 2;

  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 slateId = "my-slate-id";
    String slateUri =
        "https://my-slate-uri/test.mp4"; // URI of an MP4 video with at least one audio track

    createSlate(projectId, location, slateId, slateUri);
  }

  // Creates a slate. Slates are content that can be served when there are gaps in a livestream
  // ad break that cannot be filled with a dynamically served ad. For more information, see
  // https://cloud.google.com/video-stitcher/docs/how-to/managing-slates.
  public static Slate createSlate(
      String projectId, String location, String slateId, String slateUri)
      throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests.
    try (VideoStitcherServiceClient videoStitcherServiceClient =
        VideoStitcherServiceClient.create()) {
      CreateSlateRequest createSlateRequest =
          CreateSlateRequest.newBuilder()
              .setParent(LocationName.of(projectId, location).toString())
              .setSlateId(slateId)
              .setSlate(Slate.newBuilder().setUri(slateUri).build())
              .build();

      Slate response =
          videoStitcherServiceClient
              .createSlateAsync(createSlateRequest)
              .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
      System.out.println("Created new slate: " + response.getName());
      return response;
    }
  }
}

Node.js

Antes de probar este ejemplo, sigue las Node.js instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Node.js Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// projectId = 'my-project-id';
// location = 'us-central1';
// slateId = 'my-slate';
// slateUri = 'https://my-slate-uri/test.mp4';

// Imports the Video Stitcher library
const {VideoStitcherServiceClient} =
  require('@google-cloud/video-stitcher').v1;
// Instantiates a client
const stitcherClient = new VideoStitcherServiceClient();

async function createSlate() {
  // Construct request
  const request = {
    parent: stitcherClient.locationPath(projectId, location),
    slate: {
      uri: slateUri,
    },
    slateId: slateId,
  };
  const [operation] = await stitcherClient.createSlate(request);
  const [response] = await operation.promise();
  console.log(`response.name: ${response.name}`);
}

createSlate().catch(err => {
  console.error(err.message);
  process.exitCode = 1;
});

PHP

Antes de probar este ejemplo, sigue las PHP instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API PHP Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
use Google\Cloud\Video\Stitcher\V1\CreateSlateRequest;
use Google\Cloud\Video\Stitcher\V1\Slate;

/**
 * Creates a slate. A slate is displayed when ads are not available.
 *
 * @param string $callingProjectId     The project ID to run the API call under
 * @param string $location             The location of the slate
 * @param string $slateId              The name of the slate to be created
 * @param string $slateUri             The public URI for an MP4 video with at least one audio track
 */
function create_slate(
    string $callingProjectId,
    string $location,
    string $slateId,
    string $slateUri
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $parent = $stitcherClient->locationName($callingProjectId, $location);
    $slate = new Slate();
    $slate->setUri($slateUri);

    // Run slate creation request
    $request = (new CreateSlateRequest())
        ->setParent($parent)
        ->setSlateId($slateId)
        ->setSlate($slate);
    $operationResponse = $stitcherClient->createSlate($request);
    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        $result = $operationResponse->getResult();
        // Print results
        printf('Slate: %s' . PHP_EOL, $result->getName());
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }
}

Python

Antes de probar este ejemplo, sigue las Python instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Python Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.


import argparse

from google.cloud.video import stitcher_v1
from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
    VideoStitcherServiceClient,
)


def create_slate(
    project_id: str, location: str, slate_id: str, slate_uri: str
) -> stitcher_v1.types.Slate:
    """Creates a slate.
    Args:
        project_id: The GCP project ID.
        location: The location in which to create the slate.
        slate_id: The user-defined slate ID.
        slate_uri: Uri of the video slate; must be an MP4 video with at least one audio track.

    Returns:
        The slate resource.
    """

    client = VideoStitcherServiceClient()

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

    slate = stitcher_v1.types.Slate(
        uri=slate_uri,
    )

    operation = client.create_slate(parent=parent, slate_id=slate_id, slate=slate)
    response = operation.result()
    print(f"Slate: {response.name}")
    return response

Ruby

Antes de probar este ejemplo, sigue las Ruby instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Ruby Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

require "google/cloud/video/stitcher"

##
# Create a slate
#
# @param project_id [String] Your Google Cloud project (e.g. `my-project`)
# @param location [String] The location (e.g. `us-central1`)
# @param slate_id [String] Your slate name (e.g. `my-slate`)
# @param slate_uri [String] The URI of an MP4 video with at least one audio
#   track (e.g. `https://my-slate-uri/test.mp4`)
#
def create_slate project_id:, location:, slate_id:, slate_uri:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

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

  # Set the slate fields.
  new_slate = {
    uri: slate_uri
  }

  operation = client.create_slate parent: parent, slate_id: slate_id,
                                  slate: new_slate

  # 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 slate name.
  puts "Slate: #{operation.response.name}"
end

Comprobar el resultado

Para comprobar si se ha creado la pizarra, usa el método projects.locations.operations.get. Si la respuesta contiene "done: false", repite el comando hasta que la respuesta contenga "done: true".

Antes de usar los datos de la solicitud, haz las siguientes sustituciones:

  • PROJECT_NUMBER: tu número de proyecto; se encuentra en el campo Número de proyecto de la página Configuración de gestión de identidades y accesos. Google Cloud
  • LOCATION: la ubicación de los datos. Usa una de las regiones admitidas.
    Mostrar ubicaciones
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • OPERATION_ID: el identificador de la operación

Para enviar tu solicitud, despliega una de estas opciones:

Deberías recibir una respuesta JSON similar a la siguiente:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.common.OperationMetadata",
    "createTime": CREATE_TIME,
    "endTime": END_TIME,
    "target": "projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID",
    "verb": "create",
    "cancelRequested": false,
    "apiVersion": "v1"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.video.stitcher.v1.Slate",
    "name": "projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID",
    "uri": "SLATE_URL"
  }
}

Obtener una pizarra

Para obtener los detalles de una pizarra específica, usa el método projects.locations.slates.get.

REST

Antes de usar los datos de la solicitud, haz las siguientes sustituciones:

  • PROJECT_NUMBER: tu número de proyecto; se encuentra en el campo Número de proyecto de la página Configuración de gestión de identidades y accesos. Google Cloud
  • LOCATION: la ubicación de tu pizarra. Usa una de las regiones admitidas.
    Mostrar ubicaciones
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • SLATE_ID: identificador definido por el usuario de la pizarra

Para enviar tu solicitud, despliega una de estas opciones:

Deberías recibir una respuesta JSON similar a la siguiente:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID",
  "uri": "SLATE_URL"
}

C#

Antes de probar este ejemplo, sigue las C# instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API C# Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.


using Google.Cloud.Video.Stitcher.V1;

public class GetSlateSample
{
    public Slate GetSlate(
        string projectId, string location, string slateId)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

        GetSlateRequest request = new GetSlateRequest
        {
            SlateName = SlateName.FromProjectLocationSlate(projectId, location, slateId)
        };

        // Call the API.
        Slate response = client.GetSlate(request);

        // Return the result.
        return response;
    }
}

Go

Antes de probar este ejemplo, sigue las Go instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Go Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

import (
	"context"
	"encoding/json"
	"fmt"
	"io"

	stitcher "cloud.google.com/go/video/stitcher/apiv1"
	stitcherstreampb "cloud.google.com/go/video/stitcher/apiv1/stitcherpb"
)

// getSlate gets a previously-created slate.
func getSlate(w io.Writer, projectID, slateID string) error {
	// projectID := "my-project-id"
	// slateID := "my-slate-id"
	location := "us-central1"
	ctx := context.Background()
	client, err := stitcher.NewVideoStitcherClient(ctx)
	if err != nil {
		return fmt.Errorf("stitcher.NewVideoStitcherClient: %w", err)
	}
	defer client.Close()

	req := &stitcherstreampb.GetSlateRequest{
		Name: fmt.Sprintf("projects/%s/locations/%s/slates/%s", projectID, location, slateID),
	}

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

	fmt.Fprintf(w, "Slate:\n%s", string(b))
	return nil
}

Java

Antes de probar este ejemplo, sigue las Java instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Java Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.


import com.google.cloud.video.stitcher.v1.GetSlateRequest;
import com.google.cloud.video.stitcher.v1.Slate;
import com.google.cloud.video.stitcher.v1.SlateName;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import java.io.IOException;

public class GetSlate {

  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 slateId = "my-slate-id";

    getSlate(projectId, location, slateId);
  }

  // Gets a slate.
  public static Slate getSlate(String projectId, String location, String slateId)
      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.
    try (VideoStitcherServiceClient videoStitcherServiceClient =
        VideoStitcherServiceClient.create()) {
      GetSlateRequest getSlateRequest =
          GetSlateRequest.newBuilder()
              .setName(SlateName.of(projectId, location, slateId).toString())
              .build();

      Slate response = videoStitcherServiceClient.getSlate(getSlateRequest);
      System.out.println("Slate: " + response.getName());
      return response;
    }
  }
}

Node.js

Antes de probar este ejemplo, sigue las Node.js instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Node.js Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

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

// Imports the Video Stitcher library
const {VideoStitcherServiceClient} =
  require('@google-cloud/video-stitcher').v1;
// Instantiates a client
const stitcherClient = new VideoStitcherServiceClient();

async function getSlate() {
  // Construct request
  const request = {
    name: stitcherClient.slatePath(projectId, location, slateId),
  };
  const [slate] = await stitcherClient.getSlate(request);
  console.log(`Slate: ${slate.name}`);
}

getSlate().catch(err => {
  console.error(err.message);
  process.exitCode = 1;
});

PHP

Antes de probar este ejemplo, sigue las PHP instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API PHP Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
use Google\Cloud\Video\Stitcher\V1\GetSlateRequest;

/**
 * Gets a slate.
 *
 * @param string $callingProjectId     The project ID to run the API call under
 * @param string $location             The location of the slate
 * @param string $slateId              The ID of the slate
 */
function get_slate(
    string $callingProjectId,
    string $location,
    string $slateId
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $formattedName = $stitcherClient->slateName($callingProjectId, $location, $slateId);
    $request = (new GetSlateRequest())
        ->setName($formattedName);
    $slate = $stitcherClient->getSlate($request);

    // Print results
    printf('Slate: %s' . PHP_EOL, $slate->getName());
}

Python

Antes de probar este ejemplo, sigue las Python instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Python Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.


import argparse

from google.cloud.video import stitcher_v1
from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
    VideoStitcherServiceClient,
)


def get_slate(project_id: str, location: str, slate_id: str) -> stitcher_v1.types.Slate:
    """Gets a slate.
    Args:
        project_id: The GCP project ID.
        location: The location of the slate.
        slate_id: The user-defined slate ID.

    Returns:
        The slate resource.
    """

    client = VideoStitcherServiceClient()

    name = f"projects/{project_id}/locations/{location}/slates/{slate_id}"
    response = client.get_slate(name=name)
    print(f"Slate: {response.name}")
    return response

Ruby

Antes de probar este ejemplo, sigue las Ruby instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Ruby Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

require "google/cloud/video/stitcher"

##
# Get a slate
#
# @param project_id [String] Your Google Cloud project (e.g. `my-project`)
# @param location [String] The location (e.g. `us-central1`)
# @param slate_id [String] Your slate name (e.g. `my-slate`)
#
def get_slate project_id:, location:, slate_id:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

  # Build the resource name of the slate.
  name = client.slate_path project: project_id, location: location,
                           slate: slate_id

  # Get the slate.
  slate = client.get_slate name: name

  # Print the slate name.
  puts "Slate: #{slate.name}"
end

Actualizar una pizarra

Para actualizar una pizarra específica, usa el método projects.locations.slates.patch.

REST

Antes de usar los datos de la solicitud, haz las siguientes sustituciones:

  • PROJECT_NUMBER: tu número de proyecto; se encuentra en el campo Número de proyecto de la página Configuración de gestión de identidades y accesos. Google Cloud
  • LOCATION: la ubicación en la que quieres crear tu pizarra. Elige una de las regiones admitidas.
    Mostrar ubicaciones
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • SLATE_ID: identificador definido por el usuario de la pizarra
  • SLATE_URL: este URI debe devolver un vídeo MP4 con al menos una pista de audio.

Para enviar tu solicitud, despliega una de estas opciones:

Deberías recibir una respuesta JSON similar a la siguiente:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.common.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID",
    "verb": "update",
    "cancelRequested": false,
    "apiVersion": "v1"
  },
  "done": false
}
Este comando crea una operación de larga duración (OLD) que puedes consultar para monitorizar el progreso. Para obtener más información, consulta Comprobar el resultado.

C#

Antes de probar este ejemplo, sigue las C# instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API C# Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.


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

public class UpdateSlateSample
{
    public async Task<Slate> UpdateSlateAsync(
        string projectId, string location, string slateId, string slateUri)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

        UpdateSlateRequest request = new UpdateSlateRequest
        {
            Slate = new Slate
            {
                SlateName = SlateName.FromProjectLocationSlate(projectId, location, slateId),
                Uri = slateUri
            },
            UpdateMask = new FieldMask { Paths = { "uri" } }
        };

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

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

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

Go

Antes de probar este ejemplo, sigue las Go instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Go Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

import (
	"context"
	"fmt"
	"io"

	stitcher "cloud.google.com/go/video/stitcher/apiv1"
	stitcherstreampb "cloud.google.com/go/video/stitcher/apiv1/stitcherpb"
	"google.golang.org/protobuf/types/known/fieldmaskpb"
)

// updateSlate updates an existing slate. This sample updates the uri for an
// existing slate.
func updateSlate(w io.Writer, projectID, slateID, slateURI string) error {
	// projectID := "my-project-id"
	// slateID := "my-slate-id"
	// slateURI := "https://my-updated-slate-uri/test.mp4"
	location := "us-central1"
	ctx := context.Background()
	client, err := stitcher.NewVideoStitcherClient(ctx)
	if err != nil {
		return fmt.Errorf("stitcher.NewVideoStitcherClient: %w", err)
	}
	defer client.Close()

	req := &stitcherstreampb.UpdateSlateRequest{
		Slate: &stitcherstreampb.Slate{
			Name: fmt.Sprintf("projects/%s/locations/%s/slates/%s", projectID, location, slateID),
			Uri:  slateURI,
		},
		UpdateMask: &fieldmaskpb.FieldMask{
			Paths: []string{
				"uri",
			},
		},
	}
	// Updates the slate.
	op, err := client.UpdateSlate(ctx, req)
	if err != nil {
		return fmt.Errorf("client.UpdateSlate: %w", err)
	}
	response, err := op.Wait(ctx)
	if err != nil {
		return err
	}

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

Java

Antes de probar este ejemplo, sigue las Java instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Java Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.


import com.google.cloud.video.stitcher.v1.Slate;
import com.google.cloud.video.stitcher.v1.SlateName;
import com.google.cloud.video.stitcher.v1.UpdateSlateRequest;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
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 UpdateSlate {

  private static final int TIMEOUT_IN_MINUTES = 2;

  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 slateId = "my-slate-id";
    String slateUri =
        "https://my-slate-uri/test.mp4"; // URI of an MP4 video with at least one audio track

    updateSlate(projectId, location, slateId, slateUri);
  }

  // updateSlate updates the slate URI for an existing slate.
  public static Slate updateSlate(
      String projectId, String location, String slateId, String slateUri)
      throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests.
    try (VideoStitcherServiceClient videoStitcherServiceClient =
        VideoStitcherServiceClient.create()) {
      UpdateSlateRequest updateSlateRequest =
          UpdateSlateRequest.newBuilder()
              .setSlate(
                  Slate.newBuilder()
                      .setName(SlateName.of(projectId, location, slateId).toString())
                      .setUri(slateUri)
                      .build())
              // Set the update mask to the uri field in the existing slate. You must set the mask
              // to the field you want to update.
              .setUpdateMask(FieldMask.newBuilder().addPaths("uri").build())
              .build();

      Slate response =
          videoStitcherServiceClient
              .updateSlateAsync(updateSlateRequest)
              .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
      System.out.println("Updated slate: " + response.getName());
      return response;
    }
  }
}

Node.js

Antes de probar este ejemplo, sigue las Node.js instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Node.js Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// projectId = 'my-project-id';
// location = 'us-central1';
// slateId = 'my-slate';
// slateUri = 'https://my-slate-uri/test.mp4';

// Imports the Video Stitcher library
const {VideoStitcherServiceClient} =
  require('@google-cloud/video-stitcher').v1;
// Instantiates a client
const stitcherClient = new VideoStitcherServiceClient();

async function updateSlate() {
  // Construct request
  const request = {
    slate: {
      name: stitcherClient.slatePath(projectId, location, slateId),
      uri: slateUri,
    },
    updateMask: {
      paths: ['uri'],
    },
  };

  const [operation] = await stitcherClient.updateSlate(request);
  const [response] = await operation.promise();
  console.log(`Updated slate: ${response.name}`);
  console.log(`Updated uri: ${response.uri}`);
}

updateSlate().catch(err => {
  console.error(err.message);
  process.exitCode = 1;
});

PHP

Antes de probar este ejemplo, sigue las PHP instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API PHP Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
use Google\Cloud\Video\Stitcher\V1\Slate;
use Google\Cloud\Video\Stitcher\V1\UpdateSlateRequest;
use Google\Protobuf\FieldMask;

/**
 * Updates a slate's uri field.
 *
 * @param string $callingProjectId     The project ID to run the API call under
 * @param string $location             The location of the slate
 * @param string $slateId              The name of the slate to be created
 * @param string $slateUri             The public URI for an MP4 video with at least one audio track
 */
function update_slate(
    string $callingProjectId,
    string $location,
    string $slateId,
    string $slateUri
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $formattedName = $stitcherClient->slateName($callingProjectId, $location, $slateId);
    $slate = new Slate();
    $slate->setName($formattedName);
    $slate->setUri($slateUri);
    $updateMask = new FieldMask([
        'paths' => ['uri']
    ]);

    // Run slate update request
    $request = (new UpdateSlateRequest())
        ->setSlate($slate)
        ->setUpdateMask($updateMask);
    $operationResponse = $stitcherClient->updateSlate($request);
    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        $result = $operationResponse->getResult();
        // Print results
        printf('Updated slate: %s' . PHP_EOL, $result->getName());
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }
}

Python

Antes de probar este ejemplo, sigue las Python instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Python Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.


import argparse

from google.cloud.video import stitcher_v1
from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
    VideoStitcherServiceClient,
)
from google.protobuf import field_mask_pb2 as field_mask


def update_slate(
    project_id: str, location: str, slate_id: str, slate_uri: str
) -> stitcher_v1.types.Slate:
    """Updates a slate.
    Args:
        project_id: The GCP project ID.
        location: The location of the slate.
        slate_id: The existing slate's ID.
        slate_uri: Updated uri of the video slate; must be an MP4 video with at least one audio track.

    Returns:
        The slate resource.
    """

    client = VideoStitcherServiceClient()

    name = f"projects/{project_id}/locations/{location}/slates/{slate_id}"
    slate = stitcher_v1.types.Slate(
        name=name,
        uri=slate_uri,
    )
    update_mask = field_mask.FieldMask(paths=["uri"])

    operation = client.update_slate(slate=slate, update_mask=update_mask)
    response = operation.result()
    print(f"Updated slate: {response.name}")
    return response

Ruby

Antes de probar este ejemplo, sigue las Ruby instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Ruby Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

require "google/cloud/video/stitcher"

##
# Update a slate
#
# @param project_id [String] Your Google Cloud project (e.g. `my-project`)
# @param location [String] The location (e.g. `us-central1`)
# @param slate_id [String] Your slate name (e.g. `my-slate`)
# @param slate_uri [String] The URI of an MP4 video with at least one audio
#   track (e.g. `https://my-slate-uri/test.mp4`)
#
def update_slate project_id:, location:, slate_id:, slate_uri:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

  # Build the resource name of the slate.
  name = client.slate_path project: project_id, location: location,
                           slate: slate_id

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

  # Set the slate fields.
  update_slate = {
    name: name,
    uri: slate_uri
  }

  operation = client.update_slate slate: update_slate, update_mask: update_mask

  # 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 slate name.
  puts "Updated slate: #{operation.response.name}"
  puts "Updated uri: #{operation.response.uri}"
end

Mostrar todas las pizarras registradas

Para obtener una lista con todas las pizarras registradas en una ubicación concreta de un proyecto, usa el método projects.locations.slates.list.

REST

Antes de usar los datos de la solicitud, haz las siguientes sustituciones:

  • PROJECT_NUMBER: tu número de proyecto; se encuentra en el campo Número de proyecto de la página Configuración de gestión de identidades y accesos. Google Cloud
  • LOCATION: la ubicación de tus pizarras. Usa una de las regiones admitidas.
    Mostrar ubicaciones
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1

Para enviar tu solicitud, despliega una de estas opciones:

Deberías recibir una respuesta JSON similar a la siguiente:

{
  "slates": [
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID",
      "uri": "SLATE_URL"
    },
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/slates/my-other-slate-id",
      "uri": "my-other-slate-url"
    }
  ]
}

C#

Antes de probar este ejemplo, sigue las C# instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API C# Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.


using Google.Api.Gax;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.Video.Stitcher.V1;
using System;

public class ListSlatesSample
{
    public PagedEnumerable<ListSlatesResponse, Slate> ListSlates(
        string projectId, string regionId)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

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

        // Make the request.
        PagedEnumerable<ListSlatesResponse, Slate> response = client.ListSlates(request);
        foreach (Slate slate in response)
        {
            Console.WriteLine($"{slate.Name}");
        }

        // Return the result.
        return response;
    }
}

Go

Antes de probar este ejemplo, sigue las Go instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Go Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

import (
	"context"
	"fmt"
	"io"

	stitcher "cloud.google.com/go/video/stitcher/apiv1"
	stitcherstreampb "cloud.google.com/go/video/stitcher/apiv1/stitcherpb"
	"google.golang.org/api/iterator"
)

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

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

	it := client.ListSlates(ctx, req)
	fmt.Fprintln(w, "Slates:")

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

Java

Antes de probar este ejemplo, sigue las Java instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Java Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.


import com.google.cloud.video.stitcher.v1.ListSlatesRequest;
import com.google.cloud.video.stitcher.v1.LocationName;
import com.google.cloud.video.stitcher.v1.Slate;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient.ListSlatesPagedResponse;
import java.io.IOException;

public class ListSlates {

  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";

    listSlates(projectId, location);
  }

  // Lists the slates for a given project and location.
  public static ListSlatesPagedResponse listSlates(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.
    try (VideoStitcherServiceClient videoStitcherServiceClient =
        VideoStitcherServiceClient.create()) {
      ListSlatesRequest listSlatesRequest =
          ListSlatesRequest.newBuilder()
              .setParent(LocationName.of(projectId, location).toString())
              .build();

      VideoStitcherServiceClient.ListSlatesPagedResponse response =
          videoStitcherServiceClient.listSlates(listSlatesRequest);

      System.out.println("Slates:");
      for (Slate slate : response.iterateAll()) {
        System.out.println(slate.getName());
      }
      return response;
    }
  }
}

Node.js

Antes de probar este ejemplo, sigue las Node.js instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Node.js Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

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

// Imports the Video Stitcher library
const {VideoStitcherServiceClient} =
  require('@google-cloud/video-stitcher').v1;
// Instantiates a client
const stitcherClient = new VideoStitcherServiceClient();

async function listSlates() {
  const iterable = await stitcherClient.listSlatesAsync({
    parent: stitcherClient.locationPath(projectId, location),
  });
  console.info('Slates:');
  for await (const response of iterable) {
    console.log(response.name);
  }
}

listSlates().catch(err => {
  console.error(err.message);
  process.exitCode = 1;
});

PHP

Antes de probar este ejemplo, sigue las PHP instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API PHP Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
use Google\Cloud\Video\Stitcher\V1\ListSlatesRequest;

/**
 * Lists all slates for a location.
 *
 * @param string $callingProjectId     The project ID to run the API call under
 * @param string $location             The location of the slates
 */
function list_slates(
    string $callingProjectId,
    string $location
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $parent = $stitcherClient->locationName($callingProjectId, $location);
    $request = (new ListSlatesRequest())
        ->setParent($parent);
    $response = $stitcherClient->listSlates($request);

    // Print the slate list.
    $slates = $response->iterateAllElements();
    print('Slates:' . PHP_EOL);
    foreach ($slates as $slate) {
        printf('%s' . PHP_EOL, $slate->getName());
    }
}

Python

Antes de probar este ejemplo, sigue las Python instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Python Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.


import argparse

from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
    pagers,
    VideoStitcherServiceClient,
)


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

    Returns:
        An iterable object containing slate resources.
    """

    client = VideoStitcherServiceClient()

    parent = f"projects/{project_id}/locations/{location}"
    response = client.list_slates(parent=parent)
    print("Slates:")
    for slate in response.slates:
        print({slate.name})

    return response

Ruby

Antes de probar este ejemplo, sigue las Ruby instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Ruby Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

require "google/cloud/video/stitcher"

##
# List slates for a given location
#
# @param project_id [String] Your Google Cloud project (e.g. `my-project`)
# @param location [String] The location (e.g. `us-central1`)
#
def list_slates project_id:, location:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

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

  response = client.list_slates parent: parent

  puts "Slates:"
  # Print out all slates.
  response.each do |slate|
    puts slate.name
  end
end

Resultados adicionales

La respuesta curl puede incluir un nextPageToken, que puedes usar para obtener más resultados:

{
  "slates": [
    ...
  ],
  "nextPageToken": "NEXT_PAGE_TOKEN"
}

Puedes enviar otra solicitud curl, incluido el valor de NEXT_PAGE_TOKEN, para enumerar las pizarras adicionales. Añade lo siguiente a la URL de la llamada a la API anterior:

?pageToken=NEXT_PAGE_TOKEN

Consulta la biblioteca de cliente correspondiente para obtener más información sobre el uso de este token.

Eliminar una pizarra

Si ya no necesitas una pizarra registrada, elimínala con el método projects.locations.slates.delete.

REST

Antes de usar los datos de la solicitud, haz las siguientes sustituciones:

  • PROJECT_NUMBER: tu número de proyecto; se encuentra en el campo Número de proyecto de la página Configuración de gestión de identidades y accesos. Google Cloud
  • LOCATION: la ubicación de tu pizarra. Usa una de las regiones admitidas.
    Mostrar ubicaciones
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • SLATE_ID: identificador definido por el usuario de la pizarra

Para enviar tu solicitud, despliega una de estas opciones:

Deberías recibir una respuesta JSON similar a la siguiente:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.common.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID",
    "verb": "delete",
    "cancelRequested": false,
    "apiVersion": "v1"
  },
  "done": false
}
Este comando crea una operación de larga duración (OLD) que puedes consultar para monitorizar el progreso. Para obtener más información, consulta Comprobar el resultado.

C#

Antes de probar este ejemplo, sigue las C# instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API C# Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.


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

public class DeleteSlateSample
{
    public async Task DeleteSlateAsync(
        string projectId, string location, string slateId)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

        DeleteSlateRequest request = new DeleteSlateRequest
        {
            SlateName = SlateName.FromProjectLocationSlate(projectId, location, slateId)
        };

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

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

Go

Antes de probar este ejemplo, sigue las Go instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Go Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

import (
	"context"
	"fmt"
	"io"

	stitcher "cloud.google.com/go/video/stitcher/apiv1"
	stitcherstreampb "cloud.google.com/go/video/stitcher/apiv1/stitcherpb"
)

// deleteSlate deletes a previously-created slate.
func deleteSlate(w io.Writer, projectID, slateID string) error {
	// projectID := "my-project-id"
	// slateID := "my-slate-id"
	location := "us-central1"
	ctx := context.Background()
	client, err := stitcher.NewVideoStitcherClient(ctx)
	if err != nil {
		return fmt.Errorf("stitcher.NewVideoStitcherClient: %w", err)
	}
	defer client.Close()

	name := fmt.Sprintf("projects/%s/locations/%s/slates/%s", projectID, location, slateID)

	req := &stitcherstreampb.DeleteSlateRequest{
		Name: name,
	}
	// Deletes the slate.
	op, err := client.DeleteSlate(ctx, req)
	if err != nil {
		return fmt.Errorf("client.DeleteSlate: %w", err)
	}
	err = op.Wait(ctx)
	if err != nil {
		return err
	}

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

Java

Antes de probar este ejemplo, sigue las Java instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Java Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.


import com.google.cloud.video.stitcher.v1.DeleteSlateRequest;
import com.google.cloud.video.stitcher.v1.SlateName;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class DeleteSlate {

  private static final int TIMEOUT_IN_MINUTES = 2;

  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 slateId = "my-slate-id";

    deleteSlate(projectId, location, slateId);
  }

  // Deletes a slate.
  public static void deleteSlate(String projectId, String location, String slateId)
      throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests.
    try (VideoStitcherServiceClient videoStitcherServiceClient =
        VideoStitcherServiceClient.create()) {
      DeleteSlateRequest deleteSlateRequest =
          DeleteSlateRequest.newBuilder()
              .setName(SlateName.of(projectId, location, slateId).toString())
              .build();

      videoStitcherServiceClient
          .deleteSlateAsync(deleteSlateRequest)
          .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
      System.out.println("Deleted slate");
    }
  }
}

Node.js

Antes de probar este ejemplo, sigue las Node.js instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Node.js Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

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

// Imports the Video Stitcher library
const {VideoStitcherServiceClient} =
  require('@google-cloud/video-stitcher').v1;
// Instantiates a client
const stitcherClient = new VideoStitcherServiceClient();

async function deleteSlate() {
  // Construct request
  const request = {
    name: stitcherClient.slatePath(projectId, location, slateId),
  };
  const [operation] = await stitcherClient.deleteSlate(request);
  await operation.promise();
  console.log('Deleted slate');
}

deleteSlate().catch(err => {
  console.error(err.message);
  process.exitCode = 1;
});

PHP

Antes de probar este ejemplo, sigue las PHP instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API PHP Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
use Google\Cloud\Video\Stitcher\V1\DeleteSlateRequest;

/**
 * Deletes a slate.
 *
 * @param string $callingProjectId     The project ID to run the API call under
 * @param string $location             The location of the slate
 * @param string $slateId              The ID of the slate
 */
function delete_slate(
    string $callingProjectId,
    string $location,
    string $slateId
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $formattedName = $stitcherClient->slateName($callingProjectId, $location, $slateId);
    $request = (new DeleteSlateRequest())
        ->setName($formattedName);
    $operationResponse = $stitcherClient->deleteSlate($request);
    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        // Print status
        printf('Deleted slate %s' . PHP_EOL, $slateId);
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }
}

Python

Antes de probar este ejemplo, sigue las Python instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Python Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.


import argparse

from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
    VideoStitcherServiceClient,
)
from google.protobuf import empty_pb2 as empty


def delete_slate(project_id: str, location: str, slate_id: str) -> empty.Empty:
    """Deletes a slate.
    Args:
        project_id: The GCP project ID.
        location: The location of the slate.
        slate_id: The user-defined slate ID."""

    client = VideoStitcherServiceClient()

    name = f"projects/{project_id}/locations/{location}/slates/{slate_id}"
    operation = client.delete_slate(name=name)
    response = operation.result()
    print("Deleted slate")
    return response

Ruby

Antes de probar este ejemplo, sigue las Ruby instrucciones de configuración de la guía de inicio rápido de la API Video Stitcher con bibliotecas de cliente. Para obtener más información, consulta la documentación de referencia de la API Ruby Video Stitcher API.

Para autenticarte en la API Video Stitcher, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.

require "google/cloud/video/stitcher"

##
# Delete a slate
#
# @param project_id [String] Your Google Cloud project (e.g. `my-project`)
# @param location [String] The location (e.g. `us-central1`)
# @param slate_id [String] Your slate name (e.g. `my-slate`)
#
def delete_slate project_id:, location:, slate_id:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

  # Build the resource name of the slate.
  name = client.slate_path project: project_id, location: location,
                           slate: slate_id

  # Delete the slate.
  operation = client.delete_slate 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 slate"
end