{-# 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-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.DataPipeline.Types.ParameterAttribute where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ParameterAttribute -> ParameterAttribute -> Bool)
-> (ParameterAttribute -> ParameterAttribute -> Bool)
-> Eq ParameterAttribute
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]
(Int -> ReadS ParameterAttribute)
-> ReadS [ParameterAttribute]
-> ReadPrec ParameterAttribute
-> ReadPrec [ParameterAttribute]
-> Read 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
(Int -> ParameterAttribute -> ShowS)
-> (ParameterAttribute -> String)
-> ([ParameterAttribute] -> ShowS)
-> Show ParameterAttribute
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. ParameterAttribute -> Rep ParameterAttribute x)
-> (forall x. Rep ParameterAttribute x -> ParameterAttribute)
-> Generic ParameterAttribute
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' :: Text -> Text -> ParameterAttribute
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 :: (Text -> f Text) -> ParameterAttribute -> f ParameterAttribute
parameterAttribute_key = (ParameterAttribute -> Text)
-> (ParameterAttribute -> Text -> ParameterAttribute)
-> Lens ParameterAttribute ParameterAttribute Text Text
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 :: (Text -> f Text) -> ParameterAttribute -> f ParameterAttribute
parameterAttribute_stringValue = (ParameterAttribute -> Text)
-> (ParameterAttribute -> Text -> ParameterAttribute)
-> Lens ParameterAttribute ParameterAttribute Text Text
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 Core.FromJSON ParameterAttribute where
  parseJSON :: Value -> Parser ParameterAttribute
parseJSON =
    String
-> (Object -> Parser ParameterAttribute)
-> Value
-> Parser ParameterAttribute
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ParameterAttribute"
      ( \Object
x ->
          Text -> Text -> ParameterAttribute
ParameterAttribute'
            (Text -> Text -> ParameterAttribute)
-> Parser Text -> Parser (Text -> ParameterAttribute)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"key")
            Parser (Text -> ParameterAttribute)
-> Parser Text -> Parser ParameterAttribute
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"stringValue")
      )

instance Prelude.Hashable ParameterAttribute

instance Prelude.NFData ParameterAttribute

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
key),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"stringValue" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
stringValue)
          ]
      )