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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 value.
    UpdateProvisioningParameter -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | 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
  }
  deriving (UpdateProvisioningParameter -> UpdateProvisioningParameter -> Bool
(UpdateProvisioningParameter
 -> UpdateProvisioningParameter -> Bool)
-> (UpdateProvisioningParameter
    -> UpdateProvisioningParameter -> Bool)
-> Eq UpdateProvisioningParameter
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]
(Int -> ReadS UpdateProvisioningParameter)
-> ReadS [UpdateProvisioningParameter]
-> ReadPrec UpdateProvisioningParameter
-> ReadPrec [UpdateProvisioningParameter]
-> Read 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
(Int -> UpdateProvisioningParameter -> ShowS)
-> (UpdateProvisioningParameter -> String)
-> ([UpdateProvisioningParameter] -> ShowS)
-> Show UpdateProvisioningParameter
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.
 UpdateProvisioningParameter -> Rep UpdateProvisioningParameter x)
-> (forall x.
    Rep UpdateProvisioningParameter x -> UpdateProvisioningParameter)
-> Generic UpdateProvisioningParameter
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:
--
-- 'value', 'updateProvisioningParameter_value' - The parameter value.
--
-- 'key', 'updateProvisioningParameter_key' - The parameter key.
--
-- 'usePreviousValue', 'updateProvisioningParameter_usePreviousValue' - If set to true, @Value@ is ignored and the previous parameter value is
-- kept.
newUpdateProvisioningParameter ::
  UpdateProvisioningParameter
newUpdateProvisioningParameter :: UpdateProvisioningParameter
newUpdateProvisioningParameter =
  UpdateProvisioningParameter' :: Maybe Text
-> Maybe Text -> Maybe Bool -> UpdateProvisioningParameter
UpdateProvisioningParameter'
    { $sel:value:UpdateProvisioningParameter' :: Maybe Text
value =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:key:UpdateProvisioningParameter' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:usePreviousValue:UpdateProvisioningParameter' :: Maybe Bool
usePreviousValue = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The parameter value.
updateProvisioningParameter_value :: Lens.Lens' UpdateProvisioningParameter (Prelude.Maybe Prelude.Text)
updateProvisioningParameter_value :: (Maybe Text -> f (Maybe Text))
-> UpdateProvisioningParameter -> f UpdateProvisioningParameter
updateProvisioningParameter_value = (UpdateProvisioningParameter -> Maybe Text)
-> (UpdateProvisioningParameter
    -> Maybe Text -> UpdateProvisioningParameter)
-> Lens
     UpdateProvisioningParameter
     UpdateProvisioningParameter
     (Maybe Text)
     (Maybe Text)
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)

-- | The parameter key.
updateProvisioningParameter_key :: Lens.Lens' UpdateProvisioningParameter (Prelude.Maybe Prelude.Text)
updateProvisioningParameter_key :: (Maybe Text -> f (Maybe Text))
-> UpdateProvisioningParameter -> f UpdateProvisioningParameter
updateProvisioningParameter_key = (UpdateProvisioningParameter -> Maybe Text)
-> (UpdateProvisioningParameter
    -> Maybe Text -> UpdateProvisioningParameter)
-> Lens
     UpdateProvisioningParameter
     UpdateProvisioningParameter
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe Bool -> f (Maybe Bool))
-> UpdateProvisioningParameter -> f UpdateProvisioningParameter
updateProvisioningParameter_usePreviousValue = (UpdateProvisioningParameter -> Maybe Bool)
-> (UpdateProvisioningParameter
    -> Maybe Bool -> UpdateProvisioningParameter)
-> Lens
     UpdateProvisioningParameter
     UpdateProvisioningParameter
     (Maybe Bool)
     (Maybe Bool)
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)

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

instance Prelude.Hashable UpdateProvisioningParameter

instance Prelude.NFData UpdateProvisioningParameter

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