{-# 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.Connect.Types.TagCondition
-- 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.Connect.Types.TagCondition where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | A leaf node condition which can be used to specify a tag condition, for
-- example, @HAVE BPO = 123@.
--
-- /See:/ 'newTagCondition' smart constructor.
data TagCondition = TagCondition'
  { -- | The tag key in the tag condition.
    TagCondition -> Maybe Text
tagKey :: Prelude.Maybe Prelude.Text,
    -- | The tag value in the tag condition.
    TagCondition -> Maybe Text
tagValue :: Prelude.Maybe Prelude.Text
  }
  deriving (TagCondition -> TagCondition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TagCondition -> TagCondition -> Bool
$c/= :: TagCondition -> TagCondition -> Bool
== :: TagCondition -> TagCondition -> Bool
$c== :: TagCondition -> TagCondition -> Bool
Prelude.Eq, ReadPrec [TagCondition]
ReadPrec TagCondition
Int -> ReadS TagCondition
ReadS [TagCondition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TagCondition]
$creadListPrec :: ReadPrec [TagCondition]
readPrec :: ReadPrec TagCondition
$creadPrec :: ReadPrec TagCondition
readList :: ReadS [TagCondition]
$creadList :: ReadS [TagCondition]
readsPrec :: Int -> ReadS TagCondition
$creadsPrec :: Int -> ReadS TagCondition
Prelude.Read, Int -> TagCondition -> ShowS
[TagCondition] -> ShowS
TagCondition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TagCondition] -> ShowS
$cshowList :: [TagCondition] -> ShowS
show :: TagCondition -> String
$cshow :: TagCondition -> String
showsPrec :: Int -> TagCondition -> ShowS
$cshowsPrec :: Int -> TagCondition -> ShowS
Prelude.Show, forall x. Rep TagCondition x -> TagCondition
forall x. TagCondition -> Rep TagCondition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TagCondition x -> TagCondition
$cfrom :: forall x. TagCondition -> Rep TagCondition x
Prelude.Generic)

-- |
-- Create a value of 'TagCondition' 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:
--
-- 'tagKey', 'tagCondition_tagKey' - The tag key in the tag condition.
--
-- 'tagValue', 'tagCondition_tagValue' - The tag value in the tag condition.
newTagCondition ::
  TagCondition
newTagCondition :: TagCondition
newTagCondition =
  TagCondition'
    { $sel:tagKey:TagCondition' :: Maybe Text
tagKey = forall a. Maybe a
Prelude.Nothing,
      $sel:tagValue:TagCondition' :: Maybe Text
tagValue = forall a. Maybe a
Prelude.Nothing
    }

-- | The tag key in the tag condition.
tagCondition_tagKey :: Lens.Lens' TagCondition (Prelude.Maybe Prelude.Text)
tagCondition_tagKey :: Lens' TagCondition (Maybe Text)
tagCondition_tagKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagCondition' {Maybe Text
tagKey :: Maybe Text
$sel:tagKey:TagCondition' :: TagCondition -> Maybe Text
tagKey} -> Maybe Text
tagKey) (\s :: TagCondition
s@TagCondition' {} Maybe Text
a -> TagCondition
s {$sel:tagKey:TagCondition' :: Maybe Text
tagKey = Maybe Text
a} :: TagCondition)

-- | The tag value in the tag condition.
tagCondition_tagValue :: Lens.Lens' TagCondition (Prelude.Maybe Prelude.Text)
tagCondition_tagValue :: Lens' TagCondition (Maybe Text)
tagCondition_tagValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagCondition' {Maybe Text
tagValue :: Maybe Text
$sel:tagValue:TagCondition' :: TagCondition -> Maybe Text
tagValue} -> Maybe Text
tagValue) (\s :: TagCondition
s@TagCondition' {} Maybe Text
a -> TagCondition
s {$sel:tagValue:TagCondition' :: Maybe Text
tagValue = Maybe Text
a} :: TagCondition)

instance Prelude.Hashable TagCondition where
  hashWithSalt :: Int -> TagCondition -> Int
hashWithSalt Int
_salt TagCondition' {Maybe Text
tagValue :: Maybe Text
tagKey :: Maybe Text
$sel:tagValue:TagCondition' :: TagCondition -> Maybe Text
$sel:tagKey:TagCondition' :: TagCondition -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
tagKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
tagValue

instance Prelude.NFData TagCondition where
  rnf :: TagCondition -> ()
rnf TagCondition' {Maybe Text
tagValue :: Maybe Text
tagKey :: Maybe Text
$sel:tagValue:TagCondition' :: TagCondition -> Maybe Text
$sel:tagKey:TagCondition' :: TagCondition -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
tagKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
tagValue

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