Search in sources :

Example 1 with DataTransferServiceClient

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());
        }
    }
}
Also used : DataTransferServiceClient(com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient) ListDataSourcesPagedResponse(com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient.ListDataSourcesPagedResponse) ListDataSourcesRequest(com.google.cloud.bigquery.datatransfer.v1.ListDataSourcesRequest) DataSource(com.google.cloud.bigquery.datatransfer.v1.DataSource)

Aggregations

DataSource (com.google.cloud.bigquery.datatransfer.v1.DataSource)1 DataTransferServiceClient (com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient)1 ListDataSourcesPagedResponse (com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient.ListDataSourcesPagedResponse)1 ListDataSourcesRequest (com.google.cloud.bigquery.datatransfer.v1.ListDataSourcesRequest)1