{-# 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.Config.Types.RemediationParameterValue
-- 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.Config.Types.RemediationParameterValue where

import Amazonka.Config.Types.ResourceValue
import Amazonka.Config.Types.StaticValue
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

-- | The value is either a dynamic (resource) value or a static value. You
-- must select either a dynamic value or a static value.
--
-- /See:/ 'newRemediationParameterValue' smart constructor.
data RemediationParameterValue = RemediationParameterValue'
  { -- | The value is dynamic and changes at run-time.
    RemediationParameterValue -> Maybe ResourceValue
resourceValue :: Prelude.Maybe ResourceValue,
    -- | The value is static and does not change at run-time.
    RemediationParameterValue -> Maybe StaticValue
staticValue :: Prelude.Maybe StaticValue
  }
  deriving (RemediationParameterValue -> RemediationParameterValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemediationParameterValue -> RemediationParameterValue -> Bool
$c/= :: RemediationParameterValue -> RemediationParameterValue -> Bool
== :: RemediationParameterValue -> RemediationParameterValue -> Bool
$c== :: RemediationParameterValue -> RemediationParameterValue -> Bool
Prelude.Eq, ReadPrec [RemediationParameterValue]
ReadPrec RemediationParameterValue
Int -> ReadS RemediationParameterValue
ReadS [RemediationParameterValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemediationParameterValue]
$creadListPrec :: ReadPrec [RemediationParameterValue]
readPrec :: ReadPrec RemediationParameterValue
$creadPrec :: ReadPrec RemediationParameterValue
readList :: ReadS [RemediationParameterValue]
$creadList :: ReadS [RemediationParameterValue]
readsPrec :: Int -> ReadS RemediationParameterValue
$creadsPrec :: Int -> ReadS RemediationParameterValue
Prelude.Read, Int -> RemediationParameterValue -> ShowS
[RemediationParameterValue] -> ShowS
RemediationParameterValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemediationParameterValue] -> ShowS
$cshowList :: [RemediationParameterValue] -> ShowS
show :: RemediationParameterValue -> String
$cshow :: RemediationParameterValue -> String
showsPrec :: Int -> RemediationParameterValue -> ShowS
$cshowsPrec :: Int -> RemediationParameterValue -> ShowS
Prelude.Show, forall x.
Rep RemediationParameterValue x -> RemediationParameterValue
forall x.
RemediationParameterValue -> Rep RemediationParameterValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RemediationParameterValue x -> RemediationParameterValue
$cfrom :: forall x.
RemediationParameterValue -> Rep RemediationParameterValue x
Prelude.Generic)

-- |
-- Create a value of 'RemediationParameterValue' 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:
--
-- 'resourceValue', 'remediationParameterValue_resourceValue' - The value is dynamic and changes at run-time.
--
-- 'staticValue', 'remediationParameterValue_staticValue' - The value is static and does not change at run-time.
newRemediationParameterValue ::
  RemediationParameterValue
newRemediationParameterValue :: RemediationParameterValue
newRemediationParameterValue =
  RemediationParameterValue'
    { $sel:resourceValue:RemediationParameterValue' :: Maybe ResourceValue
resourceValue =
        forall a. Maybe a
Prelude.Nothing,
      $sel:staticValue:RemediationParameterValue' :: Maybe StaticValue
staticValue = forall a. Maybe a
Prelude.Nothing
    }

-- | The value is dynamic and changes at run-time.
remediationParameterValue_resourceValue :: Lens.Lens' RemediationParameterValue (Prelude.Maybe ResourceValue)
remediationParameterValue_resourceValue :: Lens' RemediationParameterValue (Maybe ResourceValue)
remediationParameterValue_resourceValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemediationParameterValue' {Maybe ResourceValue
resourceValue :: Maybe ResourceValue
$sel:resourceValue:RemediationParameterValue' :: RemediationParameterValue -> Maybe ResourceValue
resourceValue} -> Maybe ResourceValue
resourceValue) (\s :: RemediationParameterValue
s@RemediationParameterValue' {} Maybe ResourceValue
a -> RemediationParameterValue
s {$sel:resourceValue:RemediationParameterValue' :: Maybe ResourceValue
resourceValue = Maybe ResourceValue
a} :: RemediationParameterValue)

-- | The value is static and does not change at run-time.
remediationParameterValue_staticValue :: Lens.Lens' RemediationParameterValue (Prelude.Maybe StaticValue)
remediationParameterValue_staticValue :: Lens' RemediationParameterValue (Maybe StaticValue)
remediationParameterValue_staticValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemediationParameterValue' {Maybe StaticValue
staticValue :: Maybe StaticValue
$sel:staticValue:RemediationParameterValue' :: RemediationParameterValue -> Maybe StaticValue
staticValue} -> Maybe StaticValue
staticValue) (\s :: RemediationParameterValue
s@RemediationParameterValue' {} Maybe StaticValue
a -> RemediationParameterValue
s {$sel:staticValue:RemediationParameterValue' :: Maybe StaticValue
staticValue = Maybe StaticValue
a} :: RemediationParameterValue)

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

instance Prelude.Hashable RemediationParameterValue where
  hashWithSalt :: Int -> RemediationParameterValue -> Int
hashWithSalt Int
_salt RemediationParameterValue' {Maybe ResourceValue
Maybe StaticValue
staticValue :: Maybe StaticValue
resourceValue :: Maybe ResourceValue
$sel:staticValue:RemediationParameterValue' :: RemediationParameterValue -> Maybe StaticValue
$sel:resourceValue:RemediationParameterValue' :: RemediationParameterValue -> Maybe ResourceValue
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResourceValue
resourceValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StaticValue
staticValue

instance Prelude.NFData RemediationParameterValue where
  rnf :: RemediationParameterValue -> ()
rnf RemediationParameterValue' {Maybe ResourceValue
Maybe StaticValue
staticValue :: Maybe StaticValue
resourceValue :: Maybe ResourceValue
$sel:staticValue:RemediationParameterValue' :: RemediationParameterValue -> Maybe StaticValue
$sel:resourceValue:RemediationParameterValue' :: RemediationParameterValue -> Maybe ResourceValue
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceValue
resourceValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe StaticValue
staticValue

instance Data.ToJSON RemediationParameterValue where
  toJSON :: RemediationParameterValue -> Value
toJSON RemediationParameterValue' {Maybe ResourceValue
Maybe StaticValue
staticValue :: Maybe StaticValue
resourceValue :: Maybe ResourceValue
$sel:staticValue:RemediationParameterValue' :: RemediationParameterValue -> Maybe StaticValue
$sel:resourceValue:RemediationParameterValue' :: RemediationParameterValue -> Maybe ResourceValue
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ResourceValue" 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 ResourceValue
resourceValue,
            (Key
"StaticValue" 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 StaticValue
staticValue
          ]
      )