public static int Main(string[] args) { // Read projectId from args if (args.Length != 1) { Console.WriteLine("Usage: Project ID must be passed as first argument."); Console.WriteLine(); return(1); } string projectId = args[0]; // Create client DataTransferServiceClient client = DataTransferServiceClient.Create(); // Initialize request argument(s) ParentNameOneof parent = ParentNameOneof.From(new LocationName(projectId, "us-central1")); // Call API method PagedEnumerable <ListDataSourcesResponse, DataSource> pagedResponse = client.ListDataSources(parent); // Show the result foreach (var item in pagedResponse) { Console.WriteLine(item); } // Success Console.WriteLine("Smoke test passed OK"); return(0); }
/// <summary>Snippet for ListDataSources</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void ListDataSourcesRequestObject() { // Create client DataTransferServiceClient dataTransferServiceClient = DataTransferServiceClient.Create(); // Initialize request argument(s) ListDataSourcesRequest request = new ListDataSourcesRequest { ParentAsProjectName = ProjectName.FromProject("[PROJECT]"), }; // Make the request PagedEnumerable <ListDataSourcesResponse, DataSource> response = dataTransferServiceClient.ListDataSources(request); // Iterate over all response items, lazily performing RPCs as required foreach (DataSource item in response) { // Do something with each item Console.WriteLine(item); } // Or iterate over pages (of server-defined size), performing one RPC per page foreach (ListDataSourcesResponse page in response.AsRawResponses()) { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (DataSource item in page) { // Do something with each item Console.WriteLine(item); } } // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required int pageSize = 10; Page <DataSource> singlePage = response.ReadPage(pageSize); // Do something with the page of items Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); foreach (DataSource item in singlePage) { // Do something with each item Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; }
public static void Main(string[] args) { // Instantiates a client DataTransferServiceClient client = DataTransferServiceClient.Create(); // Your Google Cloud Platform project ID string projectId = "YOUR-PROJECT-ID"; ProjectName project = new ProjectName(projectId); var sources = client.ListDataSources(ParentNameOneof.From(project)); Console.WriteLine("Supported Data Sources:"); foreach (DataSource source in sources) { Console.WriteLine( $"{source.DataSourceId}: " + $"{source.DisplayName} ({source.Description})"); } }