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

import Amazonka.Connect.Types.TagCondition
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

-- | An object that can be used to specify Tag conditions inside the
-- @SearchFilter@. This accepts an @OR@ of @AND@ (List of List) input
-- where:
--
-- -   Top level list specifies conditions that need to be applied with
--     @OR@ operator
--
-- -   Inner list specifies conditions that need to be applied with @AND@
--     operator.
--
-- /See:/ 'newControlPlaneTagFilter' smart constructor.
data ControlPlaneTagFilter = ControlPlaneTagFilter'
  { -- | A list of conditions which would be applied together with an @AND@
    -- condition.
    ControlPlaneTagFilter -> Maybe [TagCondition]
andConditions :: Prelude.Maybe [TagCondition],
    -- | A list of conditions which would be applied together with an @OR@
    -- condition.
    ControlPlaneTagFilter -> Maybe [[TagCondition]]
orConditions :: Prelude.Maybe [[TagCondition]],
    -- | A leaf node condition which can be used to specify a tag condition.
    ControlPlaneTagFilter -> Maybe TagCondition
tagCondition :: Prelude.Maybe TagCondition
  }
  deriving (ControlPlaneTagFilter -> ControlPlaneTagFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ControlPlaneTagFilter -> ControlPlaneTagFilter -> Bool
$c/= :: ControlPlaneTagFilter -> ControlPlaneTagFilter -> Bool
== :: ControlPlaneTagFilter -> ControlPlaneTagFilter -> Bool
$c== :: ControlPlaneTagFilter -> ControlPlaneTagFilter -> Bool
Prelude.Eq, ReadPrec [ControlPlaneTagFilter]
ReadPrec ControlPlaneTagFilter
Int -> ReadS ControlPlaneTagFilter
ReadS [ControlPlaneTagFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ControlPlaneTagFilter]
$creadListPrec :: ReadPrec [ControlPlaneTagFilter]
readPrec :: ReadPrec ControlPlaneTagFilter
$creadPrec :: ReadPrec ControlPlaneTagFilter
readList :: ReadS [ControlPlaneTagFilter]
$creadList :: ReadS [ControlPlaneTagFilter]
readsPrec :: Int -> ReadS ControlPlaneTagFilter
$creadsPrec :: Int -> ReadS ControlPlaneTagFilter
Prelude.Read, Int -> ControlPlaneTagFilter -> ShowS
[ControlPlaneTagFilter] -> ShowS
ControlPlaneTagFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ControlPlaneTagFilter] -> ShowS
$cshowList :: [ControlPlaneTagFilter] -> ShowS
show :: ControlPlaneTagFilter -> String
$cshow :: ControlPlaneTagFilter -> String
showsPrec :: Int -> ControlPlaneTagFilter -> ShowS
$cshowsPrec :: Int -> ControlPlaneTagFilter -> ShowS
Prelude.Show, forall x. Rep ControlPlaneTagFilter x -> ControlPlaneTagFilter
forall x. ControlPlaneTagFilter -> Rep ControlPlaneTagFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ControlPlaneTagFilter x -> ControlPlaneTagFilter
$cfrom :: forall x. ControlPlaneTagFilter -> Rep ControlPlaneTagFilter x
Prelude.Generic)

-- |
-- Create a value of 'ControlPlaneTagFilter' 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:
--
-- 'andConditions', 'controlPlaneTagFilter_andConditions' - A list of conditions which would be applied together with an @AND@
-- condition.
--
-- 'orConditions', 'controlPlaneTagFilter_orConditions' - A list of conditions which would be applied together with an @OR@
-- condition.
--
-- 'tagCondition', 'controlPlaneTagFilter_tagCondition' - A leaf node condition which can be used to specify a tag condition.
newControlPlaneTagFilter ::
  ControlPlaneTagFilter
newControlPlaneTagFilter :: ControlPlaneTagFilter
newControlPlaneTagFilter =
  ControlPlaneTagFilter'
    { $sel:andConditions:ControlPlaneTagFilter' :: Maybe [TagCondition]
andConditions =
        forall a. Maybe a
Prelude.Nothing,
      $sel:orConditions:ControlPlaneTagFilter' :: Maybe [[TagCondition]]
orConditions = forall a. Maybe a
Prelude.Nothing,
      $sel:tagCondition:ControlPlaneTagFilter' :: Maybe TagCondition
tagCondition = forall a. Maybe a
Prelude.Nothing
    }

-- | A list of conditions which would be applied together with an @AND@
-- condition.
controlPlaneTagFilter_andConditions :: Lens.Lens' ControlPlaneTagFilter (Prelude.Maybe [TagCondition])
controlPlaneTagFilter_andConditions :: Lens' ControlPlaneTagFilter (Maybe [TagCondition])
controlPlaneTagFilter_andConditions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ControlPlaneTagFilter' {Maybe [TagCondition]
andConditions :: Maybe [TagCondition]
$sel:andConditions:ControlPlaneTagFilter' :: ControlPlaneTagFilter -> Maybe [TagCondition]
andConditions} -> Maybe [TagCondition]
andConditions) (\s :: ControlPlaneTagFilter
s@ControlPlaneTagFilter' {} Maybe [TagCondition]
a -> ControlPlaneTagFilter
s {$sel:andConditions:ControlPlaneTagFilter' :: Maybe [TagCondition]
andConditions = Maybe [TagCondition]
a} :: ControlPlaneTagFilter) 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

-- | A list of conditions which would be applied together with an @OR@
-- condition.
controlPlaneTagFilter_orConditions :: Lens.Lens' ControlPlaneTagFilter (Prelude.Maybe [[TagCondition]])
controlPlaneTagFilter_orConditions :: Lens' ControlPlaneTagFilter (Maybe [[TagCondition]])
controlPlaneTagFilter_orConditions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ControlPlaneTagFilter' {Maybe [[TagCondition]]
orConditions :: Maybe [[TagCondition]]
$sel:orConditions:ControlPlaneTagFilter' :: ControlPlaneTagFilter -> Maybe [[TagCondition]]
orConditions} -> Maybe [[TagCondition]]
orConditions) (\s :: ControlPlaneTagFilter
s@ControlPlaneTagFilter' {} Maybe [[TagCondition]]
a -> ControlPlaneTagFilter
s {$sel:orConditions:ControlPlaneTagFilter' :: Maybe [[TagCondition]]
orConditions = Maybe [[TagCondition]]
a} :: ControlPlaneTagFilter) 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

-- | A leaf node condition which can be used to specify a tag condition.
controlPlaneTagFilter_tagCondition :: Lens.Lens' ControlPlaneTagFilter (Prelude.Maybe TagCondition)
controlPlaneTagFilter_tagCondition :: Lens' ControlPlaneTagFilter (Maybe TagCondition)
controlPlaneTagFilter_tagCondition = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ControlPlaneTagFilter' {Maybe TagCondition
tagCondition :: Maybe TagCondition
$sel:tagCondition:ControlPlaneTagFilter' :: ControlPlaneTagFilter -> Maybe TagCondition
tagCondition} -> Maybe TagCondition
tagCondition) (\s :: ControlPlaneTagFilter
s@ControlPlaneTagFilter' {} Maybe TagCondition
a -> ControlPlaneTagFilter
s {$sel:tagCondition:ControlPlaneTagFilter' :: Maybe TagCondition
tagCondition = Maybe TagCondition
a} :: ControlPlaneTagFilter)

instance Prelude.Hashable ControlPlaneTagFilter where
  hashWithSalt :: Int -> ControlPlaneTagFilter -> Int
hashWithSalt Int
_salt ControlPlaneTagFilter' {Maybe [[TagCondition]]
Maybe [TagCondition]
Maybe TagCondition
tagCondition :: Maybe TagCondition
orConditions :: Maybe [[TagCondition]]
andConditions :: Maybe [TagCondition]
$sel:tagCondition:ControlPlaneTagFilter' :: ControlPlaneTagFilter -> Maybe TagCondition
$sel:orConditions:ControlPlaneTagFilter' :: ControlPlaneTagFilter -> Maybe [[TagCondition]]
$sel:andConditions:ControlPlaneTagFilter' :: ControlPlaneTagFilter -> Maybe [TagCondition]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [TagCondition]
andConditions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [[TagCondition]]
orConditions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TagCondition
tagCondition

instance Prelude.NFData ControlPlaneTagFilter where
  rnf :: ControlPlaneTagFilter -> ()
rnf ControlPlaneTagFilter' {Maybe [[TagCondition]]
Maybe [TagCondition]
Maybe TagCondition
tagCondition :: Maybe TagCondition
orConditions :: Maybe [[TagCondition]]
andConditions :: Maybe [TagCondition]
$sel:tagCondition:ControlPlaneTagFilter' :: ControlPlaneTagFilter -> Maybe TagCondition
$sel:orConditions:ControlPlaneTagFilter' :: ControlPlaneTagFilter -> Maybe [[TagCondition]]
$sel:andConditions:ControlPlaneTagFilter' :: ControlPlaneTagFilter -> Maybe [TagCondition]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [TagCondition]
andConditions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [[TagCondition]]
orConditions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TagCondition
tagCondition

instance Data.ToJSON ControlPlaneTagFilter where
  toJSON :: ControlPlaneTagFilter -> Value
toJSON ControlPlaneTagFilter' {Maybe [[TagCondition]]
Maybe [TagCondition]
Maybe TagCondition
tagCondition :: Maybe TagCondition
orConditions :: Maybe [[TagCondition]]
andConditions :: Maybe [TagCondition]
$sel:tagCondition:ControlPlaneTagFilter' :: ControlPlaneTagFilter -> Maybe TagCondition
$sel:orConditions:ControlPlaneTagFilter' :: ControlPlaneTagFilter -> Maybe [[TagCondition]]
$sel:andConditions:ControlPlaneTagFilter' :: ControlPlaneTagFilter -> Maybe [TagCondition]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AndConditions" 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 [TagCondition]
andConditions,
            (Key
"OrConditions" 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 [[TagCondition]]
orConditions,
            (Key
"TagCondition" 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 TagCondition
tagCondition
          ]
      )