Example #1
0
        public async Task <IActionResult> GetDeviceWithLKS([FromQuery] string deviceName)
        {
            Logger.LogInformation($"{nameof(GetDeviceWithLKS)} deviceName {deviceName}");
            DeviceDataValidator.ValidateDeviceName(deviceName);

            var device = await CwsDeviceGatewayClient.GetDeviceLKS(deviceName, customHeaders);

            Logger.LogInformation($"{nameof(GetDeviceWithLKS)} completed. device {(device == null ? null : JsonConvert.SerializeObject(device))}");
            if (device == null)
            {
                return(NotFound());
            }

            return(Ok(device));
        }
Example #2
0
        public async Task <IActionResult> GetDevicesLKSForProject(
            [FromQuery] Guid projectUid,
            [FromQuery] DateTime?earliestOfInterestUtc)
        {
            Logger.LogInformation($"{nameof(GetDevicesLKSForProject)} projectUid {projectUid} earliestOfInterestUtc {earliestOfInterestUtc}");
            DeviceDataValidator.ValidateProjectUid(projectUid);
            DeviceDataValidator.ValidateEarliestOfInterestUtc(earliestOfInterestUtc);

            earliestOfInterestUtc ??= DateTime.UtcNow.AddDays(-30);
            var devices =
                (await CwsDeviceGatewayClient.GetDevicesLKSForProject(projectUid, earliestOfInterestUtc, customHeaders))
                .Where(d => string.Compare(d.AccountUid, CustomerUid, StringComparison.OrdinalIgnoreCase) == 0);

            Logger.LogInformation($"{nameof(GetDevicesLKSForProject)} completed. deviceCount to return {devices.Count()}");

            return(Ok(devices));
        }