{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE StrictData #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} {-# OPTIONS_GHC -fno-warn-unused-matches #-} -- Derived from AWS service descriptions, licensed under Apache 2.0. -- | -- Module : Amazonka.DeviceFarm.Types.Rule -- Copyright : (c) 2013-2021 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay <brendan.g.hay+amazonka@gmail.com> -- Stability : auto-generated -- Portability : non-portable (GHC extensions) module Amazonka.DeviceFarm.Types.Rule where import qualified Amazonka.Core as Core import Amazonka.DeviceFarm.Types.DeviceAttribute import Amazonka.DeviceFarm.Types.RuleOperator import qualified Amazonka.Lens as Lens import qualified Amazonka.Prelude as Prelude -- | Represents a condition for a device pool. -- -- /See:/ 'newRule' smart constructor. data Rule = Rule' { -- | The rule\'s stringified attribute. For example, specify the value as -- @\"\\\"abc\\\"\"@. -- -- The supported operators for each attribute are provided in the following -- list. -- -- [APPIUM_VERSION] -- The Appium version for the test. -- -- Supported operators: @CONTAINS@ -- -- [ARN] -- The Amazon Resource Name (ARN) of the device (for example, -- @arn:aws:devicefarm:us-west-2::device:12345Example@. -- -- Supported operators: @EQUALS@, @IN@, @NOT_IN@ -- -- [AVAILABILITY] -- The current availability of the device. Valid values are AVAILABLE, -- HIGHLY_AVAILABLE, BUSY, or TEMPORARY_NOT_AVAILABLE. -- -- Supported operators: @EQUALS@ -- -- [FLEET_TYPE] -- The fleet type. Valid values are PUBLIC or PRIVATE. -- -- Supported operators: @EQUALS@ -- -- [FORM_FACTOR] -- The device form factor. Valid values are PHONE or TABLET. -- -- Supported operators: @EQUALS@, @IN@, @NOT_IN@ -- -- [INSTANCE_ARN] -- The Amazon Resource Name (ARN) of the device instance. -- -- Supported operators: @IN@, @NOT_IN@ -- -- [INSTANCE_LABELS] -- The label of the device instance. -- -- Supported operators: @CONTAINS@ -- -- [MANUFACTURER] -- The device manufacturer (for example, Apple). -- -- Supported operators: @EQUALS@, @IN@, @NOT_IN@ -- -- [MODEL] -- The device model, such as Apple iPad Air 2 or Google Pixel. -- -- Supported operators: @CONTAINS@, @EQUALS@, @IN@, @NOT_IN@ -- -- [OS_VERSION] -- The operating system version (for example, 10.3.2). -- -- Supported operators: @EQUALS@, @GREATER_THAN@, -- @GREATER_THAN_OR_EQUALS@, @IN@, @LESS_THAN@, @LESS_THAN_OR_EQUALS@, -- @NOT_IN@ -- -- [PLATFORM] -- The device platform. Valid values are ANDROID or IOS. -- -- Supported operators: @EQUALS@, @IN@, @NOT_IN@ -- -- [REMOTE_ACCESS_ENABLED] -- Whether the device is enabled for remote access. Valid values are -- TRUE or FALSE. -- -- Supported operators: @EQUALS@ -- -- [REMOTE_DEBUG_ENABLED] -- Whether the device is enabled for remote debugging. Valid values are -- TRUE or FALSE. -- -- Supported operators: @EQUALS@ -- -- Because remote debugging is -- <https://docs.aws.amazon.com/devicefarm/latest/developerguide/history.html no longer supported>, -- this filter is ignored. Rule -> Maybe DeviceAttribute attribute :: Prelude.Maybe DeviceAttribute, -- | Specifies how Device Farm compares the rule\'s attribute to the value. -- For the operators that are supported by each attribute, see the -- attribute descriptions. Rule -> Maybe RuleOperator operator :: Prelude.Maybe RuleOperator, -- | The rule\'s value. Rule -> Maybe Text value :: Prelude.Maybe Prelude.Text } deriving (Rule -> Rule -> Bool (Rule -> Rule -> Bool) -> (Rule -> Rule -> Bool) -> Eq Rule forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Rule -> Rule -> Bool $c/= :: Rule -> Rule -> Bool == :: Rule -> Rule -> Bool $c== :: Rule -> Rule -> Bool Prelude.Eq, ReadPrec [Rule] ReadPrec Rule Int -> ReadS Rule ReadS [Rule] (Int -> ReadS Rule) -> ReadS [Rule] -> ReadPrec Rule -> ReadPrec [Rule] -> Read Rule forall a. (Int -> ReadS a) -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a readListPrec :: ReadPrec [Rule] $creadListPrec :: ReadPrec [Rule] readPrec :: ReadPrec Rule $creadPrec :: ReadPrec Rule readList :: ReadS [Rule] $creadList :: ReadS [Rule] readsPrec :: Int -> ReadS Rule $creadsPrec :: Int -> ReadS Rule Prelude.Read, Int -> Rule -> ShowS [Rule] -> ShowS Rule -> String (Int -> Rule -> ShowS) -> (Rule -> String) -> ([Rule] -> ShowS) -> Show Rule forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Rule] -> ShowS $cshowList :: [Rule] -> ShowS show :: Rule -> String $cshow :: Rule -> String showsPrec :: Int -> Rule -> ShowS $cshowsPrec :: Int -> Rule -> ShowS Prelude.Show, (forall x. Rule -> Rep Rule x) -> (forall x. Rep Rule x -> Rule) -> Generic Rule forall x. Rep Rule x -> Rule forall x. Rule -> Rep Rule x forall a. (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a $cto :: forall x. Rep Rule x -> Rule $cfrom :: forall x. Rule -> Rep Rule x Prelude.Generic) -- | -- Create a value of 'Rule' with all optional fields omitted. -- -- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'attribute', 'rule_attribute' - The rule\'s stringified attribute. For example, specify the value as -- @\"\\\"abc\\\"\"@. -- -- The supported operators for each attribute are provided in the following -- list. -- -- [APPIUM_VERSION] -- The Appium version for the test. -- -- Supported operators: @CONTAINS@ -- -- [ARN] -- The Amazon Resource Name (ARN) of the device (for example, -- @arn:aws:devicefarm:us-west-2::device:12345Example@. -- -- Supported operators: @EQUALS@, @IN@, @NOT_IN@ -- -- [AVAILABILITY] -- The current availability of the device. Valid values are AVAILABLE, -- HIGHLY_AVAILABLE, BUSY, or TEMPORARY_NOT_AVAILABLE. -- -- Supported operators: @EQUALS@ -- -- [FLEET_TYPE] -- The fleet type. Valid values are PUBLIC or PRIVATE. -- -- Supported operators: @EQUALS@ -- -- [FORM_FACTOR] -- The device form factor. Valid values are PHONE or TABLET. -- -- Supported operators: @EQUALS@, @IN@, @NOT_IN@ -- -- [INSTANCE_ARN] -- The Amazon Resource Name (ARN) of the device instance. -- -- Supported operators: @IN@, @NOT_IN@ -- -- [INSTANCE_LABELS] -- The label of the device instance. -- -- Supported operators: @CONTAINS@ -- -- [MANUFACTURER] -- The device manufacturer (for example, Apple). -- -- Supported operators: @EQUALS@, @IN@, @NOT_IN@ -- -- [MODEL] -- The device model, such as Apple iPad Air 2 or Google Pixel. -- -- Supported operators: @CONTAINS@, @EQUALS@, @IN@, @NOT_IN@ -- -- [OS_VERSION] -- The operating system version (for example, 10.3.2). -- -- Supported operators: @EQUALS@, @GREATER_THAN@, -- @GREATER_THAN_OR_EQUALS@, @IN@, @LESS_THAN@, @LESS_THAN_OR_EQUALS@, -- @NOT_IN@ -- -- [PLATFORM] -- The device platform. Valid values are ANDROID or IOS. -- -- Supported operators: @EQUALS@, @IN@, @NOT_IN@ -- -- [REMOTE_ACCESS_ENABLED] -- Whether the device is enabled for remote access. Valid values are -- TRUE or FALSE. -- -- Supported operators: @EQUALS@ -- -- [REMOTE_DEBUG_ENABLED] -- Whether the device is enabled for remote debugging. Valid values are -- TRUE or FALSE. -- -- Supported operators: @EQUALS@ -- -- Because remote debugging is -- <https://docs.aws.amazon.com/devicefarm/latest/developerguide/history.html no longer supported>, -- this filter is ignored. -- -- 'operator', 'rule_operator' - Specifies how Device Farm compares the rule\'s attribute to the value. -- For the operators that are supported by each attribute, see the -- attribute descriptions. -- -- 'value', 'rule_value' - The rule\'s value. newRule :: Rule newRule :: Rule newRule = Rule' :: Maybe DeviceAttribute -> Maybe RuleOperator -> Maybe Text -> Rule Rule' { $sel:attribute:Rule' :: Maybe DeviceAttribute attribute = Maybe DeviceAttribute forall a. Maybe a Prelude.Nothing, $sel:operator:Rule' :: Maybe RuleOperator operator = Maybe RuleOperator forall a. Maybe a Prelude.Nothing, $sel:value:Rule' :: Maybe Text value = Maybe Text forall a. Maybe a Prelude.Nothing } -- | The rule\'s stringified attribute. For example, specify the value as -- @\"\\\"abc\\\"\"@. -- -- The supported operators for each attribute are provided in the following -- list. -- -- [APPIUM_VERSION] -- The Appium version for the test. -- -- Supported operators: @CONTAINS@ -- -- [ARN] -- The Amazon Resource Name (ARN) of the device (for example, -- @arn:aws:devicefarm:us-west-2::device:12345Example@. -- -- Supported operators: @EQUALS@, @IN@, @NOT_IN@ -- -- [AVAILABILITY] -- The current availability of the device. Valid values are AVAILABLE, -- HIGHLY_AVAILABLE, BUSY, or TEMPORARY_NOT_AVAILABLE. -- -- Supported operators: @EQUALS@ -- -- [FLEET_TYPE] -- The fleet type. Valid values are PUBLIC or PRIVATE. -- -- Supported operators: @EQUALS@ -- -- [FORM_FACTOR] -- The device form factor. Valid values are PHONE or TABLET. -- -- Supported operators: @EQUALS@, @IN@, @NOT_IN@ -- -- [INSTANCE_ARN] -- The Amazon Resource Name (ARN) of the device instance. -- -- Supported operators: @IN@, @NOT_IN@ -- -- [INSTANCE_LABELS] -- The label of the device instance. -- -- Supported operators: @CONTAINS@ -- -- [MANUFACTURER] -- The device manufacturer (for example, Apple). -- -- Supported operators: @EQUALS@, @IN@, @NOT_IN@ -- -- [MODEL] -- The device model, such as Apple iPad Air 2 or Google Pixel. -- -- Supported operators: @CONTAINS@, @EQUALS@, @IN@, @NOT_IN@ -- -- [OS_VERSION] -- The operating system version (for example, 10.3.2). -- -- Supported operators: @EQUALS@, @GREATER_THAN@, -- @GREATER_THAN_OR_EQUALS@, @IN@, @LESS_THAN@, @LESS_THAN_OR_EQUALS@, -- @NOT_IN@ -- -- [PLATFORM] -- The device platform. Valid values are ANDROID or IOS. -- -- Supported operators: @EQUALS@, @IN@, @NOT_IN@ -- -- [REMOTE_ACCESS_ENABLED] -- Whether the device is enabled for remote access. Valid values are -- TRUE or FALSE. -- -- Supported operators: @EQUALS@ -- -- [REMOTE_DEBUG_ENABLED] -- Whether the device is enabled for remote debugging. Valid values are -- TRUE or FALSE. -- -- Supported operators: @EQUALS@ -- -- Because remote debugging is -- <https://docs.aws.amazon.com/devicefarm/latest/developerguide/history.html no longer supported>, -- this filter is ignored. rule_attribute :: Lens.Lens' Rule (Prelude.Maybe DeviceAttribute) rule_attribute :: (Maybe DeviceAttribute -> f (Maybe DeviceAttribute)) -> Rule -> f Rule rule_attribute = (Rule -> Maybe DeviceAttribute) -> (Rule -> Maybe DeviceAttribute -> Rule) -> Lens Rule Rule (Maybe DeviceAttribute) (Maybe DeviceAttribute) forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\Rule' {Maybe DeviceAttribute attribute :: Maybe DeviceAttribute $sel:attribute:Rule' :: Rule -> Maybe DeviceAttribute attribute} -> Maybe DeviceAttribute attribute) (\s :: Rule s@Rule' {} Maybe DeviceAttribute a -> Rule s {$sel:attribute:Rule' :: Maybe DeviceAttribute attribute = Maybe DeviceAttribute a} :: Rule) -- | Specifies how Device Farm compares the rule\'s attribute to the value. -- For the operators that are supported by each attribute, see the -- attribute descriptions. rule_operator :: Lens.Lens' Rule (Prelude.Maybe RuleOperator) rule_operator :: (Maybe RuleOperator -> f (Maybe RuleOperator)) -> Rule -> f Rule rule_operator = (Rule -> Maybe RuleOperator) -> (Rule -> Maybe RuleOperator -> Rule) -> Lens Rule Rule (Maybe RuleOperator) (Maybe RuleOperator) forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\Rule' {Maybe RuleOperator operator :: Maybe RuleOperator $sel:operator:Rule' :: Rule -> Maybe RuleOperator operator} -> Maybe RuleOperator operator) (\s :: Rule s@Rule' {} Maybe RuleOperator a -> Rule s {$sel:operator:Rule' :: Maybe RuleOperator operator = Maybe RuleOperator a} :: Rule) -- | The rule\'s value. rule_value :: Lens.Lens' Rule (Prelude.Maybe Prelude.Text) rule_value :: (Maybe Text -> f (Maybe Text)) -> Rule -> f Rule rule_value = (Rule -> Maybe Text) -> (Rule -> Maybe Text -> Rule) -> Lens Rule Rule (Maybe Text) (Maybe Text) forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\Rule' {Maybe Text value :: Maybe Text $sel:value:Rule' :: Rule -> Maybe Text value} -> Maybe Text value) (\s :: Rule s@Rule' {} Maybe Text a -> Rule s {$sel:value:Rule' :: Maybe Text value = Maybe Text a} :: Rule) instance Core.FromJSON Rule where parseJSON :: Value -> Parser Rule parseJSON = String -> (Object -> Parser Rule) -> Value -> Parser Rule forall a. String -> (Object -> Parser a) -> Value -> Parser a Core.withObject String "Rule" ( \Object x -> Maybe DeviceAttribute -> Maybe RuleOperator -> Maybe Text -> Rule Rule' (Maybe DeviceAttribute -> Maybe RuleOperator -> Maybe Text -> Rule) -> Parser (Maybe DeviceAttribute) -> Parser (Maybe RuleOperator -> Maybe Text -> Rule) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b Prelude.<$> (Object x Object -> Text -> Parser (Maybe DeviceAttribute) forall a. FromJSON a => Object -> Text -> Parser (Maybe a) Core..:? Text "attribute") Parser (Maybe RuleOperator -> Maybe Text -> Rule) -> Parser (Maybe RuleOperator) -> Parser (Maybe Text -> Rule) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b Prelude.<*> (Object x Object -> Text -> Parser (Maybe RuleOperator) forall a. FromJSON a => Object -> Text -> Parser (Maybe a) Core..:? Text "operator") Parser (Maybe Text -> Rule) -> Parser (Maybe Text) -> Parser Rule forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b Prelude.<*> (Object x Object -> Text -> Parser (Maybe Text) forall a. FromJSON a => Object -> Text -> Parser (Maybe a) Core..:? Text "value") ) instance Prelude.Hashable Rule instance Prelude.NFData Rule instance Core.ToJSON Rule where toJSON :: Rule -> Value toJSON Rule' {Maybe Text Maybe DeviceAttribute Maybe RuleOperator value :: Maybe Text operator :: Maybe RuleOperator attribute :: Maybe DeviceAttribute $sel:value:Rule' :: Rule -> Maybe Text $sel:operator:Rule' :: Rule -> Maybe RuleOperator $sel:attribute:Rule' :: Rule -> Maybe DeviceAttribute ..} = [Pair] -> Value Core.object ( [Maybe Pair] -> [Pair] forall a. [Maybe a] -> [a] Prelude.catMaybes [ (Text "attribute" Text -> DeviceAttribute -> Pair forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv Core..=) (DeviceAttribute -> Pair) -> Maybe DeviceAttribute -> Maybe Pair forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b Prelude.<$> Maybe DeviceAttribute attribute, (Text "operator" Text -> RuleOperator -> Pair forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv Core..=) (RuleOperator -> Pair) -> Maybe RuleOperator -> Maybe Pair forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b Prelude.<$> Maybe RuleOperator operator, (Text "value" Text -> Text -> Pair forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b Prelude.<$> Maybe Text value ] )