Represents a condition for a device pool.
Esempio n. 1
0
        private DevicePool CreateDefaultDevicePool(string projectArn)
        {
            Log.LogMessage("Creating device pool {0}.", DefaultDevicePoolName);
            string nextToken = null;
            List<Device> devices = new List<Device>();
            do
            {
                var resp = DFClient.ListDevices(new ListDevicesRequest() { NextToken = nextToken });
                nextToken = resp.NextToken;
                devices.AddRange(resp.Devices);
            } while (nextToken != null);

            List<string> deviceArns = new List<string>();

            foreach (var device in devices)
            {
                if (DefaultDevices.ContainsKey(device.Name) && DefaultDevices[device.Name] == device.Os)
                {
                    deviceArns.Add('"' + device.Arn + '"');
                }
            }
            Rule rule = new Rule()
            {
                Attribute = DeviceAttribute.ARN,
                Operator = RuleOperator.IN,
                Value = "[" + string.Join(",", deviceArns) + "]"
            };
            DevicePool devicePool = DFClient.CreateDevicePool(new CreateDevicePoolRequest()
            {
                ProjectArn = projectArn,
                Name = DefaultDevicePoolName,
                Rules = new List<Rule>() { rule }
            }).DevicePool;
            return devicePool;
        }