{-# 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-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) module Amazonka.DeviceFarm.Types.Rule where import qualified Amazonka.Core as Core import qualified Amazonka.Core.Lens.Internal as Lens import qualified Amazonka.Data as Data import Amazonka.DeviceFarm.Types.DeviceAttribute import Amazonka.DeviceFarm.Types.RuleOperator 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 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] 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 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. 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' { $sel:attribute:Rule' :: Maybe DeviceAttribute attribute = forall a. Maybe a Prelude.Nothing, $sel:operator:Rule' :: Maybe RuleOperator operator = forall a. Maybe a Prelude.Nothing, $sel:value:Rule' :: Maybe Text value = 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 :: Lens' Rule (Maybe DeviceAttribute) rule_attribute = 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 :: Lens' Rule (Maybe RuleOperator) rule_operator = 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 :: Lens' Rule (Maybe Text) rule_value = 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 Data.FromJSON Rule where parseJSON :: Value -> Parser Rule parseJSON = forall a. String -> (Object -> Parser a) -> Value -> Parser a Data.withObject String "Rule" ( \Object x -> Maybe DeviceAttribute -> Maybe RuleOperator -> Maybe Text -> Rule Rule' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b Prelude.<$> (Object x forall a. FromJSON a => Object -> Key -> Parser (Maybe a) Data..:? Key "attribute") forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b Prelude.<*> (Object x forall a. FromJSON a => Object -> Key -> Parser (Maybe a) Data..:? Key "operator") forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b Prelude.<*> (Object x forall a. FromJSON a => Object -> Key -> Parser (Maybe a) Data..:? Key "value") ) instance Prelude.Hashable Rule where hashWithSalt :: Int -> Rule -> Int hashWithSalt Int _salt 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 ..} = Int _salt forall a. Hashable a => Int -> a -> Int `Prelude.hashWithSalt` Maybe DeviceAttribute attribute forall a. Hashable a => Int -> a -> Int `Prelude.hashWithSalt` Maybe RuleOperator operator forall a. Hashable a => Int -> a -> Int `Prelude.hashWithSalt` Maybe Text value instance Prelude.NFData Rule where rnf :: Rule -> () rnf 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 ..} = forall a. NFData a => a -> () Prelude.rnf Maybe DeviceAttribute attribute seq :: forall a b. a -> b -> b `Prelude.seq` forall a. NFData a => a -> () Prelude.rnf Maybe RuleOperator operator seq :: forall a b. a -> b -> b `Prelude.seq` forall a. NFData a => a -> () Prelude.rnf Maybe Text value instance Data.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 Data.object ( forall a. [Maybe a] -> [a] Prelude.catMaybes [ (Key "attribute" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b Prelude.<$> Maybe DeviceAttribute attribute, (Key "operator" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b Prelude.<$> Maybe RuleOperator operator, (Key "value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b Prelude.<$> Maybe Text value ] )