Crie e faça a gestão de listas

As faixas são conteúdo que pode ser publicado quando existem lacunas numa pausa para anúncios de uma stream em direto que não podem ser preenchidas por um anúncio publicado dinamicamente. Um anúncio pode estar indisponível por vários motivos, incluindo, entre outros, os seguintes:

  • Ocorrem erros ao obter recursos de RFCs (redes de fornecimento de conteúdos)
  • Ocorrem erros durante o processamento de recursos enquanto são unidos

Antes de a API Video Stitcher poder inserir uma faixa, o recurso de vídeo da faixa tem de ser registado. O registo é necessário para que a API Video Stitcher possa preparar o recurso de ardósia para inserção na ausência de anúncios.

Este documento descreve como gerir listas. Para mais detalhes, consulte a documentação REST.

Registe uma faixa

Para registar uma ardósia, use o método projects.locations.slates.create.

REST

Antes de usar qualquer um dos dados do pedido, faça as seguintes substituições:

  • PROJECT_NUMBER: o seu Google Cloud número do projeto; este encontra-se no campo Número do projeto na página Definições de IAM
  • LOCATION: a localização na qual criar a sua lista; use uma das regiões suportadas
    Mostrar localizações
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • SLATE_ID: um identificador definido pelo utilizador para a lista de sugestões. Este ID só pode conter letras minúsculas, números e hífenes. O primeiro caráter tem de ser uma letra, o último caráter tem de ser uma letra ou um número, e o ID completo tem um máximo de 63 carateres.
  • SLATE_URL: o URI público de um vídeo MP4 com, pelo menos, uma faixa de áudio (vídeo de exemplo)

Para enviar o seu pedido, expanda uma destas opções:

Deve receber uma resposta JSON semelhante à seguinte:

{
  "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 cria uma operação de longa duração (LRO) que pode consultar para acompanhar o progresso. Copie o valor devolvido OPERATION_ID, que é a última parte do campo name, para usar na secção seguinte.

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 Video StitcherC#.

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.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 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 Video StitcherGo.

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

// 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 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 Video StitcherJava.

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.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 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 Video StitcherNode.js.

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';
// 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 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 Video StitcherPHP.

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

##
# 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

Verifique o resultado

Para verificar se a indicação foi criada, use o método projects.locations.operations.get. Se a resposta contiver "done: false", repita o comando até que a resposta contenha "done: true".

Antes de usar qualquer um dos dados do pedido, faça as seguintes substituições:

  • PROJECT_NUMBER: o número do seu Google Cloud projeto; encontra-se no campo Número do projeto na página Definições de IAM
  • LOCATION: a localização dos dados; use uma das regiões suportadas
    Mostrar localizações
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • OPERATION_ID: o identificador da operação

Para enviar o seu pedido, expanda uma destas opções:

Deve receber uma resposta JSON semelhante à seguinte:

{
  "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"
  }
}

Crie uma faixa

Para obter os detalhes de uma ardósia específica, use o método projects.locations.slates.get.

REST

Antes de usar qualquer um dos dados do pedido, faça as seguintes substituições:

  • PROJECT_NUMBER: o seu Google Cloud número do projeto; este encontra-se no campo Número do projeto na página Definições de IAM
  • LOCATION: a localização onde a sua lista de reprodução está localizada; use uma das regiões suportadas
    Mostrar localizações
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • SLATE_ID: um identificador definido pelo utilizador para o slate

Para enviar o seu pedido, expanda uma destas opções:

Deve receber uma resposta JSON semelhante à seguinte:

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

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 Video StitcherC#.

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.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 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 Video StitcherGo.

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"
	"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 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 Video StitcherJava.

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.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 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 Video StitcherNode.js.

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';
// 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 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 Video StitcherPHP.

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

##
# 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

Atualize uma ardósia

Para atualizar uma lista específica, use o método projects.locations.slates.patch.

REST

Antes de usar qualquer um dos dados do pedido, faça as seguintes substituições:

  • PROJECT_NUMBER: o seu Google Cloud número do projeto; este encontra-se no campo Número do projeto na página Definições de IAM
  • LOCATION: a localização para criar a sua lista de sugestões; use uma das regiões suportadas
    Mostrar localizações
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • SLATE_ID: um identificador definido pelo utilizador para o slate
  • SLATE_URL: este URI tem de devolver um vídeo MP4 com, pelo menos, uma faixa de áudio

Para enviar o seu pedido, expanda uma destas opções:

Deve receber uma resposta JSON semelhante à seguinte:

{
  "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 cria uma operação de longa duração (LRO) que pode consultar para acompanhar o progresso. Para mais informações, consulte a secção Verifique o resultado.

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 Video StitcherC#.

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.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 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 Video StitcherGo.

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/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 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 Video StitcherJava.

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.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 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 Video StitcherNode.js.

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';
// 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 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 Video StitcherPHP.

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

##
# 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

Apresentar todas as listas registadas

Para listar todas as listas de reprodução registadas para uma determinada localização num projeto, use o método projects.locations.slates.list.

REST

Antes de usar qualquer um dos dados do pedido, faça as seguintes substituições:

  • PROJECT_NUMBER: o seu Google Cloud número do projeto; este encontra-se no campo Número do projeto na página Definições de IAM
  • LOCATION: a localização onde se encontram as suas listas; use uma das regiões suportadas
    Mostrar localizações
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1

Para enviar o seu pedido, expanda uma destas opções:

Deve receber uma resposta JSON semelhante à seguinte:

{
  "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 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 Video StitcherC#.

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 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 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 Video StitcherGo.

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

// 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 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 Video StitcherJava.

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.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 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 Video StitcherNode.js.

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 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 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 Video StitcherPHP.

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\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 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_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 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 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 adicionais

A resposta curl pode incluir um nextPageToken, que pode usar para obter resultados adicionais:

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

Pode enviar outro pedido curl, incluindo o valor de NEXT_PAGE_TOKEN, para listar as seleções adicionais. Anexe o seguinte ao URL na chamada da API anterior:

?pageToken=NEXT_PAGE_TOKEN

Consulte a biblioteca de cliente relevante para mais informações sobre a utilização deste token.

Elimine uma ardósia

Se já não precisar de uma ardósia registada, elimine-a através do método projects.locations.slates.delete.

REST

Antes de usar qualquer um dos dados do pedido, faça as seguintes substituições:

  • PROJECT_NUMBER: o seu Google Cloud número do projeto; este encontra-se no campo Número do projeto na página Definições de IAM
  • LOCATION: a localização onde a sua lista de reprodução está localizada; use uma das regiões suportadas
    Mostrar localizações
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • SLATE_ID: um identificador definido pelo utilizador para o slate

Para enviar o seu pedido, expanda uma destas opções:

Deve receber uma resposta JSON semelhante à seguinte:

{
  "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 cria uma operação de longa duração (LRO) que pode consultar para acompanhar o progresso. Para mais informações, consulte a secção Verifique o resultado.

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 Video StitcherC#.

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.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 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 Video StitcherGo.

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

// 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 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 Video StitcherJava.

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.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 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 Video StitcherNode.js.

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';
// 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 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 Video StitcherPHP.

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\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 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 (
    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 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"

##
# 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