{-# 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.MechanicalTurk.Types.HITLayoutParameter
-- 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.MechanicalTurk.Types.HITLayoutParameter where

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

-- | The HITLayoutParameter data structure defines parameter values used with
-- a HITLayout. A HITLayout is a reusable Amazon Mechanical Turk project
-- template used to provide Human Intelligence Task (HIT) question data for
-- CreateHIT.
--
-- /See:/ 'newHITLayoutParameter' smart constructor.
data HITLayoutParameter = HITLayoutParameter'
  { -- | The name of the parameter in the HITLayout.
    HITLayoutParameter -> Text
name :: Prelude.Text,
    -- | The value substituted for the parameter referenced in the HITLayout.
    HITLayoutParameter -> Text
value :: Prelude.Text
  }
  deriving (HITLayoutParameter -> HITLayoutParameter -> Bool
(HITLayoutParameter -> HITLayoutParameter -> Bool)
-> (HITLayoutParameter -> HITLayoutParameter -> Bool)
-> Eq HITLayoutParameter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HITLayoutParameter -> HITLayoutParameter -> Bool
$c/= :: HITLayoutParameter -> HITLayoutParameter -> Bool
== :: HITLayoutParameter -> HITLayoutParameter -> Bool
$c== :: HITLayoutParameter -> HITLayoutParameter -> Bool
Prelude.Eq, ReadPrec [HITLayoutParameter]
ReadPrec HITLayoutParameter
Int -> ReadS HITLayoutParameter
ReadS [HITLayoutParameter]
(Int -> ReadS HITLayoutParameter)
-> ReadS [HITLayoutParameter]
-> ReadPrec HITLayoutParameter
-> ReadPrec [HITLayoutParameter]
-> Read HITLayoutParameter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HITLayoutParameter]
$creadListPrec :: ReadPrec [HITLayoutParameter]
readPrec :: ReadPrec HITLayoutParameter
$creadPrec :: ReadPrec HITLayoutParameter
readList :: ReadS [HITLayoutParameter]
$creadList :: ReadS [HITLayoutParameter]
readsPrec :: Int -> ReadS HITLayoutParameter
$creadsPrec :: Int -> ReadS HITLayoutParameter
Prelude.Read, Int -> HITLayoutParameter -> ShowS
[HITLayoutParameter] -> ShowS
HITLayoutParameter -> String
(Int -> HITLayoutParameter -> ShowS)
-> (HITLayoutParameter -> String)
-> ([HITLayoutParameter] -> ShowS)
-> Show HITLayoutParameter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HITLayoutParameter] -> ShowS
$cshowList :: [HITLayoutParameter] -> ShowS
show :: HITLayoutParameter -> String
$cshow :: HITLayoutParameter -> String
showsPrec :: Int -> HITLayoutParameter -> ShowS
$cshowsPrec :: Int -> HITLayoutParameter -> ShowS
Prelude.Show, (forall x. HITLayoutParameter -> Rep HITLayoutParameter x)
-> (forall x. Rep HITLayoutParameter x -> HITLayoutParameter)
-> Generic HITLayoutParameter
forall x. Rep HITLayoutParameter x -> HITLayoutParameter
forall x. HITLayoutParameter -> Rep HITLayoutParameter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HITLayoutParameter x -> HITLayoutParameter
$cfrom :: forall x. HITLayoutParameter -> Rep HITLayoutParameter x
Prelude.Generic)

-- |
-- Create a value of 'HITLayoutParameter' 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:
--
-- 'name', 'hITLayoutParameter_name' - The name of the parameter in the HITLayout.
--
-- 'value', 'hITLayoutParameter_value' - The value substituted for the parameter referenced in the HITLayout.
newHITLayoutParameter ::
  -- | 'name'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  HITLayoutParameter
newHITLayoutParameter :: Text -> Text -> HITLayoutParameter
newHITLayoutParameter Text
pName_ Text
pValue_ =
  HITLayoutParameter' :: Text -> Text -> HITLayoutParameter
HITLayoutParameter' {$sel:name:HITLayoutParameter' :: Text
name = Text
pName_, $sel:value:HITLayoutParameter' :: Text
value = Text
pValue_}

-- | The name of the parameter in the HITLayout.
hITLayoutParameter_name :: Lens.Lens' HITLayoutParameter Prelude.Text
hITLayoutParameter_name :: (Text -> f Text) -> HITLayoutParameter -> f HITLayoutParameter
hITLayoutParameter_name = (HITLayoutParameter -> Text)
-> (HITLayoutParameter -> Text -> HITLayoutParameter)
-> Lens HITLayoutParameter HITLayoutParameter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HITLayoutParameter' {Text
name :: Text
$sel:name:HITLayoutParameter' :: HITLayoutParameter -> Text
name} -> Text
name) (\s :: HITLayoutParameter
s@HITLayoutParameter' {} Text
a -> HITLayoutParameter
s {$sel:name:HITLayoutParameter' :: Text
name = Text
a} :: HITLayoutParameter)

-- | The value substituted for the parameter referenced in the HITLayout.
hITLayoutParameter_value :: Lens.Lens' HITLayoutParameter Prelude.Text
hITLayoutParameter_value :: (Text -> f Text) -> HITLayoutParameter -> f HITLayoutParameter
hITLayoutParameter_value = (HITLayoutParameter -> Text)
-> (HITLayoutParameter -> Text -> HITLayoutParameter)
-> Lens HITLayoutParameter HITLayoutParameter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HITLayoutParameter' {Text
value :: Text
$sel:value:HITLayoutParameter' :: HITLayoutParameter -> Text
value} -> Text
value) (\s :: HITLayoutParameter
s@HITLayoutParameter' {} Text
a -> HITLayoutParameter
s {$sel:value:HITLayoutParameter' :: Text
value = Text
a} :: HITLayoutParameter)

instance Prelude.Hashable HITLayoutParameter

instance Prelude.NFData HITLayoutParameter

instance Core.ToJSON HITLayoutParameter where
  toJSON :: HITLayoutParameter -> Value
toJSON HITLayoutParameter' {Text
value :: Text
name :: Text
$sel:value:HITLayoutParameter' :: HITLayoutParameter -> Text
$sel:name:HITLayoutParameter' :: HITLayoutParameter -> 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
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Value" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
value)
          ]
      )