use of com.google.cloud.bigquery.datatransfer.v1.TransferConfig in project java-bigquerydatatransfer by googleapis.
the class CreatePlayTransfer method createPlayTransfer.
public static void createPlayTransfer(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("play transfer created successfully :" + config.getName());
} catch (ApiException ex) {
System.out.print("play transfer was not created." + ex.toString());
}
}
use of com.google.cloud.bigquery.datatransfer.v1.TransferConfig in project java-bigquerydatatransfer by googleapis.
the class CreateScheduledQuery 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";
final String datasetId = "MY_DATASET_ID";
final String query = "SELECT CURRENT_TIMESTAMP() as current_time, @run_time as intended_run_time, " + "@run_date as intended_run_date, 17 as some_integer";
Map<String, Value> params = new HashMap<>();
params.put("query", Value.newBuilder().setStringValue(query).build());
params.put("destination_table_name_template", Value.newBuilder().setStringValue("my_destination_table_{run_date}").build());
params.put("write_disposition", Value.newBuilder().setStringValue("WRITE_TRUNCATE").build());
params.put("partitioning_field", Value.newBuilder().build());
TransferConfig transferConfig = TransferConfig.newBuilder().setDestinationDatasetId(datasetId).setDisplayName("Your Scheduled Query Name").setDataSourceId("scheduled_query").setParams(Struct.newBuilder().putAllFields(params).build()).setSchedule("every 24 hours").build();
createScheduledQuery(projectId, transferConfig);
}
use of com.google.cloud.bigquery.datatransfer.v1.TransferConfig in project java-bigquerydatatransfer by googleapis.
the class CreateTeradataTransfer method createTeradataTransfer.
public static void createTeradataTransfer(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 teradata transfer created successfully :" + config.getName());
} catch (ApiException ex) {
System.out.print("Cloud teradata transfer was not created." + ex.toString());
}
}
use of com.google.cloud.bigquery.datatransfer.v1.TransferConfig in project java-bigquerydatatransfer by googleapis.
the class CreateYoutubeChannelTransfer method createYoutubeChannelTransfer.
public static void createYoutubeChannelTransfer(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("Youtube channel transfer created successfully :" + config.getName());
} catch (ApiException ex) {
System.out.print("Youtube channel transfer was not created." + ex.toString());
}
}
use of com.google.cloud.bigquery.datatransfer.v1.TransferConfig in project java-bigquerydatatransfer by googleapis.
the class CreateYoutubeContentOwnerTransfer 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 contentOwnerId = "MY_CONTENT_OWNER_ID";
String tableSuffix = "_test";
Map<String, Value> params = new HashMap<>();
params.put("content_owner_id", Value.newBuilder().setStringValue(contentOwnerId).build());
params.put("table_suffix", Value.newBuilder().setStringValue(tableSuffix).build());
TransferConfig transferConfig = TransferConfig.newBuilder().setDestinationDatasetId(datasetId).setDisplayName("Your Youtube Owner Channel Config Name").setDataSourceId("youtube_content_owner").setParams(Struct.newBuilder().putAllFields(params).build()).build();
createYoutubeContentOwnerTransfer(projectId, transferConfig);
}
Aggregations