{-# 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.ServiceCatalog.Types.UpdateProvisioningParameter
-- 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.ServiceCatalog.Types.UpdateProvisioningParameter 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

-- | The parameter key-value pair used to update a provisioned product.
--
-- /See:/ 'newUpdateProvisioningParameter' smart constructor.
data UpdateProvisioningParameter = UpdateProvisioningParameter'
  { -- | The parameter key.
    UpdateProvisioningParameter -> Maybe Text
key :: Prelude.Maybe Prelude.Text,
    -- | If set to true, @Value@ is ignored and the previous parameter value is
    -- kept.
    UpdateProvisioningParameter -> Maybe Bool
usePreviousValue :: Prelude.Maybe Prelude.Bool,
    -- | The parameter value.
    UpdateProvisioningParameter -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (UpdateProvisioningParameter -> UpdateProvisioningParameter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateProvisioningParameter -> UpdateProvisioningParameter -> Bool
$c/= :: UpdateProvisioningParameter -> UpdateProvisioningParameter -> Bool
== :: UpdateProvisioningParameter -> UpdateProvisioningParameter -> Bool
$c== :: UpdateProvisioningParameter -> UpdateProvisioningParameter -> Bool
Prelude.Eq, ReadPrec [UpdateProvisioningParameter]
ReadPrec UpdateProvisioningParameter
Int -> ReadS UpdateProvisioningParameter
ReadS [UpdateProvisioningParameter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateProvisioningParameter]
$creadListPrec :: ReadPrec [UpdateProvisioningParameter]
readPrec :: ReadPrec UpdateProvisioningParameter
$creadPrec :: ReadPrec UpdateProvisioningParameter
readList :: ReadS [UpdateProvisioningParameter]
$creadList :: ReadS [UpdateProvisioningParameter]
readsPrec :: Int -> ReadS UpdateProvisioningParameter
$creadsPrec :: Int -> ReadS UpdateProvisioningParameter
Prelude.Read, Int -> UpdateProvisioningParameter -> ShowS
[UpdateProvisioningParameter] -> ShowS
UpdateProvisioningParameter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateProvisioningParameter] -> ShowS
$cshowList :: [UpdateProvisioningParameter] -> ShowS
show :: UpdateProvisioningParameter -> String
$cshow :: UpdateProvisioningParameter -> String
showsPrec :: Int -> UpdateProvisioningParameter -> ShowS
$cshowsPrec :: Int -> UpdateProvisioningParameter -> ShowS
Prelude.Show, forall x.
Rep UpdateProvisioningParameter x -> UpdateProvisioningParameter
forall x.
UpdateProvisioningParameter -> Rep UpdateProvisioningParameter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateProvisioningParameter x -> UpdateProvisioningParameter
$cfrom :: forall x.
UpdateProvisioningParameter -> Rep UpdateProvisioningParameter x
Prelude.Generic)

-- |
-- Create a value of 'UpdateProvisioningParameter' 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:
--
-- 'key', 'updateProvisioningParameter_key' - The parameter key.
--
-- 'usePreviousValue', 'updateProvisioningParameter_usePreviousValue' - If set to true, @Value@ is ignored and the previous parameter value is
-- kept.
--
-- 'value', 'updateProvisioningParameter_value' - The parameter value.
newUpdateProvisioningParameter ::
  UpdateProvisioningParameter
newUpdateProvisioningParameter :: UpdateProvisioningParameter
newUpdateProvisioningParameter =
  UpdateProvisioningParameter'
    { $sel:key:UpdateProvisioningParameter' :: Maybe Text
key = forall a. Maybe a
Prelude.Nothing,
      $sel:usePreviousValue:UpdateProvisioningParameter' :: Maybe Bool
usePreviousValue = forall a. Maybe a
Prelude.Nothing,
      $sel:value:UpdateProvisioningParameter' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The parameter key.
updateProvisioningParameter_key :: Lens.Lens' UpdateProvisioningParameter (Prelude.Maybe Prelude.Text)
updateProvisioningParameter_key :: Lens' UpdateProvisioningParameter (Maybe Text)
updateProvisioningParameter_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProvisioningParameter' {Maybe Text
key :: Maybe Text
$sel:key:UpdateProvisioningParameter' :: UpdateProvisioningParameter -> Maybe Text
key} -> Maybe Text
key) (\s :: UpdateProvisioningParameter
s@UpdateProvisioningParameter' {} Maybe Text
a -> UpdateProvisioningParameter
s {$sel:key:UpdateProvisioningParameter' :: Maybe Text
key = Maybe Text
a} :: UpdateProvisioningParameter)

-- | If set to true, @Value@ is ignored and the previous parameter value is
-- kept.
updateProvisioningParameter_usePreviousValue :: Lens.Lens' UpdateProvisioningParameter (Prelude.Maybe Prelude.Bool)
updateProvisioningParameter_usePreviousValue :: Lens' UpdateProvisioningParameter (Maybe Bool)
updateProvisioningParameter_usePreviousValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProvisioningParameter' {Maybe Bool
usePreviousValue :: Maybe Bool
$sel:usePreviousValue:UpdateProvisioningParameter' :: UpdateProvisioningParameter -> Maybe Bool
usePreviousValue} -> Maybe Bool
usePreviousValue) (\s :: UpdateProvisioningParameter
s@UpdateProvisioningParameter' {} Maybe Bool
a -> UpdateProvisioningParameter
s {$sel:usePreviousValue:UpdateProvisioningParameter' :: Maybe Bool
usePreviousValue = Maybe Bool
a} :: UpdateProvisioningParameter)

-- | The parameter value.
updateProvisioningParameter_value :: Lens.Lens' UpdateProvisioningParameter (Prelude.Maybe Prelude.Text)
updateProvisioningParameter_value :: Lens' UpdateProvisioningParameter (Maybe Text)
updateProvisioningParameter_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProvisioningParameter' {Maybe Text
value :: Maybe Text
$sel:value:UpdateProvisioningParameter' :: UpdateProvisioningParameter -> Maybe Text
value} -> Maybe Text
value) (\s :: UpdateProvisioningParameter
s@UpdateProvisioningParameter' {} Maybe Text
a -> UpdateProvisioningParameter
s {$sel:value:UpdateProvisioningParameter' :: Maybe Text
value = Maybe Text
a} :: UpdateProvisioningParameter)

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

instance Prelude.Hashable UpdateProvisioningParameter where
  hashWithSalt :: Int -> UpdateProvisioningParameter -> Int
hashWithSalt Int
_salt UpdateProvisioningParameter' {Maybe Bool
Maybe Text
value :: Maybe Text
usePreviousValue :: Maybe Bool
key :: Maybe Text
$sel:value:UpdateProvisioningParameter' :: UpdateProvisioningParameter -> Maybe Text
$sel:usePreviousValue:UpdateProvisioningParameter' :: UpdateProvisioningParameter -> Maybe Bool
$sel:key:UpdateProvisioningParameter' :: UpdateProvisioningParameter -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
usePreviousValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData UpdateProvisioningParameter where
  rnf :: UpdateProvisioningParameter -> ()
rnf UpdateProvisioningParameter' {Maybe Bool
Maybe Text
value :: Maybe Text
usePreviousValue :: Maybe Bool
key :: Maybe Text
$sel:value:UpdateProvisioningParameter' :: UpdateProvisioningParameter -> Maybe Text
$sel:usePreviousValue:UpdateProvisioningParameter' :: UpdateProvisioningParameter -> Maybe Bool
$sel:key:UpdateProvisioningParameter' :: UpdateProvisioningParameter -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
key
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
usePreviousValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value

instance Data.ToJSON UpdateProvisioningParameter where
  toJSON :: UpdateProvisioningParameter -> Value
toJSON UpdateProvisioningParameter' {Maybe Bool
Maybe Text
value :: Maybe Text
usePreviousValue :: Maybe Bool
key :: Maybe Text
$sel:value:UpdateProvisioningParameter' :: UpdateProvisioningParameter -> Maybe Text
$sel:usePreviousValue:UpdateProvisioningParameter' :: UpdateProvisioningParameter -> Maybe Bool
$sel:key:UpdateProvisioningParameter' :: UpdateProvisioningParameter -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Key" 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
key,
            (Key
"UsePreviousValue" 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 Bool
usePreviousValue,
            (Key
"Value" 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
value
          ]
      )