{-# 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.ParameterValue
-- 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.ParameterValue where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A value or list of parameter values.
--
-- /See:/ 'newParameterValue' smart constructor.
data ParameterValue = ParameterValue'
  { -- | The ID of the parameter value.
    ParameterValue -> Text
id :: Prelude.Text,
    -- | The field value, expressed as a String.
    ParameterValue -> Text
stringValue :: Prelude.Text
  }
  deriving (ParameterValue -> ParameterValue -> Bool
(ParameterValue -> ParameterValue -> Bool)
-> (ParameterValue -> ParameterValue -> Bool) -> Eq ParameterValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ParameterValue -> ParameterValue -> Bool
$c/= :: ParameterValue -> ParameterValue -> Bool
== :: ParameterValue -> ParameterValue -> Bool
$c== :: ParameterValue -> ParameterValue -> Bool
Prelude.Eq, ReadPrec [ParameterValue]
ReadPrec ParameterValue
Int -> ReadS ParameterValue
ReadS [ParameterValue]
(Int -> ReadS ParameterValue)
-> ReadS [ParameterValue]
-> ReadPrec ParameterValue
-> ReadPrec [ParameterValue]
-> Read ParameterValue
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ParameterValue]
$creadListPrec :: ReadPrec [ParameterValue]
readPrec :: ReadPrec ParameterValue
$creadPrec :: ReadPrec ParameterValue
readList :: ReadS [ParameterValue]
$creadList :: ReadS [ParameterValue]
readsPrec :: Int -> ReadS ParameterValue
$creadsPrec :: Int -> ReadS ParameterValue
Prelude.Read, Int -> ParameterValue -> ShowS
[ParameterValue] -> ShowS
ParameterValue -> String
(Int -> ParameterValue -> ShowS)
-> (ParameterValue -> String)
-> ([ParameterValue] -> ShowS)
-> Show ParameterValue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ParameterValue] -> ShowS
$cshowList :: [ParameterValue] -> ShowS
show :: ParameterValue -> String
$cshow :: ParameterValue -> String
showsPrec :: Int -> ParameterValue -> ShowS
$cshowsPrec :: Int -> ParameterValue -> ShowS
Prelude.Show, (forall x. ParameterValue -> Rep ParameterValue x)
-> (forall x. Rep ParameterValue x -> ParameterValue)
-> Generic ParameterValue
forall x. Rep ParameterValue x -> ParameterValue
forall x. ParameterValue -> Rep ParameterValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ParameterValue x -> ParameterValue
$cfrom :: forall x. ParameterValue -> Rep ParameterValue x
Prelude.Generic)

-- |
-- Create a value of 'ParameterValue' 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:
--
-- 'id', 'parameterValue_id' - The ID of the parameter value.
--
-- 'stringValue', 'parameterValue_stringValue' - The field value, expressed as a String.
newParameterValue ::
  -- | 'id'
  Prelude.Text ->
  -- | 'stringValue'
  Prelude.Text ->
  ParameterValue
newParameterValue :: Text -> Text -> ParameterValue
newParameterValue Text
pId_ Text
pStringValue_ =
  ParameterValue' :: Text -> Text -> ParameterValue
ParameterValue'
    { $sel:id:ParameterValue' :: Text
id = Text
pId_,
      $sel:stringValue:ParameterValue' :: Text
stringValue = Text
pStringValue_
    }

-- | The ID of the parameter value.
parameterValue_id :: Lens.Lens' ParameterValue Prelude.Text
parameterValue_id :: (Text -> f Text) -> ParameterValue -> f ParameterValue
parameterValue_id = (ParameterValue -> Text)
-> (ParameterValue -> Text -> ParameterValue)
-> Lens ParameterValue ParameterValue Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterValue' {Text
id :: Text
$sel:id:ParameterValue' :: ParameterValue -> Text
id} -> Text
id) (\s :: ParameterValue
s@ParameterValue' {} Text
a -> ParameterValue
s {$sel:id:ParameterValue' :: Text
id = Text
a} :: ParameterValue)

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

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

instance Prelude.NFData ParameterValue

instance Core.ToJSON ParameterValue where
  toJSON :: ParameterValue -> Value
toJSON ParameterValue' {Text
stringValue :: Text
id :: Text
$sel:stringValue:ParameterValue' :: ParameterValue -> Text
$sel:id:ParameterValue' :: ParameterValue -> 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
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id),
            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)
          ]
      )