In case it's useful, I figured out that once i got a process id for a given process I can query /processes/ProcessId to get the actions. I then query the list of imports to find the corresponding import details for any action that is an import, then I query files to get the info about the datasource: var anaplanFiles = await client.GetJsonObjectAsync<FilesResponse>($"https://api.anaplan.com/2/0/workspaces/{WorkspaceId}/models/{ModelId}/files");
Console.Write($"Getting list of processes.{new string(' ', Console.WindowWidth)}".Substring(0, Console.WindowWidth - 1) + "\r");
// Get details of processes
List<Process> anaplanProcesses =
(await client.GetJsonObjectAsync<ProcessesResponse>($"https://api.anaplan.com/2/0/workspaces/{WorkspaceId}/models/{ModelId}/processes")).Processes;
var processIdsByName = anaplanProcesses.ToDictionary(p => p.Name, p => p.Id);
Console.Write($"Getting list of actions.{new string(' ', Console.WindowWidth)}".Substring(0, Console.WindowWidth - 1) + "\r");
var anaplanActions = (await client.GetJsonObjectAsync<ActionsResponse>($"https://api.anaplan.com/2/0/workspaces/{WorkspaceId}/models/{ModelId}/actions")).Actions;
Console.Write($"Getting list of actions for each process.{new string(' ', Console.WindowWidth)}".Substring(0, Console.WindowWidth - 1) + "\r");
var processesActionsToRunTasks = ProcessesToRun
.Select(async p => (await client.GetJsonObjectAsync<ProcessResponse>($"https://api.anaplan.com/2/0/workspaces/{WorkspaceId}/models/{ModelId}/processes/{processIdsByName[p]}")).ProcessMetadata.Actions).ToArray();
Task.WaitAll(processesActionsToRunTasks);
var processesActionsToRun = processesActionsToRunTasks.SelectMany(t => t.Result).Where(a => !string.IsNullOrEmpty(a.ImportDataSourceId));
var usedFiles = processesActionsToRun.Select(a => anaplanFiles.Files.Single(f => f.Id == a.ImportDataSourceId)).ToArray();
... View more