보고서 실행

보고서를 실행하면 기존 Report 템플릿의 실행이 시작되어 큐레이션 계정의 실적 데이터가 생성됩니다.

이 가이드에서는 큐레이션 계정의 실적을 설명하는 보고서를 생성하는 방법을 설명합니다. 큐레이션 파트너 API를 사용하여 run a Report 템플릿을 실행합니다.

시작하기 전에

계속하기 전에 다음을 완료해야 합니다.

보고서 실행 시작

기존 보고서를 실행하려면 curators.reports.run 메서드를 사용합니다.

다음 예에서는 보고서 실행을 시작하기 위해 POST 요청을 실행합니다.

REST

요청

curl --request POST \
  'https://curationpartners.googleapis.com/v1/curators/ACCOUNT_ID/reports/123456789:run' \
  --header 'Authorization: Bearer ACCESS_TOKEN' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{}' \
  --compressed

다음을 바꿉니다.

  • ACCOUNT_ID: 계정 ID입니다.
  • ACCESS_TOKEN: 액세스 토큰입니다.

응답

{
  "name": "curators/ACCOUNT_ID/reports/123456789/operations/10486370264",
  "done": false,
  "metadata": {
    "@type": "type.googleapis.com/google.ads.curationpartners.v1.RunReportMetadata"
  }
}

자바

/*
 * Copyright (c) 2026 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package com.google.api.services.samples.curationpartners.v1.curators.reports;

import com.google.api.services.curationpartners.v1.CurationPartners;
import com.google.api.services.curationpartners.v1.model.Operation;
import com.google.api.services.curationpartners.v1.model.RunReportRequest;
import com.google.api.services.samples.curationpartners.v1.Utils;
import java.io.IOException;
import java.security.GeneralSecurityException;
import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;

public class RunReport {

  /**
   * Executes the run operation for a report.
   *
   * @param curationPartnersClient the initialized Curation Partners API client.
   * @param accountId the account ID of the curator that created the report.
   * @param reportId the resource ID of the report to run.
   * @throws IOException if the API returns an error.
   */
  public static void execute(
      CurationPartners curationPartnersClient, Long accountId, String reportId)
      throws IOException {
    String name = String.format("curators/%s/reports/%s", accountId, reportId);

    System.out.printf("Running report with name \"%s\".%n", name);

    RunReportRequest requestBody = new RunReportRequest();

    // Run the specified report to start an asynchronous operation.
    Operation operation =
        curationPartnersClient
            .curators()
            .reports()
            .run(name, requestBody)
            .execute();

    System.out.println("Successfully initiated report run operation:");
    Utils.jsonPrettyPrint(operation);
  }

  /**
   * Creates and configures the ArgumentParser for this sample.
   *
   * @return the configured ArgumentParser.
   */
  private static ArgumentParser createArgumentParser() {
    ArgumentParser parser =
        ArgumentParsers.newFor("RunReport")
            .build()
            .defaultHelp(true)
            .description("Runs a specified report asynchronously, returning an Operation " +
                "that can be used to track its progress.");

    // Required arguments.
    parser
        .addArgument("-a", "--account_id")
        .help("The account ID of the curator that created the report.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("-r", "--report_id")
        .help("The resource ID of the report to run.")
        .required(true);

    return parser;
  }

  public static void main(String[] args) {
    ArgumentParser parser = createArgumentParser();

    Namespace parsedArgs = null;
    try {
      parsedArgs = parser.parseArgs(args);
    } catch (ArgumentParserException ex) {
      parser.handleError(ex);
      System.exit(1);
    }

    CurationPartners client = null;
    try {
      client = Utils.getCurationPartnersClient();
    } catch (IOException ex) {
      System.out.printf("Unable to create Curation Partners API service:%n%s", ex);
      System.out.println("Did you specify a valid path to a service account key file?");
      System.exit(1);
    } catch (GeneralSecurityException ex) {
      System.out.printf("Unable to establish secure HttpTransport:%n%s", ex);
      System.exit(1);
    }

    try {
      execute(
          client,
          parsedArgs.getLong("account_id"),
          parsedArgs.getString("report_id"));
    } catch (IOException ex) {
      System.out.printf("Curation Partners API returned error response:%n%s", ex);
      System.exit(1);
    }
  }
}

보고서 실행은 비동기 장기 실행 작업입니다. run 메서드를 호출하면 큐레이션 파트너 API가 Operation 리소스로 응답합니다. 작업의 name 필드는 실행 작업을 식별하며 형식은 다음과 같습니다.

curators/ACCOUNT_ID/reports/REPORT_ID/operations/OPERATION_ID

반환된 Operation 객체에는 다음이 포함됩니다.

  • name: 장기 실행 작업에 대해 서버에서 할당한 이름입니다.
  • metadata: 서비스별 진행률 정보(선택사항)입니다. curators.reports.run 응답에서 수신하는 Operation 객체에 metadata 필드가 채워지지 않을 수 있습니다.

보고서 실행을 시작한 후에는 작업의 done 필드가 true 값일 때까지 보고서 결과를 볼 수 없습니다. 보고서 실행이 완료되는 데 걸리는 시간은 보고서의 복잡성에 따라 다릅니다.

다음 단계