{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DataPipeline.Types.Operator where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DataPipeline.Types.OperatorType
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 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,
    -- | The value that the actual field value will be compared with.
    Operator -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text]
  }
  deriving (Operator -> Operator -> Bool
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]
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
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. 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:
--
-- '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\".
--
-- 'values', 'operator_values' - The value that the actual field value will be compared with.
newOperator ::
  Operator
newOperator :: Operator
newOperator =
  Operator'
    { $sel:type':Operator' :: Maybe OperatorType
type' = forall a. Maybe a
Prelude.Nothing,
      $sel:values:Operator' :: Maybe [Text]
values = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' Operator (Maybe OperatorType)
operator_type = 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)

-- | The value that the actual field value will be compared with.
operator_values :: Lens.Lens' Operator (Prelude.Maybe [Prelude.Text])
operator_values :: Lens' Operator (Maybe [Text])
operator_values = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable Operator where
  hashWithSalt :: Int -> Operator -> Int
hashWithSalt Int
_salt Operator' {Maybe [Text]
Maybe OperatorType
values :: Maybe [Text]
type' :: Maybe OperatorType
$sel:values:Operator' :: Operator -> Maybe [Text]
$sel:type':Operator' :: Operator -> Maybe OperatorType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe OperatorType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
values

instance Prelude.NFData Operator where
  rnf :: Operator -> ()
rnf Operator' {Maybe [Text]
Maybe OperatorType
values :: Maybe [Text]
type' :: Maybe OperatorType
$sel:values:Operator' :: Operator -> Maybe [Text]
$sel:type':Operator' :: Operator -> Maybe OperatorType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe OperatorType
type' seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
values

instance Data.ToJSON Operator where
  toJSON :: Operator -> Value
toJSON Operator' {Maybe [Text]
Maybe OperatorType
values :: Maybe [Text]
type' :: Maybe OperatorType
$sel:values:Operator' :: Operator -> Maybe [Text]
$sel:type':Operator' :: Operator -> Maybe OperatorType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"type" 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 OperatorType
type',
            (Key
"values" 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]
values
          ]
      )