다운로드 작업 만들기

sdfdownloadtasks.create 요청은 장기 실행 작업을 만듭니다. 이 작업으로 구조화된 데이터 파일(SDF)이 생성됩니다.

요청 필드는 SDF를 정의합니다.

  • partnerId 또는 advertiserId: SDF의 콘텐츠를 지정된 파트너 또는 광고주의 컨텍스트로 제한합니다. 필드는 하나만 설정할 수 있습니다.
  • version: 사용할 SDF 버전을 정의합니다. 설정하지 않으면 파트너 또는 광고주 설정이 기본값으로 사용됩니다.
  • parentEntityFilter, idFilter 또는 inventorySourceFilter: SDF의 콘텐츠를 정의합니다. 필드는 하나만 설정할 수 있습니다.

다음은 지정된 캠페인의 게재 신청서 및 광고 항목 SDF를 생성하는 다운로드 작업을 만드는 방법입니다.

자바

// Provide the ID of the parent advertiser of the resources to retrieve.
long advertiserId = advertiser-id;

// Provide the Structured Data Files version to download.
String sdfVersion = sdf-version;

// Provide the IDs of the parent campaigns of the resources to retrieve.
List<Long> campaignIds = campaign-ids;

// Create the filter structure.
ParentEntityFilter parentEntityFilter =
    new ParentEntityFilter()
        .setFileType(Arrays.asList("FILE_TYPE_INSERTION_ORDER", "FILE_TYPE_LINE_ITEM"))
        .setFilterType("FILTER_TYPE_CAMPAIGN_ID")
        .setFilterIds(campaignIds);

// Configure and create the SDF download task.
Operation operation =
    service
        .sdfdownloadtasks()
        .create(
            new CreateSdfDownloadTaskRequest()
                .setVersion(sdfVersion)
                .setAdvertiserId(advertiserId)
                .setParentEntityFilter(parentEntityFilter))
        .execute();

// Print the resulting operation name.
System.out.printf("Operation %s was created.", operation.getName());

Python

# Provide the ID of the parent advertiser of the resources to retrieve.
advertiser_id = advertiser-id

# Provide the Structured Data Files version to download.
sdf_version = sdf-version

# Provide the IDs of the parent campaigns of the resources to retrieve.
campaign_ids = campaign-ids

# Create the request body.
body = {
    "version": sdf_version,
    "advertiserId": advertiser_id,
    "parentEntityFilter": {
        "fileType": ["FILE_TYPE_INSERTION_ORDER", "FILE_TYPE_LINE_ITEM"],
        "filterType": "FILTER_TYPE_CAMPAIGN_ID",
        "filterIds": campaign_ids,
    },
}

# Create the operation.
operation = service.sdfdownloadtasks().create(body=body).execute()

# Print resulting operation name.
print(f'Operation {operation["name"]} was created.')

PHP

// Provide the ID of the parent advertiser of the resources to retrieve.
$advertiserId = advertiser-id;

// Provide the Structured Data Files version to download.
$sdfVersion = sdf-version;

// Provide the IDs of the parent campaigns of the resources to retrieve.
$campaignIds = campaign-ids;

// Create the filter structure.
$filter = new Google_Service_DisplayVideo_ParentEntityFilter();
$filter->setFileType(array('FILE_TYPE_INSERTION_ORDER','FILE_TYPE_LINE_ITEM'));
$filter->setFilterType('FILTER_TYPE_CAMPAIGN_ID');
$filter->setFilterIds($campaignIds);

// Configure and create the SDF download task.
$createDownloadRequest = new Google_Service_DisplayVideo_CreateSdfDownloadTaskRequest();
$createDownloadRequest->setVersion($sdfVersion);
$createDownloadRequest->setAdvertiserId($advertiserId);
$createDownloadRequest->setParentEntityFilter($filter);

// Call the API, creating the SDF Download Task.
$operation = $this->service->sdfdownloadtasks->create(
    $createDownloadRequest
);

// Print the resulting operation name.
printf('<p>Operation %s was created.</p>', $operation['name']);