슬레이트 가져오기

동영상 광고 삽입 도구 슬레이트 리소스의 세부정보를 가져옵니다.

더 살펴보기

이 코드 샘플이 포함된 자세한 문서는 다음을 참조하세요.

코드 샘플

C#

이 샘플을 사용해 보기 전에 Video Stitcher API 빠른 시작: 클라이언트 라이브러리 사용C# 설정 안내를 따르세요. 자세한 내용은 Video Stitcher API C# API 참조 문서를 확인하세요.

Video Stitcher API에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정하세요. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.


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

이 샘플을 사용해 보기 전에 Video Stitcher API 빠른 시작: 클라이언트 라이브러리 사용Go 설정 안내를 따르세요. 자세한 내용은 Video Stitcher API Go API 참조 문서를 확인하세요.

Video Stitcher API에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정하세요. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

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

이 샘플을 사용해 보기 전에 Video Stitcher API 빠른 시작: 클라이언트 라이브러리 사용Java 설정 안내를 따르세요. 자세한 내용은 Video Stitcher API Java API 참조 문서를 확인하세요.

Video Stitcher API에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정하세요. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.


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);
  }

  public static void 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. In this example, try-with-resources is used
    // which automatically calls close() on the client to clean up resources.
    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());
    }
  }
}

Node.js

이 샘플을 사용해 보기 전에 Video Stitcher API 빠른 시작: 클라이언트 라이브러리 사용Node.js 설정 안내를 따르세요. 자세한 내용은 Video Stitcher API Node.js API 참조 문서를 확인하세요.

Video Stitcher API에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정하세요. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

/**
 * 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();

PHP

이 샘플을 사용해 보기 전에 Video Stitcher API 빠른 시작: 클라이언트 라이브러리 사용PHP 설정 안내를 따르세요. 자세한 내용은 Video Stitcher API PHP API 참조 문서를 확인하세요.

Video Stitcher API에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정하세요. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

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

이 샘플을 사용해 보기 전에 Video Stitcher API 빠른 시작: 클라이언트 라이브러리 사용Python 설정 안내를 따르세요. 자세한 내용은 Video Stitcher API Python API 참조 문서를 확인하세요.

Video Stitcher API에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정하세요. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.


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

이 샘플을 사용해 보기 전에 Video Stitcher API 빠른 시작: 클라이언트 라이브러리 사용Ruby 설정 안내를 따르세요. 자세한 내용은 Video Stitcher API Ruby API 참조 문서를 확인하세요.

Video Stitcher API에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정하세요. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

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

다음 단계

다른 Google Cloud 제품의 코드 샘플을 검색하고 필터링하려면 Google Cloud 샘플 브라우저를 참조하세요.