프로세서 유형 가져오기(v1)

특정 프로젝트 및 위치에 사용 가능한 프로세서 유형을 가져옵니다.

코드 샘플

Java

자세한 내용은 Document AI Java API 참고 문서를 참조하세요.

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

import com.google.cloud.documentai.v1.DocumentProcessorServiceClient;
import com.google.cloud.documentai.v1.DocumentProcessorServiceSettings;
import com.google.cloud.documentai.v1.FetchProcessorTypesRequest;
import com.google.cloud.documentai.v1.FetchProcessorTypesResponse;
import com.google.cloud.documentai.v1.ProcessorType;
import java.io.IOException;

public class FetchProcessorTypes {

  public static void main(String[] args) throws Exception {
    String projectId = "example-project-id";
    String locationId = "us";
    fetchProcessorTypes(projectId, locationId);
  }

  public static void fetchProcessorTypes(String projectId, String locationId) throws Exception {
    // Configure the client to connect to the regional endpoint.
    String endpoint = String.format("%s-documentai.googleapis.com:443", locationId);
    DocumentProcessorServiceSettings settings =
        DocumentProcessorServiceSettings.newBuilder().setEndpoint(endpoint).build();

    try (DocumentProcessorServiceClient client = DocumentProcessorServiceClient.create(settings)) {
      String parent = String.format("projects/%s/locations/%s", projectId, locationId);
      FetchProcessorTypesRequest request =
          FetchProcessorTypesRequest.newBuilder().setParent(parent).build();

      FetchProcessorTypesResponse response = client.fetchProcessorTypes(request);

      for (ProcessorType processorType : response.getProcessorTypesList()) {
        System.out.printf("Processor Type: %s%n", processorType.getType());
        System.out.printf("Category: %s%n", processorType.getCategory());
        System.out.printf("Allow Creation: %b%n", processorType.getAllowCreation());
      }
    }
  }
}

다음 단계

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