use of com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient in project java-docs-samples by GoogleCloudPlatform.
the class QuickstartSample method main.
/**
* List available data sources for the BigQuery Data Transfer service.
*/
public static void main(String... args) throws Exception {
// Sets your Google Cloud Platform project ID.
// String projectId = "YOUR_PROJECT_ID";
String projectId = args[0];
// GOOGLE_APPLICATION_CREDENTIALS environment variable.
try (DataTransferServiceClient client = DataTransferServiceClient.create()) {
// Request the list of available data sources.
String parent = String.format("projects/%s", projectId);
ListDataSourcesRequest request = ListDataSourcesRequest.newBuilder().setParent(parent).build();
ListDataSourcesPagedResponse response = client.listDataSources(request);
// Print the results.
System.out.println("Supported Data Sources:");
for (DataSource dataSource : response.iterateAll()) {
System.out.println(dataSource.getDisplayName());
System.out.printf("\tID: %s%n", dataSource.getDataSourceId());
System.out.printf("\tFull path: %s%n", dataSource.getName());
System.out.printf("\tDescription: %s%n", dataSource.getDescription());
}
}
}
Aggregations