/// <summary>
        ///     Gets a list of processes being monitored for a device
        /// </summary>
        /// <param name="deviceId">The device id</param>
        /// <param name="deviceProcessServiceTaskType">The process/service type</param>
        /// <param name="cancellationToken">The cancellation token</param>
        /// <returns></returns>
        public async Task <List <DeviceDataSourceInstance> > GetMonitoredDeviceProcesses(
            int deviceId,
            DeviceProcessServiceTaskType deviceProcessServiceTaskType,
            CancellationToken cancellationToken = default)
        {
            var dataSourceName = deviceProcessServiceTaskType switch
            {
                DeviceProcessServiceTaskType.LinuxProcess => "LinuxNewProcesses-",
                DeviceProcessServiceTaskType.WindowsProcess => "WinProcessStats-",
                DeviceProcessServiceTaskType.WindowsService => "WinService-",
                _ => throw new ArgumentException($"Only {DeviceProcessServiceTaskType.LinuxProcess}, {DeviceProcessServiceTaskType.WindowsProcess} and {DeviceProcessServiceTaskType.WindowsService} are supported", nameof(deviceProcessServiceTaskType)),
            };
            var filter = new Filter <DeviceDataSource>
            {
                FilterItems = new List <FilterItem <DeviceDataSource> >
                {
                    new Eq <DeviceDataSource>(nameof(DeviceDataSource.DataSourceName), dataSourceName),
                    new Eq <DeviceDataSource>(nameof(DeviceDataSource.DataSourceType), "DS")
                }
            };
            var deviceDataSources = await GetAllAsync(filter, $"device/devices/{deviceId}/devicedatasources", cancellationToken).ConfigureAwait(false);

            if (deviceDataSources.Count != 1)
            {
                return(new List <DeviceDataSourceInstance>());
            }

            return(await GetAllDeviceDataSourceInstancesAsync(deviceId, deviceDataSources.Single().Id, cancellationToken : cancellationToken).ConfigureAwait(false));
        }
        /// <summary>
        ///     Gets currently-running device processes
        /// </summary>
        /// <param name="deviceId">The device id</param>
        /// <param name="deviceProcessServiceTaskType">The process/service type</param>
        /// <param name="cancellationToken">The cancellation token</param>
        /// <returns></returns>
        public async Task <Page <DeviceProcess> > GetDeviceProcesses(
            int deviceId,
            DeviceProcessServiceTaskType deviceProcessServiceTaskType,
            CancellationToken cancellationToken = default)
        {
            var task = await GetProcessServiceTaskForDevice(deviceId, deviceProcessServiceTaskType, cancellationToken).ConfigureAwait(false);

            return(await GetProcessServiceTaskResults(deviceId, task.TaskId, cancellationToken).ConfigureAwait(false));
        }
 /// <summary>
 ///     Initiates a task to fetch the list of current running processes on a device
 /// </summary>
 /// <param name="deviceId">The device id</param>
 /// <param name="deviceProcessServiceTaskType">The device process/service task type</param>
 /// <param name="cancellationToken">The cancellation token</param>
 /// <returns></returns>
 public Task <DeviceProcessServiceTask> GetProcessServiceTaskForDevice(
     int deviceId,
     DeviceProcessServiceTaskType deviceProcessServiceTaskType,
     CancellationToken cancellationToken = default)
 => PostAsync <DeviceProcessServiceTask, DeviceProcessServiceTask>(
     new DeviceProcessServiceTask
 {
     Type = deviceProcessServiceTaskType
 },
     $"device/devices/{deviceId}/fetchProcessServiceTask",
     cancellationToken
     );