{-# 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.DataPipeline.Types.ParameterAttribute
-- 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.DataPipeline.Types.ParameterAttribute 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 attributes allowed or specified with a parameter object.
--
-- /See:/ 'newParameterAttribute' smart constructor.
data ParameterAttribute = ParameterAttribute'
  { -- | The field identifier.
    ParameterAttribute -> Text
key :: Prelude.Text,
    -- | The field value, expressed as a String.
    ParameterAttribute -> Text
stringValue :: Prelude.Text
  }
  deriving (ParameterAttribute -> ParameterAttribute -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ParameterAttribute -> ParameterAttribute -> Bool
$c/= :: ParameterAttribute -> ParameterAttribute -> Bool
== :: ParameterAttribute -> ParameterAttribute -> Bool
$c== :: ParameterAttribute -> ParameterAttribute -> Bool
Prelude.Eq, ReadPrec [ParameterAttribute]
ReadPrec ParameterAttribute
Int -> ReadS ParameterAttribute
ReadS [ParameterAttribute]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ParameterAttribute]
$creadListPrec :: ReadPrec [ParameterAttribute]
readPrec :: ReadPrec ParameterAttribute
$creadPrec :: ReadPrec ParameterAttribute
readList :: ReadS [ParameterAttribute]
$creadList :: ReadS [ParameterAttribute]
readsPrec :: Int -> ReadS ParameterAttribute
$creadsPrec :: Int -> ReadS ParameterAttribute
Prelude.Read, Int -> ParameterAttribute -> ShowS
[ParameterAttribute] -> ShowS
ParameterAttribute -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ParameterAttribute] -> ShowS
$cshowList :: [ParameterAttribute] -> ShowS
show :: ParameterAttribute -> String
$cshow :: ParameterAttribute -> String
showsPrec :: Int -> ParameterAttribute -> ShowS
$cshowsPrec :: Int -> ParameterAttribute -> ShowS
Prelude.Show, forall x. Rep ParameterAttribute x -> ParameterAttribute
forall x. ParameterAttribute -> Rep ParameterAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ParameterAttribute x -> ParameterAttribute
$cfrom :: forall x. ParameterAttribute -> Rep ParameterAttribute x
Prelude.Generic)

-- |
-- Create a value of 'ParameterAttribute' 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', 'parameterAttribute_key' - The field identifier.
--
-- 'stringValue', 'parameterAttribute_stringValue' - The field value, expressed as a String.
newParameterAttribute ::
  -- | 'key'
  Prelude.Text ->
  -- | 'stringValue'
  Prelude.Text ->
  ParameterAttribute
newParameterAttribute :: Text -> Text -> ParameterAttribute
newParameterAttribute Text
pKey_ Text
pStringValue_ =
  ParameterAttribute'
    { $sel:key:ParameterAttribute' :: Text
key = Text
pKey_,
      $sel:stringValue:ParameterAttribute' :: Text
stringValue = Text
pStringValue_
    }

-- | The field identifier.
parameterAttribute_key :: Lens.Lens' ParameterAttribute Prelude.Text
parameterAttribute_key :: Lens' ParameterAttribute Text
parameterAttribute_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterAttribute' {Text
key :: Text
$sel:key:ParameterAttribute' :: ParameterAttribute -> Text
key} -> Text
key) (\s :: ParameterAttribute
s@ParameterAttribute' {} Text
a -> ParameterAttribute
s {$sel:key:ParameterAttribute' :: Text
key = Text
a} :: ParameterAttribute)

-- | The field value, expressed as a String.
parameterAttribute_stringValue :: Lens.Lens' ParameterAttribute Prelude.Text
parameterAttribute_stringValue :: Lens' ParameterAttribute Text
parameterAttribute_stringValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterAttribute' {Text
stringValue :: Text
$sel:stringValue:ParameterAttribute' :: ParameterAttribute -> Text
stringValue} -> Text
stringValue) (\s :: ParameterAttribute
s@ParameterAttribute' {} Text
a -> ParameterAttribute
s {$sel:stringValue:ParameterAttribute' :: Text
stringValue = Text
a} :: ParameterAttribute)

instance Data.FromJSON ParameterAttribute where
  parseJSON :: Value -> Parser ParameterAttribute
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ParameterAttribute"
      ( \Object
x ->
          Text -> Text -> ParameterAttribute
ParameterAttribute'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser 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 a
Data..: Key
"stringValue")
      )

instance Prelude.Hashable ParameterAttribute where
  hashWithSalt :: Int -> ParameterAttribute -> Int
hashWithSalt Int
_salt ParameterAttribute' {Text
stringValue :: Text
key :: Text
$sel:stringValue:ParameterAttribute' :: ParameterAttribute -> Text
$sel:key:ParameterAttribute' :: ParameterAttribute -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
stringValue

instance Prelude.NFData ParameterAttribute where
  rnf :: ParameterAttribute -> ()
rnf ParameterAttribute' {Text
stringValue :: Text
key :: Text
$sel:stringValue:ParameterAttribute' :: ParameterAttribute -> Text
$sel:key:ParameterAttribute' :: ParameterAttribute -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
key
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
stringValue

instance Data.ToJSON ParameterAttribute where
  toJSON :: ParameterAttribute -> Value
toJSON ParameterAttribute' {Text
stringValue :: Text
key :: Text
$sel:stringValue:ParameterAttribute' :: ParameterAttribute -> Text
$sel:key:ParameterAttribute' :: ParameterAttribute -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
key),
            forall a. a -> Maybe a
Prelude.Just (Key
"stringValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
stringValue)
          ]
      )