{-# 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.ControlInputParameter
-- 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.ControlInputParameter 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 list of parameters for a control. A control can have zero, one, or
-- more than one parameter. An example of a control with two parameters is:
-- \"backup plan frequency is at least @daily@ and the retention period is
-- at least @1 year@\". The first parameter is @daily@. The second
-- parameter is @1 year@.
--
-- /See:/ 'newControlInputParameter' smart constructor.
data ControlInputParameter = ControlInputParameter'
  { -- | The name of a parameter, for example, @BackupPlanFrequency@.
    ControlInputParameter -> Maybe Text
parameterName :: Prelude.Maybe Prelude.Text,
    -- | The value of parameter, for example, @hourly@.
    ControlInputParameter -> Maybe Text
parameterValue :: Prelude.Maybe Prelude.Text
  }
  deriving (ControlInputParameter -> ControlInputParameter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ControlInputParameter -> ControlInputParameter -> Bool
$c/= :: ControlInputParameter -> ControlInputParameter -> Bool
== :: ControlInputParameter -> ControlInputParameter -> Bool
$c== :: ControlInputParameter -> ControlInputParameter -> Bool
Prelude.Eq, ReadPrec [ControlInputParameter]
ReadPrec ControlInputParameter
Int -> ReadS ControlInputParameter
ReadS [ControlInputParameter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ControlInputParameter]
$creadListPrec :: ReadPrec [ControlInputParameter]
readPrec :: ReadPrec ControlInputParameter
$creadPrec :: ReadPrec ControlInputParameter
readList :: ReadS [ControlInputParameter]
$creadList :: ReadS [ControlInputParameter]
readsPrec :: Int -> ReadS ControlInputParameter
$creadsPrec :: Int -> ReadS ControlInputParameter
Prelude.Read, Int -> ControlInputParameter -> ShowS
[ControlInputParameter] -> ShowS
ControlInputParameter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ControlInputParameter] -> ShowS
$cshowList :: [ControlInputParameter] -> ShowS
show :: ControlInputParameter -> String
$cshow :: ControlInputParameter -> String
showsPrec :: Int -> ControlInputParameter -> ShowS
$cshowsPrec :: Int -> ControlInputParameter -> ShowS
Prelude.Show, forall x. Rep ControlInputParameter x -> ControlInputParameter
forall x. ControlInputParameter -> Rep ControlInputParameter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ControlInputParameter x -> ControlInputParameter
$cfrom :: forall x. ControlInputParameter -> Rep ControlInputParameter x
Prelude.Generic)

-- |
-- Create a value of 'ControlInputParameter' 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:
--
-- 'parameterName', 'controlInputParameter_parameterName' - The name of a parameter, for example, @BackupPlanFrequency@.
--
-- 'parameterValue', 'controlInputParameter_parameterValue' - The value of parameter, for example, @hourly@.
newControlInputParameter ::
  ControlInputParameter
newControlInputParameter :: ControlInputParameter
newControlInputParameter =
  ControlInputParameter'
    { $sel:parameterName:ControlInputParameter' :: Maybe Text
parameterName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:parameterValue:ControlInputParameter' :: Maybe Text
parameterValue = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of a parameter, for example, @BackupPlanFrequency@.
controlInputParameter_parameterName :: Lens.Lens' ControlInputParameter (Prelude.Maybe Prelude.Text)
controlInputParameter_parameterName :: Lens' ControlInputParameter (Maybe Text)
controlInputParameter_parameterName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ControlInputParameter' {Maybe Text
parameterName :: Maybe Text
$sel:parameterName:ControlInputParameter' :: ControlInputParameter -> Maybe Text
parameterName} -> Maybe Text
parameterName) (\s :: ControlInputParameter
s@ControlInputParameter' {} Maybe Text
a -> ControlInputParameter
s {$sel:parameterName:ControlInputParameter' :: Maybe Text
parameterName = Maybe Text
a} :: ControlInputParameter)

-- | The value of parameter, for example, @hourly@.
controlInputParameter_parameterValue :: Lens.Lens' ControlInputParameter (Prelude.Maybe Prelude.Text)
controlInputParameter_parameterValue :: Lens' ControlInputParameter (Maybe Text)
controlInputParameter_parameterValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ControlInputParameter' {Maybe Text
parameterValue :: Maybe Text
$sel:parameterValue:ControlInputParameter' :: ControlInputParameter -> Maybe Text
parameterValue} -> Maybe Text
parameterValue) (\s :: ControlInputParameter
s@ControlInputParameter' {} Maybe Text
a -> ControlInputParameter
s {$sel:parameterValue:ControlInputParameter' :: Maybe Text
parameterValue = Maybe Text
a} :: ControlInputParameter)

instance Data.FromJSON ControlInputParameter where
  parseJSON :: Value -> Parser ControlInputParameter
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ControlInputParameter"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> ControlInputParameter
ControlInputParameter'
            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
"ParameterName")
            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
"ParameterValue")
      )

instance Prelude.Hashable ControlInputParameter where
  hashWithSalt :: Int -> ControlInputParameter -> Int
hashWithSalt Int
_salt ControlInputParameter' {Maybe Text
parameterValue :: Maybe Text
parameterName :: Maybe Text
$sel:parameterValue:ControlInputParameter' :: ControlInputParameter -> Maybe Text
$sel:parameterName:ControlInputParameter' :: ControlInputParameter -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
parameterName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
parameterValue

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

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