{-# 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.Backup.Types.ConditionParameter
-- 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.Backup.Types.ConditionParameter 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

-- | Includes information about tags you define to assign tagged resources to
-- a backup plan.
--
-- /See:/ 'newConditionParameter' smart constructor.
data ConditionParameter = ConditionParameter'
  { -- | The key in a key-value pair. For example, in the tag
    -- @Department: Accounting@, @Department@ is the key.
    ConditionParameter -> Maybe Text
conditionKey :: Prelude.Maybe Prelude.Text,
    -- | The value in a key-value pair. For example, in the tag
    -- @Department: Accounting@, @Accounting@ is the value.
    ConditionParameter -> Maybe Text
conditionValue :: Prelude.Maybe Prelude.Text
  }
  deriving (ConditionParameter -> ConditionParameter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConditionParameter -> ConditionParameter -> Bool
$c/= :: ConditionParameter -> ConditionParameter -> Bool
== :: ConditionParameter -> ConditionParameter -> Bool
$c== :: ConditionParameter -> ConditionParameter -> Bool
Prelude.Eq, ReadPrec [ConditionParameter]
ReadPrec ConditionParameter
Int -> ReadS ConditionParameter
ReadS [ConditionParameter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConditionParameter]
$creadListPrec :: ReadPrec [ConditionParameter]
readPrec :: ReadPrec ConditionParameter
$creadPrec :: ReadPrec ConditionParameter
readList :: ReadS [ConditionParameter]
$creadList :: ReadS [ConditionParameter]
readsPrec :: Int -> ReadS ConditionParameter
$creadsPrec :: Int -> ReadS ConditionParameter
Prelude.Read, Int -> ConditionParameter -> ShowS
[ConditionParameter] -> ShowS
ConditionParameter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConditionParameter] -> ShowS
$cshowList :: [ConditionParameter] -> ShowS
show :: ConditionParameter -> String
$cshow :: ConditionParameter -> String
showsPrec :: Int -> ConditionParameter -> ShowS
$cshowsPrec :: Int -> ConditionParameter -> ShowS
Prelude.Show, forall x. Rep ConditionParameter x -> ConditionParameter
forall x. ConditionParameter -> Rep ConditionParameter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConditionParameter x -> ConditionParameter
$cfrom :: forall x. ConditionParameter -> Rep ConditionParameter x
Prelude.Generic)

-- |
-- Create a value of 'ConditionParameter' 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:
--
-- 'conditionKey', 'conditionParameter_conditionKey' - The key in a key-value pair. For example, in the tag
-- @Department: Accounting@, @Department@ is the key.
--
-- 'conditionValue', 'conditionParameter_conditionValue' - The value in a key-value pair. For example, in the tag
-- @Department: Accounting@, @Accounting@ is the value.
newConditionParameter ::
  ConditionParameter
newConditionParameter :: ConditionParameter
newConditionParameter =
  ConditionParameter'
    { $sel:conditionKey:ConditionParameter' :: Maybe Text
conditionKey = forall a. Maybe a
Prelude.Nothing,
      $sel:conditionValue:ConditionParameter' :: Maybe Text
conditionValue = forall a. Maybe a
Prelude.Nothing
    }

-- | The key in a key-value pair. For example, in the tag
-- @Department: Accounting@, @Department@ is the key.
conditionParameter_conditionKey :: Lens.Lens' ConditionParameter (Prelude.Maybe Prelude.Text)
conditionParameter_conditionKey :: Lens' ConditionParameter (Maybe Text)
conditionParameter_conditionKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConditionParameter' {Maybe Text
conditionKey :: Maybe Text
$sel:conditionKey:ConditionParameter' :: ConditionParameter -> Maybe Text
conditionKey} -> Maybe Text
conditionKey) (\s :: ConditionParameter
s@ConditionParameter' {} Maybe Text
a -> ConditionParameter
s {$sel:conditionKey:ConditionParameter' :: Maybe Text
conditionKey = Maybe Text
a} :: ConditionParameter)

-- | The value in a key-value pair. For example, in the tag
-- @Department: Accounting@, @Accounting@ is the value.
conditionParameter_conditionValue :: Lens.Lens' ConditionParameter (Prelude.Maybe Prelude.Text)
conditionParameter_conditionValue :: Lens' ConditionParameter (Maybe Text)
conditionParameter_conditionValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConditionParameter' {Maybe Text
conditionValue :: Maybe Text
$sel:conditionValue:ConditionParameter' :: ConditionParameter -> Maybe Text
conditionValue} -> Maybe Text
conditionValue) (\s :: ConditionParameter
s@ConditionParameter' {} Maybe Text
a -> ConditionParameter
s {$sel:conditionValue:ConditionParameter' :: Maybe Text
conditionValue = Maybe Text
a} :: ConditionParameter)

instance Data.FromJSON ConditionParameter where
  parseJSON :: Value -> Parser ConditionParameter
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ConditionParameter"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> ConditionParameter
ConditionParameter'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ConditionKey")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ConditionValue")
      )

instance Prelude.Hashable ConditionParameter where
  hashWithSalt :: Int -> ConditionParameter -> Int
hashWithSalt Int
_salt ConditionParameter' {Maybe Text
conditionValue :: Maybe Text
conditionKey :: Maybe Text
$sel:conditionValue:ConditionParameter' :: ConditionParameter -> Maybe Text
$sel:conditionKey:ConditionParameter' :: ConditionParameter -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
conditionKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
conditionValue

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

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