@@ -0,0 +1,3018 @@
+/*%0A * Copyright 2020 Google LLC%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.example.bigquerydatatransfer;%0A%0A// %5BSTART bigquerydatatransfer_create_admanager_transfer%5D%0Aimport com.google.api.gax.rpc.ApiException;%0Aimport com.google.cloud.bigquery.datatransfer.v1.CreateTransferConfigRequest;%0Aimport com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient;%0Aimport com.google.cloud.bigquery.datatransfer.v1.ProjectName;%0Aimport com.google.cloud.bigquery.datatransfer.v1.TransferConfig;%0Aimport com.google.protobuf.Struct;%0Aimport com.google.protobuf.Value;%0Aimport java.io.IOException;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0A// Sample to create a ad manager(formerly DFP) transfer config%0Apublic class CreateAdManagerTransfer %7B%0A%0A  public static void main(String%5B%5D args) throws IOException %7B%0A    // TODO(developer): Replace these variables before running the sample.%0A    final String projectId = %22MY_PROJECT_ID%22;%0A    String datasetId = %22MY_DATASET_ID%22;%0A    String bucket = %22gs://cloud-sample-data%22;%0A    String networkCode = %22MY_NETWORK_CODE%22;%0A    Map%3CString, Value%3E params = new HashMap%3C%3E();%0A    params.put(%22bucket%22, Value.newBuilder().setStringValue(bucket).build());%0A    params.put(%22network_code%22, Value.newBuilder().setStringValue(networkCode).build());%0A    TransferConfig transferConfig =%0A        TransferConfig.newBuilder()%0A            .setDestinationDatasetId(datasetId)%0A            .setDisplayName(%22Your Ad Manager Config Name%22)%0A            .setDataSourceId(%22dfp_dt%22)%0A            .setParams(Struct.newBuilder().putAllFields(params).build())%0A            .setSchedule(%22every 24 hours%22)%0A            .build();%0A    createAdManagerTransfer(projectId, transferConfig);%0A  %7D%0A%0A  public static void createAdManagerTransfer(String projectId, TransferConfig transferConfig)%0A      throws IOException %7B%0A    try (DataTransferServiceClient client = DataTransferServiceClient.create()) %7B%0A      ProjectName parent = ProjectName.of(projectId);%0A      CreateTransferConfigRequest request =%0A          CreateTransferConfigRequest.newBuilder()%0A              .setParent(parent.toString())%0A              .setTransferConfig(transferConfig)%0A              .build();%0A      TransferConfig config = client.createTransferConfig(request);%0A      System.out.println(%22Ad manager transfer created successfully :%22 + config.getName());%0A    %7D catch (ApiException ex) %7B%0A      System.out.print(%22Ad manager transfer was not created.%22 + ex.toString());%0A    %7D%0A  %7D%0A%7D%0A// %5BEND bigquerydatatransfer_create_admanager_transfer%5D%0A

add create ad manager transfer config (#530)