작업 템플릿 가져오기

특정 트랜스코딩 작업 템플릿에 대한 세부정보를 가져옵니다.

더 살펴보기

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

코드 샘플

C#

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

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


using Google.Cloud.Video.Transcoder.V1;

public class GetJobTemplateSample
{
    public JobTemplate GetJobTemplate(string projectId, string location, string templateId)
    {
        // Create the client.
        TranscoderServiceClient client = TranscoderServiceClient.Create();

        // Build the job template name.
        JobTemplateName name = JobTemplateName.FromProjectLocationJobTemplate(projectId, location, templateId);

        // Call the API.
        JobTemplate jobTemplate = client.GetJobTemplate(name);

        // Return the result.
        return jobTemplate;
    }
}

Go

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

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

import (
	"context"
	"fmt"
	"io"

	transcoder "cloud.google.com/go/video/transcoder/apiv1"
	"cloud.google.com/go/video/transcoder/apiv1/transcoderpb"
)

// getJobTemplate gets a previously-created job template. See
// https://cloud.google.com/transcoder/docs/how-to/job-templates#get_job_template
// for more information.
func getJobTemplate(w io.Writer, projectID string, location string, templateID string) error {
	// projectID := "my-project-id"
	// location := "us-central1"
	// templateID := "my-job-template"
	ctx := context.Background()
	client, err := transcoder.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient: %w", err)
	}
	defer client.Close()

	req := &transcoderpb.GetJobTemplateRequest{
		Name: fmt.Sprintf("projects/%s/locations/%s/jobTemplates/%s", projectID, location, templateID),
	}

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

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

Java

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

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


import com.google.cloud.video.transcoder.v1.GetJobTemplateRequest;
import com.google.cloud.video.transcoder.v1.JobTemplate;
import com.google.cloud.video.transcoder.v1.JobTemplateName;
import com.google.cloud.video.transcoder.v1.TranscoderServiceClient;
import java.io.IOException;

public class GetJobTemplate {

  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 templateId = "my-job-template";

    getJobTemplate(projectId, location, templateId);
  }

  // Gets a job template.
  public static void getJobTemplate(String projectId, String location, String templateId)
      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 (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
      JobTemplateName jobTemplateName =
          JobTemplateName.newBuilder()
              .setProject(projectId)
              .setLocation(location)
              .setJobTemplate(templateId)
              .build();
      GetJobTemplateRequest getJobTemplateRequest =
          GetJobTemplateRequest.newBuilder().setName(jobTemplateName.toString()).build();

      // Send the get job template request and process the response.
      JobTemplate jobTemplate = transcoderServiceClient.getJobTemplate(getJobTemplateRequest);
      System.out.println("Job template: " + jobTemplate.getName());
    }
  }
}

Node.js

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

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

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

// Imports the Transcoder library
const {TranscoderServiceClient} =
  require('@google-cloud/video-transcoder').v1;

// Instantiates a client
const transcoderServiceClient = new TranscoderServiceClient();

async function getJobTemplate() {
  // Construct request
  const request = {
    name: transcoderServiceClient.jobTemplatePath(
      projectId,
      location,
      templateId
    ),
  };
  const [jobTemplate] = await transcoderServiceClient.getJobTemplate(request);
  console.log(`Job template: ${jobTemplate.name}`);
}

getJobTemplate();

PHP

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

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

use Google\Cloud\Video\Transcoder\V1\Client\TranscoderServiceClient;
use Google\Cloud\Video\Transcoder\V1\GetJobTemplateRequest;

/**
 * Gets a Transcoder job template.
 *
 * @param string $projectId The ID of your Google Cloud Platform project.
 * @param string $location The location of the job template.
 * @param string $templateId The user-defined template ID.
 */
function get_job_template($projectId, $location, $templateId)
{
    // Instantiate a client.
    $transcoderServiceClient = new TranscoderServiceClient();

    $formattedName = $transcoderServiceClient->jobTemplateName($projectId, $location, $templateId);
    $request = (new GetJobTemplateRequest())
        ->setName($formattedName);
    $template = $transcoderServiceClient->getJobTemplate($request);

    // Print job template name.
    printf('Job template: %s' . PHP_EOL, $template->getName());
}

Python

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

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


import argparse

from google.cloud.video import transcoder_v1
from google.cloud.video.transcoder_v1.services.transcoder_service import (
    TranscoderServiceClient,
)

def get_job_template(
    project_id: str,
    location: str,
    template_id: str,
) -> transcoder_v1.types.resources.JobTemplate:
    """Gets a job template.

    Args:
        project_id: The GCP project ID.
        location: The location of the template.
        template_id: The user-defined template ID.

    Returns:
        The job template resource.
    """

    client = TranscoderServiceClient()

    name = f"projects/{project_id}/locations/{location}/jobTemplates/{template_id}"
    response = client.get_job_template(name=name)
    print(f"Job template: {response.name}")
    return response

Ruby

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

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

# project_id  = "YOUR-GOOGLE-CLOUD-PROJECT"  # (e.g. "my-project")
# location    = "YOUR-JOB-TEMPLATE-LOCATION"  # (e.g. "us-central1")
# template_id = "YOUR-JOB-TEMPLATE"  # (e.g. "my-job-template")

# Require the Transcoder client library.
require "google/cloud/video/transcoder"

# Create a Transcoder client.
client = Google::Cloud::Video::Transcoder.transcoder_service

# Build the resource name of the job template.
name = client.job_template_path project: project_id, location: location, job_template: template_id

# Get the job template.
job_template = client.get_job_template name: name

# Print the job template name.
puts "Job template: #{job_template.name}"

다음 단계

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