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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 value of parameter, for example, @hourly@.
    ControlInputParameter -> Maybe Text
parameterValue :: Prelude.Maybe Prelude.Text,
    -- | The name of a parameter, for example, @BackupPlanFrequency@.
    ControlInputParameter -> Maybe Text
parameterName :: Prelude.Maybe Prelude.Text
  }
  deriving (ControlInputParameter -> ControlInputParameter -> Bool
(ControlInputParameter -> ControlInputParameter -> Bool)
-> (ControlInputParameter -> ControlInputParameter -> Bool)
-> Eq ControlInputParameter
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]
(Int -> ReadS ControlInputParameter)
-> ReadS [ControlInputParameter]
-> ReadPrec ControlInputParameter
-> ReadPrec [ControlInputParameter]
-> Read 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
(Int -> ControlInputParameter -> ShowS)
-> (ControlInputParameter -> String)
-> ([ControlInputParameter] -> ShowS)
-> Show ControlInputParameter
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. ControlInputParameter -> Rep ControlInputParameter x)
-> (forall x. Rep ControlInputParameter x -> ControlInputParameter)
-> Generic ControlInputParameter
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:
--
-- 'parameterValue', 'controlInputParameter_parameterValue' - The value of parameter, for example, @hourly@.
--
-- 'parameterName', 'controlInputParameter_parameterName' - The name of a parameter, for example, @BackupPlanFrequency@.
newControlInputParameter ::
  ControlInputParameter
newControlInputParameter :: ControlInputParameter
newControlInputParameter =
  ControlInputParameter' :: Maybe Text -> Maybe Text -> ControlInputParameter
ControlInputParameter'
    { $sel:parameterValue:ControlInputParameter' :: Maybe Text
parameterValue =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:parameterName:ControlInputParameter' :: Maybe Text
parameterName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The value of parameter, for example, @hourly@.
controlInputParameter_parameterValue :: Lens.Lens' ControlInputParameter (Prelude.Maybe Prelude.Text)
controlInputParameter_parameterValue :: (Maybe Text -> f (Maybe Text))
-> ControlInputParameter -> f ControlInputParameter
controlInputParameter_parameterValue = (ControlInputParameter -> Maybe Text)
-> (ControlInputParameter -> Maybe Text -> ControlInputParameter)
-> Lens
     ControlInputParameter
     ControlInputParameter
     (Maybe Text)
     (Maybe Text)
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)

-- | The name of a parameter, for example, @BackupPlanFrequency@.
controlInputParameter_parameterName :: Lens.Lens' ControlInputParameter (Prelude.Maybe Prelude.Text)
controlInputParameter_parameterName :: (Maybe Text -> f (Maybe Text))
-> ControlInputParameter -> f ControlInputParameter
controlInputParameter_parameterName = (ControlInputParameter -> Maybe Text)
-> (ControlInputParameter -> Maybe Text -> ControlInputParameter)
-> Lens
     ControlInputParameter
     ControlInputParameter
     (Maybe Text)
     (Maybe Text)
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)

instance Core.FromJSON ControlInputParameter where
  parseJSON :: Value -> Parser ControlInputParameter
parseJSON =
    String
-> (Object -> Parser ControlInputParameter)
-> Value
-> Parser ControlInputParameter
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ControlInputParameter"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> ControlInputParameter
ControlInputParameter'
            (Maybe Text -> Maybe Text -> ControlInputParameter)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> ControlInputParameter)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ParameterValue")
            Parser (Maybe Text -> ControlInputParameter)
-> Parser (Maybe Text) -> Parser ControlInputParameter
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ParameterName")
      )

instance Prelude.Hashable ControlInputParameter

instance Prelude.NFData ControlInputParameter

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