Liste as configurações de VOD

Listar todos os recursos de configuração de VOD do Video Stitcher para uma localização.

Explore mais

Para ver documentação detalhada que inclui este exemplo de código, consulte o seguinte:

Exemplo de código

C#

Antes de experimentar este exemplo, siga as C#instruções de configuração no guia de início rápido da API Video Stitcher com bibliotecas cliente. Para mais informações, consulte a documentação de referência da API C# Video Stitcher API.

Para se autenticar na API Video Stitcher, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para um ambiente de desenvolvimento local.


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

public class ListVodConfigsSample
{
    public PagedEnumerable<ListVodConfigsResponse, VodConfig> ListVodConfigs(
        string projectId, string regionId)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

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

        // Make the request.
        PagedEnumerable<ListVodConfigsResponse, VodConfig> response = client.ListVodConfigs(request);
        foreach (VodConfig vodConfig in response)
        {
            Console.WriteLine($"{vodConfig.Name}");
        }

        // Return the result.
        return response;
    }
}

Go

Antes de experimentar este exemplo, siga as Goinstruções de configuração no guia de início rápido da API Video Stitcher com bibliotecas cliente. Para mais informações, consulte a documentação de referência da API Go Video Stitcher API.

Para se autenticar na API Video Stitcher, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para um ambiente de desenvolvimento 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"
)

// listVodConfigs lists all VOD configs for a given location.
func listVodConfigs(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.ListVodConfigsRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s", projectID, location),
	}

	it := client.ListVodConfigs(ctx, req)
	fmt.Fprintln(w, "VOD configs:")

	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 experimentar este exemplo, siga as Javainstruções de configuração no guia de início rápido da API Video Stitcher com bibliotecas cliente. Para mais informações, consulte a documentação de referência da API Java Video Stitcher API.

Para se autenticar na API Video Stitcher, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para um ambiente de desenvolvimento local.


import com.google.cloud.video.stitcher.v1.ListVodConfigsRequest;
import com.google.cloud.video.stitcher.v1.LocationName;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient.ListVodConfigsPagedResponse;
import com.google.cloud.video.stitcher.v1.VodConfig;
import java.io.IOException;

public class ListVodConfigs {

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

    listVodConfigs(projectId, location);
  }

  // Lists all the video on demand (VOD) configs for a given project and locatin.
  public static ListVodConfigsPagedResponse listVodConfigs(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()) {
      ListVodConfigsRequest listVodConfigsRequest =
          ListVodConfigsRequest.newBuilder()
              .setParent(LocationName.of(projectId, location).toString())
              .build();

      VideoStitcherServiceClient.ListVodConfigsPagedResponse response =
          videoStitcherServiceClient.listVodConfigs(listVodConfigsRequest);

      System.out.println("VOD configs:");
      for (VodConfig vodConfig : response.iterateAll()) {
        System.out.println(vodConfig.getName());
      }
      return response;
    }
  }
}

Node.js

Antes de experimentar este exemplo, siga as Node.jsinstruções de configuração no guia de início rápido da API Video Stitcher com bibliotecas cliente. Para mais informações, consulte a documentação de referência da API Node.js Video Stitcher API.

Para se autenticar na API Video Stitcher, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para um ambiente de desenvolvimento 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 listVodConfigs() {
  const iterable = await stitcherClient.listVodConfigsAsync({
    parent: stitcherClient.locationPath(projectId, location),
  });
  console.info('VOD configs:');
  for await (const response of iterable) {
    console.log(response.name);
  }
}

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

PHP

Antes de experimentar este exemplo, siga as PHPinstruções de configuração no guia de início rápido da API Video Stitcher com bibliotecas cliente. Para mais informações, consulte a documentação de referência da API PHP Video Stitcher API.

Para se autenticar na API Video Stitcher, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para um ambiente de desenvolvimento local.

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

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

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

    // Print the VOD config list.
    $vodConfigs = $response->iterateAllElements();
    print('VOD configs:' . PHP_EOL);
    foreach ($vodConfigs as $vodConfig) {
        printf('%s' . PHP_EOL, $vodConfig->getName());
    }
}

Python

Antes de experimentar este exemplo, siga as Pythoninstruções de configuração no guia de início rápido da API Video Stitcher com bibliotecas cliente. Para mais informações, consulte a documentação de referência da API Video StitcherPython.

Para se autenticar na API Video Stitcher, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para um ambiente de desenvolvimento local.


import argparse

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


def list_vod_configs(project_id: str, location: str) -> pagers.ListVodConfigsPager:
    """Lists all VOD configs in a location.
    Args:
        project_id: The GCP project ID.
        location: The location of the VOD configs.

    Returns:
        An iterable object containing VOD config resources.
    """

    client = VideoStitcherServiceClient()

    parent = f"projects/{project_id}/locations/{location}"
    response = client.list_vod_configs(parent=parent)
    print("VOD configs:")
    for vod_config in response.vod_configs:
        print({vod_config.name})

    return response

Ruby

Antes de experimentar este exemplo, siga as Rubyinstruções de configuração no guia de início rápido da API Video Stitcher com bibliotecas cliente. Para mais informações, consulte a documentação de referência da API Video StitcherRuby.

Para se autenticar na API Video Stitcher, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para um ambiente de desenvolvimento local.

require "google/cloud/video/stitcher"

##
# List VOD configs 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_vod_configs 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_vod_configs parent: parent

  puts "VOD configs:"
  # Print out all VOD configs.
  response.each do |vod_config|
    puts vod_config.name
  end
end

O que se segue?

Para pesquisar e filtrar exemplos de código para outros Google Cloud produtos, consulte o Google Cloud navegador de exemplos.