use of com.google.cloud.bigquery.datatransfer.v1.TransferConfig in project java-bigquerydatatransfer by googleapis.
the class CreateCampaignmanagerTransfer method createCampaignmanagerTransfer.
public static void createCampaignmanagerTransfer(String projectId, TransferConfig transferConfig) throws IOException {
try (DataTransferServiceClient client = DataTransferServiceClient.create()) {
ProjectName parent = ProjectName.of(projectId);
CreateTransferConfigRequest request = CreateTransferConfigRequest.newBuilder().setParent(parent.toString()).setTransferConfig(transferConfig).build();
TransferConfig config = client.createTransferConfig(request);
System.out.println("Campaignmanager transfer created successfully :" + config.getName());
} catch (ApiException ex) {
System.out.print("Campaignmanager transfer was not created." + ex.toString());
}
}
use of com.google.cloud.bigquery.datatransfer.v1.TransferConfig in project java-bigquerydatatransfer by googleapis.
the class CreateCampaignmanagerTransfer method main.
public static void main(String[] args) throws IOException {
// TODO(developer): Replace these variables before running the sample.
final String projectId = "MY_PROJECT_ID";
String datasetId = "MY_DATASET_ID";
String bucket = "gs://cloud-sample-data";
// the network_id only allows digits
String networkId = "7878";
String fileNamePrefix = "test_";
Map<String, Value> params = new HashMap<>();
params.put("bucket", Value.newBuilder().setStringValue(bucket).build());
params.put("network_id", Value.newBuilder().setStringValue(networkId).build());
params.put("file_name_prefix", Value.newBuilder().setStringValue(fileNamePrefix).build());
TransferConfig transferConfig = TransferConfig.newBuilder().setDestinationDatasetId(datasetId).setDisplayName("Your Campaignmanager Config Name").setDataSourceId("dcm_dt").setParams(Struct.newBuilder().putAllFields(params).build()).build();
createCampaignmanagerTransfer(projectId, transferConfig);
}
use of com.google.cloud.bigquery.datatransfer.v1.TransferConfig in project java-bigquerydatatransfer by googleapis.
the class CreateRedshiftTransfer method createRedshiftTransfer.
public static void createRedshiftTransfer(String projectId, TransferConfig transferConfig) throws IOException {
try (DataTransferServiceClient client = DataTransferServiceClient.create()) {
ProjectName parent = ProjectName.of(projectId);
CreateTransferConfigRequest request = CreateTransferConfigRequest.newBuilder().setParent(parent.toString()).setTransferConfig(transferConfig).build();
TransferConfig config = client.createTransferConfig(request);
System.out.println("Cloud redshift transfer created successfully :" + config.getName());
} catch (ApiException ex) {
System.out.print("Cloud redshift transfer was not created." + ex.toString());
}
}
Aggregations