{-# 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.Nimble.Types.ScriptParameterKeyValue
-- 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.Nimble.Types.ScriptParameterKeyValue 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 parameter for a studio component script, in the form of a key-value
-- pair.
--
-- /See:/ 'newScriptParameterKeyValue' smart constructor.
data ScriptParameterKeyValue = ScriptParameterKeyValue'
  { -- | A script parameter key.
    ScriptParameterKeyValue -> Maybe Text
key :: Prelude.Maybe Prelude.Text,
    -- | A script parameter value.
    ScriptParameterKeyValue -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (ScriptParameterKeyValue -> ScriptParameterKeyValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScriptParameterKeyValue -> ScriptParameterKeyValue -> Bool
$c/= :: ScriptParameterKeyValue -> ScriptParameterKeyValue -> Bool
== :: ScriptParameterKeyValue -> ScriptParameterKeyValue -> Bool
$c== :: ScriptParameterKeyValue -> ScriptParameterKeyValue -> Bool
Prelude.Eq, ReadPrec [ScriptParameterKeyValue]
ReadPrec ScriptParameterKeyValue
Int -> ReadS ScriptParameterKeyValue
ReadS [ScriptParameterKeyValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScriptParameterKeyValue]
$creadListPrec :: ReadPrec [ScriptParameterKeyValue]
readPrec :: ReadPrec ScriptParameterKeyValue
$creadPrec :: ReadPrec ScriptParameterKeyValue
readList :: ReadS [ScriptParameterKeyValue]
$creadList :: ReadS [ScriptParameterKeyValue]
readsPrec :: Int -> ReadS ScriptParameterKeyValue
$creadsPrec :: Int -> ReadS ScriptParameterKeyValue
Prelude.Read, Int -> ScriptParameterKeyValue -> ShowS
[ScriptParameterKeyValue] -> ShowS
ScriptParameterKeyValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScriptParameterKeyValue] -> ShowS
$cshowList :: [ScriptParameterKeyValue] -> ShowS
show :: ScriptParameterKeyValue -> String
$cshow :: ScriptParameterKeyValue -> String
showsPrec :: Int -> ScriptParameterKeyValue -> ShowS
$cshowsPrec :: Int -> ScriptParameterKeyValue -> ShowS
Prelude.Show, forall x. Rep ScriptParameterKeyValue x -> ScriptParameterKeyValue
forall x. ScriptParameterKeyValue -> Rep ScriptParameterKeyValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScriptParameterKeyValue x -> ScriptParameterKeyValue
$cfrom :: forall x. ScriptParameterKeyValue -> Rep ScriptParameterKeyValue x
Prelude.Generic)

-- |
-- Create a value of 'ScriptParameterKeyValue' 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', 'scriptParameterKeyValue_key' - A script parameter key.
--
-- 'value', 'scriptParameterKeyValue_value' - A script parameter value.
newScriptParameterKeyValue ::
  ScriptParameterKeyValue
newScriptParameterKeyValue :: ScriptParameterKeyValue
newScriptParameterKeyValue =
  ScriptParameterKeyValue'
    { $sel:key:ScriptParameterKeyValue' :: Maybe Text
key = forall a. Maybe a
Prelude.Nothing,
      $sel:value:ScriptParameterKeyValue' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | A script parameter key.
scriptParameterKeyValue_key :: Lens.Lens' ScriptParameterKeyValue (Prelude.Maybe Prelude.Text)
scriptParameterKeyValue_key :: Lens' ScriptParameterKeyValue (Maybe Text)
scriptParameterKeyValue_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScriptParameterKeyValue' {Maybe Text
key :: Maybe Text
$sel:key:ScriptParameterKeyValue' :: ScriptParameterKeyValue -> Maybe Text
key} -> Maybe Text
key) (\s :: ScriptParameterKeyValue
s@ScriptParameterKeyValue' {} Maybe Text
a -> ScriptParameterKeyValue
s {$sel:key:ScriptParameterKeyValue' :: Maybe Text
key = Maybe Text
a} :: ScriptParameterKeyValue)

-- | A script parameter value.
scriptParameterKeyValue_value :: Lens.Lens' ScriptParameterKeyValue (Prelude.Maybe Prelude.Text)
scriptParameterKeyValue_value :: Lens' ScriptParameterKeyValue (Maybe Text)
scriptParameterKeyValue_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScriptParameterKeyValue' {Maybe Text
value :: Maybe Text
$sel:value:ScriptParameterKeyValue' :: ScriptParameterKeyValue -> Maybe Text
value} -> Maybe Text
value) (\s :: ScriptParameterKeyValue
s@ScriptParameterKeyValue' {} Maybe Text
a -> ScriptParameterKeyValue
s {$sel:value:ScriptParameterKeyValue' :: Maybe Text
value = Maybe Text
a} :: ScriptParameterKeyValue)

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

instance Prelude.Hashable ScriptParameterKeyValue where
  hashWithSalt :: Int -> ScriptParameterKeyValue -> Int
hashWithSalt Int
_salt ScriptParameterKeyValue' {Maybe Text
value :: Maybe Text
key :: Maybe Text
$sel:value:ScriptParameterKeyValue' :: ScriptParameterKeyValue -> Maybe Text
$sel:key:ScriptParameterKeyValue' :: ScriptParameterKeyValue -> 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 Text
value

instance Prelude.NFData ScriptParameterKeyValue where
  rnf :: ScriptParameterKeyValue -> ()
rnf ScriptParameterKeyValue' {Maybe Text
value :: Maybe Text
key :: Maybe Text
$sel:value:ScriptParameterKeyValue' :: ScriptParameterKeyValue -> Maybe Text
$sel:key:ScriptParameterKeyValue' :: ScriptParameterKeyValue -> 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 Text
value

instance Data.ToJSON ScriptParameterKeyValue where
  toJSON :: ScriptParameterKeyValue -> Value
toJSON ScriptParameterKeyValue' {Maybe Text
value :: Maybe Text
key :: Maybe Text
$sel:value:ScriptParameterKeyValue' :: ScriptParameterKeyValue -> Maybe Text
$sel:key:ScriptParameterKeyValue' :: ScriptParameterKeyValue -> 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
"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
          ]
      )