작업 템플릿 나열

지정된 위치의 모든 트랜스코딩 작업 템플릿을 나열합니다.

더 살펴보기

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

코드 샘플

C#

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

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


using Google.Cloud.Video.Transcoder.V1;
using Google.Api.Gax.ResourceNames;
using Google.Api.Gax;
using System.Linq;
using System.Collections.Generic;

public class ListJobTemplatesSample
{
    public IList<JobTemplate> ListJobTemplates(string projectId, string location)
    {
        // Create the client.
        TranscoderServiceClient client = TranscoderServiceClient.Create();

        // Build the parent location name.
        LocationName parentLocation = new LocationName(projectId, location);

        // Call the API.
        PagedEnumerable<ListJobTemplatesResponse, JobTemplate> response = client.ListJobTemplates(parentLocation);

        // The returned sequence will lazily perform RPCs as it's being iterated over.
        return response.ToList();
    }
}

Go

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

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

import (
	"context"
	"fmt"
	"io"

	"google.golang.org/api/iterator"

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

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

	req := &transcoderpb.ListJobTemplatesRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s", projectID, location),
	}

	it := client.ListJobTemplates(ctx, req)
	fmt.Fprintln(w, "Job templates:")
	for {
		response, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("ListJobTemplates: %w", err)
		}
		fmt.Fprintln(w, response.GetName())
	}

	return nil
}

Java

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

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


import com.google.cloud.video.transcoder.v1.JobTemplate;
import com.google.cloud.video.transcoder.v1.ListJobTemplatesRequest;
import com.google.cloud.video.transcoder.v1.LocationName;
import com.google.cloud.video.transcoder.v1.TranscoderServiceClient;
import java.io.IOException;

public class ListJobTemplates {

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

    listJobTemplates(projectId, location);
  }

  // Lists the job templates for a given location.
  public static void listJobTemplates(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 (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {

      ListJobTemplatesRequest listJobTemplatesRequest =
          ListJobTemplatesRequest.newBuilder()
              .setParent(LocationName.of(projectId, location).toString())
              .build();

      // Send the list job templates request and process the response.
      TranscoderServiceClient.ListJobTemplatesPagedResponse response =
          transcoderServiceClient.listJobTemplates(listJobTemplatesRequest);
      System.out.println("Job templates:");

      for (JobTemplate jobTemplate : response.iterateAll()) {
        System.out.println(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';

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

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

async function listJobTemplates() {
  const iterable = await transcoderServiceClient.listJobTemplatesAsync({
    parent: transcoderServiceClient.locationPath(projectId, location),
  });
  console.info('Job templates:');
  for await (const response of iterable) {
    console.log(response.name);
  }
}

listJobTemplates();

PHP

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

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

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

/**
 * Lists all Transcoder job templates in a location.
 *
 * @param string $projectId The ID of your Google Cloud Platform project.
 * @param string $location The location of the job templates.
 */
function list_job_templates($projectId, $location)
{
    // Instantiate a client.
    $transcoderServiceClient = new TranscoderServiceClient();

    $formattedParent = $transcoderServiceClient->locationName($projectId, $location);
    $request = (new ListJobTemplatesRequest())
        ->setParent($formattedParent);
    $response = $transcoderServiceClient->listJobTemplates($request);

    // Print job template list.
    $jobTemplates = $response->iterateAllElements();
    print('Job templates:' . PHP_EOL);
    foreach ($jobTemplates as $jobTemplate) {
        printf('%s' . PHP_EOL, $jobTemplate->getName());
    }
}

Python

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

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


import argparse

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

def list_job_templates(
    project_id: str,
    location: str,
) -> pagers.ListJobTemplatesPager:
    """Lists all job templates in a location.

    Args:
        project_id: The GCP project ID.
        location: The location of the templates.

    Returns:
        An iterable object containing job template resources.
    """

    client = TranscoderServiceClient()

    parent = f"projects/{project_id}/locations/{location}"
    response = client.list_job_templates(parent=parent)
    print("Job templates:")
    for jobTemplate in response.job_templates:
        print({jobTemplate.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")

# 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 parent.
parent = client.location_path project: project_id, location: location

# Get the list of job templates.
response = client.list_job_templates parent: parent

puts "Job templates:"
# Print out all job templates.
response.each do |job_template|
  puts job_template.name
end

다음 단계

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