{-# 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.DataPipeline.Types.Operator
-- 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.DataPipeline.Types.Operator where

import qualified Amazonka.Core as Core
import Amazonka.DataPipeline.Types.OperatorType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains a logical operation for comparing the value of a field with a
-- specified value.
--
-- /See:/ 'newOperator' smart constructor.
data Operator = Operator'
  { -- | The value that the actual field value will be compared with.
    Operator -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text],
    -- | The logical operation to be performed: equal (@EQ@), equal reference
    -- (@REF_EQ@), less than or equal (@LE@), greater than or equal (@GE@), or
    -- between (@BETWEEN@). Equal reference (@REF_EQ@) can be used only with
    -- reference fields. The other comparison types can be used only with
    -- String fields. The comparison types you can use apply only to certain
    -- object fields, as detailed below.
    --
    -- The comparison operators EQ and REF_EQ act on the following fields:
    --
    -- -   name
    -- -   \@sphere
    -- -   parent
    -- -   \@componentParent
    -- -   \@instanceParent
    -- -   \@status
    -- -   \@scheduledStartTime
    -- -   \@scheduledEndTime
    -- -   \@actualStartTime
    -- -   \@actualEndTime
    --
    -- The comparison operators @GE@, @LE@, and @BETWEEN@ act on the following
    -- fields:
    --
    -- -   \@scheduledStartTime
    -- -   \@scheduledEndTime
    -- -   \@actualStartTime
    -- -   \@actualEndTime
    --
    -- Note that fields beginning with the at sign (\@) are read-only and set
    -- by the web service. When you name fields, you should choose names
    -- containing only alpha-numeric values, as symbols may be reserved by AWS
    -- Data Pipeline. User-defined fields that you add to a pipeline should
    -- prefix their name with the string \"my\".
    Operator -> Maybe OperatorType
type' :: Prelude.Maybe OperatorType
  }
  deriving (Operator -> Operator -> Bool
(Operator -> Operator -> Bool)
-> (Operator -> Operator -> Bool) -> Eq Operator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Operator -> Operator -> Bool
$c/= :: Operator -> Operator -> Bool
== :: Operator -> Operator -> Bool
$c== :: Operator -> Operator -> Bool
Prelude.Eq, ReadPrec [Operator]
ReadPrec Operator
Int -> ReadS Operator
ReadS [Operator]
(Int -> ReadS Operator)
-> ReadS [Operator]
-> ReadPrec Operator
-> ReadPrec [Operator]
-> Read Operator
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Operator]
$creadListPrec :: ReadPrec [Operator]
readPrec :: ReadPrec Operator
$creadPrec :: ReadPrec Operator
readList :: ReadS [Operator]
$creadList :: ReadS [Operator]
readsPrec :: Int -> ReadS Operator
$creadsPrec :: Int -> ReadS Operator
Prelude.Read, Int -> Operator -> ShowS
[Operator] -> ShowS
Operator -> String
(Int -> Operator -> ShowS)
-> (Operator -> String) -> ([Operator] -> ShowS) -> Show Operator
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Operator] -> ShowS
$cshowList :: [Operator] -> ShowS
show :: Operator -> String
$cshow :: Operator -> String
showsPrec :: Int -> Operator -> ShowS
$cshowsPrec :: Int -> Operator -> ShowS
Prelude.Show, (forall x. Operator -> Rep Operator x)
-> (forall x. Rep Operator x -> Operator) -> Generic Operator
forall x. Rep Operator x -> Operator
forall x. Operator -> Rep Operator x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Operator x -> Operator
$cfrom :: forall x. Operator -> Rep Operator x
Prelude.Generic)

-- |
-- Create a value of 'Operator' 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:
--
-- 'values', 'operator_values' - The value that the actual field value will be compared with.
--
-- 'type'', 'operator_type' - The logical operation to be performed: equal (@EQ@), equal reference
-- (@REF_EQ@), less than or equal (@LE@), greater than or equal (@GE@), or
-- between (@BETWEEN@). Equal reference (@REF_EQ@) can be used only with
-- reference fields. The other comparison types can be used only with
-- String fields. The comparison types you can use apply only to certain
-- object fields, as detailed below.
--
-- The comparison operators EQ and REF_EQ act on the following fields:
--
-- -   name
-- -   \@sphere
-- -   parent
-- -   \@componentParent
-- -   \@instanceParent
-- -   \@status
-- -   \@scheduledStartTime
-- -   \@scheduledEndTime
-- -   \@actualStartTime
-- -   \@actualEndTime
--
-- The comparison operators @GE@, @LE@, and @BETWEEN@ act on the following
-- fields:
--
-- -   \@scheduledStartTime
-- -   \@scheduledEndTime
-- -   \@actualStartTime
-- -   \@actualEndTime
--
-- Note that fields beginning with the at sign (\@) are read-only and set
-- by the web service. When you name fields, you should choose names
-- containing only alpha-numeric values, as symbols may be reserved by AWS
-- Data Pipeline. User-defined fields that you add to a pipeline should
-- prefix their name with the string \"my\".
newOperator ::
  Operator
newOperator :: Operator
newOperator =
  Operator' :: Maybe [Text] -> Maybe OperatorType -> Operator
Operator'
    { $sel:values:Operator' :: Maybe [Text]
values = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Operator' :: Maybe OperatorType
type' = Maybe OperatorType
forall a. Maybe a
Prelude.Nothing
    }

-- | The value that the actual field value will be compared with.
operator_values :: Lens.Lens' Operator (Prelude.Maybe [Prelude.Text])
operator_values :: (Maybe [Text] -> f (Maybe [Text])) -> Operator -> f Operator
operator_values = (Operator -> Maybe [Text])
-> (Operator -> Maybe [Text] -> Operator)
-> Lens Operator Operator (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Operator' {Maybe [Text]
values :: Maybe [Text]
$sel:values:Operator' :: Operator -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: Operator
s@Operator' {} Maybe [Text]
a -> Operator
s {$sel:values:Operator' :: Maybe [Text]
values = Maybe [Text]
a} :: Operator) ((Maybe [Text] -> f (Maybe [Text])) -> Operator -> f Operator)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Operator
-> f Operator
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The logical operation to be performed: equal (@EQ@), equal reference
-- (@REF_EQ@), less than or equal (@LE@), greater than or equal (@GE@), or
-- between (@BETWEEN@). Equal reference (@REF_EQ@) can be used only with
-- reference fields. The other comparison types can be used only with
-- String fields. The comparison types you can use apply only to certain
-- object fields, as detailed below.
--
-- The comparison operators EQ and REF_EQ act on the following fields:
--
-- -   name
-- -   \@sphere
-- -   parent
-- -   \@componentParent
-- -   \@instanceParent
-- -   \@status
-- -   \@scheduledStartTime
-- -   \@scheduledEndTime
-- -   \@actualStartTime
-- -   \@actualEndTime
--
-- The comparison operators @GE@, @LE@, and @BETWEEN@ act on the following
-- fields:
--
-- -   \@scheduledStartTime
-- -   \@scheduledEndTime
-- -   \@actualStartTime
-- -   \@actualEndTime
--
-- Note that fields beginning with the at sign (\@) are read-only and set
-- by the web service. When you name fields, you should choose names
-- containing only alpha-numeric values, as symbols may be reserved by AWS
-- Data Pipeline. User-defined fields that you add to a pipeline should
-- prefix their name with the string \"my\".
operator_type :: Lens.Lens' Operator (Prelude.Maybe OperatorType)
operator_type :: (Maybe OperatorType -> f (Maybe OperatorType))
-> Operator -> f Operator
operator_type = (Operator -> Maybe OperatorType)
-> (Operator -> Maybe OperatorType -> Operator)
-> Lens Operator Operator (Maybe OperatorType) (Maybe OperatorType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Operator' {Maybe OperatorType
type' :: Maybe OperatorType
$sel:type':Operator' :: Operator -> Maybe OperatorType
type'} -> Maybe OperatorType
type') (\s :: Operator
s@Operator' {} Maybe OperatorType
a -> Operator
s {$sel:type':Operator' :: Maybe OperatorType
type' = Maybe OperatorType
a} :: Operator)

instance Prelude.Hashable Operator

instance Prelude.NFData Operator

instance Core.ToJSON Operator where
  toJSON :: Operator -> Value
toJSON Operator' {Maybe [Text]
Maybe OperatorType
type' :: Maybe OperatorType
values :: Maybe [Text]
$sel:type':Operator' :: Operator -> Maybe OperatorType
$sel:values:Operator' :: Operator -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"values" 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]
values,
            (Text
"type" Text -> OperatorType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (OperatorType -> Pair) -> Maybe OperatorType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OperatorType
type'
          ]
      )