Googe Cloud Healthcare api: How can I get a list of all the datasets and data stores?

I am using the Google cloud healthcare api to store dicom images. I need a way to fetch a list of all the dataset in a project with names of all the data stores in each dataset.

so possible output would look like this:

{ dataset1: [ "dataStoreA", "dataStoreB", ], 
  dataset2: [ "dataStoreC", "dataStoreD", ],
  dataset3: [ "dataStoreE", "dataStoreF", ], 
 }

I am able to fetch the list of all the datasets using

healthcare.projects.locations.datasets.list({
  parent: `projects/${project}/locations/${location}`
 })

but that only returns an object for each dataset containing only the name of the dataset. I want to get name of all the data stores in that datasets as well.

My current way is to fetch a list of all the datasets and then for each dataset, fetch all the data stores in it. Using

healthcare.projects.locations.datasets.dicomStores
  .list({
    parent: `projects/${project}/locations/${location}/datasets/${dataset}`,
  })

but this very time consuming because if there are 5 datasets, then I have to make 5 different requests to the api. I have looked the Google docs for the api and searched around without any luck.

Unfortunately, there is no way to do this except the way you are currently doing this, fetching the list of all datasets and then getting the details for each dataset.

https://cloud.google.com/healthcare-api/docs/how-tos/datasets#getting_dataset_details