Mostrar pizarras

Muestra todos los recursos de pizarra de Video Stitcher de una ubicación.

Investigar más

Para obtener documentación detallada que incluya este código de muestra, consulta lo siguiente:

Código de ejemplo

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

Siguientes pasos

Para buscar y filtrar ejemplos de código de otros Google Cloud productos, consulta el Google Cloud navegador de ejemplos.