אחזור סוגי מעבדים (גרסה 1)

אחזור של סוגי המעבדים שזמינים לפרויקט ולמיקום ספציפיים.

דוגמת קוד

Java

מידע נוסף מופיע במאמרי העזרה של Document AI Java API.

כדי לבצע אימות ב-Document AI, צריך להגדיר את Application Default Credentials. למידע נוסף, ראו הגדרת אימות לסביבת פיתוח מקומית.

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 .