{-# 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.Selector
-- 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.Selector where

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

-- | A comparision that is used to determine whether a query should return
-- this object.
--
-- /See:/ 'newSelector' smart constructor.
data Selector = Selector'
  { Selector -> Maybe Operator
operator :: Prelude.Maybe Operator,
    -- | The name of the field that the operator will be applied to. The field
    -- name is the \"key\" portion of the field definition in the pipeline
    -- definition syntax that is used by the AWS Data Pipeline API. If the
    -- field is not set on the object, the condition fails.
    Selector -> Maybe Text
fieldName :: Prelude.Maybe Prelude.Text
  }
  deriving (Selector -> Selector -> Bool
(Selector -> Selector -> Bool)
-> (Selector -> Selector -> Bool) -> Eq Selector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Selector -> Selector -> Bool
$c/= :: Selector -> Selector -> Bool
== :: Selector -> Selector -> Bool
$c== :: Selector -> Selector -> Bool
Prelude.Eq, ReadPrec [Selector]
ReadPrec Selector
Int -> ReadS Selector
ReadS [Selector]
(Int -> ReadS Selector)
-> ReadS [Selector]
-> ReadPrec Selector
-> ReadPrec [Selector]
-> Read Selector
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Selector]
$creadListPrec :: ReadPrec [Selector]
readPrec :: ReadPrec Selector
$creadPrec :: ReadPrec Selector
readList :: ReadS [Selector]
$creadList :: ReadS [Selector]
readsPrec :: Int -> ReadS Selector
$creadsPrec :: Int -> ReadS Selector
Prelude.Read, Int -> Selector -> ShowS
[Selector] -> ShowS
Selector -> String
(Int -> Selector -> ShowS)
-> (Selector -> String) -> ([Selector] -> ShowS) -> Show Selector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Selector] -> ShowS
$cshowList :: [Selector] -> ShowS
show :: Selector -> String
$cshow :: Selector -> String
showsPrec :: Int -> Selector -> ShowS
$cshowsPrec :: Int -> Selector -> ShowS
Prelude.Show, (forall x. Selector -> Rep Selector x)
-> (forall x. Rep Selector x -> Selector) -> Generic Selector
forall x. Rep Selector x -> Selector
forall x. Selector -> Rep Selector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Selector x -> Selector
$cfrom :: forall x. Selector -> Rep Selector x
Prelude.Generic)

-- |
-- Create a value of 'Selector' 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:
--
-- 'operator', 'selector_operator' - Undocumented member.
--
-- 'fieldName', 'selector_fieldName' - The name of the field that the operator will be applied to. The field
-- name is the \"key\" portion of the field definition in the pipeline
-- definition syntax that is used by the AWS Data Pipeline API. If the
-- field is not set on the object, the condition fails.
newSelector ::
  Selector
newSelector :: Selector
newSelector =
  Selector' :: Maybe Operator -> Maybe Text -> Selector
Selector'
    { $sel:operator:Selector' :: Maybe Operator
operator = Maybe Operator
forall a. Maybe a
Prelude.Nothing,
      $sel:fieldName:Selector' :: Maybe Text
fieldName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
selector_operator :: Lens.Lens' Selector (Prelude.Maybe Operator)
selector_operator :: (Maybe Operator -> f (Maybe Operator)) -> Selector -> f Selector
selector_operator = (Selector -> Maybe Operator)
-> (Selector -> Maybe Operator -> Selector)
-> Lens Selector Selector (Maybe Operator) (Maybe Operator)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Selector' {Maybe Operator
operator :: Maybe Operator
$sel:operator:Selector' :: Selector -> Maybe Operator
operator} -> Maybe Operator
operator) (\s :: Selector
s@Selector' {} Maybe Operator
a -> Selector
s {$sel:operator:Selector' :: Maybe Operator
operator = Maybe Operator
a} :: Selector)

-- | The name of the field that the operator will be applied to. The field
-- name is the \"key\" portion of the field definition in the pipeline
-- definition syntax that is used by the AWS Data Pipeline API. If the
-- field is not set on the object, the condition fails.
selector_fieldName :: Lens.Lens' Selector (Prelude.Maybe Prelude.Text)
selector_fieldName :: (Maybe Text -> f (Maybe Text)) -> Selector -> f Selector
selector_fieldName = (Selector -> Maybe Text)
-> (Selector -> Maybe Text -> Selector)
-> Lens Selector Selector (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Selector' {Maybe Text
fieldName :: Maybe Text
$sel:fieldName:Selector' :: Selector -> Maybe Text
fieldName} -> Maybe Text
fieldName) (\s :: Selector
s@Selector' {} Maybe Text
a -> Selector
s {$sel:fieldName:Selector' :: Maybe Text
fieldName = Maybe Text
a} :: Selector)

instance Prelude.Hashable Selector

instance Prelude.NFData Selector

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