{-# 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.IoTEventsData.Types.VariableDefinition
-- 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.IoTEventsData.Types.VariableDefinition where

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

-- | The new value of the variable.
--
-- /See:/ 'newVariableDefinition' smart constructor.
data VariableDefinition = VariableDefinition'
  { -- | The name of the variable.
    VariableDefinition -> Text
name :: Prelude.Text,
    -- | The new value of the variable.
    VariableDefinition -> Text
value :: Prelude.Text
  }
  deriving (VariableDefinition -> VariableDefinition -> Bool
(VariableDefinition -> VariableDefinition -> Bool)
-> (VariableDefinition -> VariableDefinition -> Bool)
-> Eq VariableDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VariableDefinition -> VariableDefinition -> Bool
$c/= :: VariableDefinition -> VariableDefinition -> Bool
== :: VariableDefinition -> VariableDefinition -> Bool
$c== :: VariableDefinition -> VariableDefinition -> Bool
Prelude.Eq, ReadPrec [VariableDefinition]
ReadPrec VariableDefinition
Int -> ReadS VariableDefinition
ReadS [VariableDefinition]
(Int -> ReadS VariableDefinition)
-> ReadS [VariableDefinition]
-> ReadPrec VariableDefinition
-> ReadPrec [VariableDefinition]
-> Read VariableDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VariableDefinition]
$creadListPrec :: ReadPrec [VariableDefinition]
readPrec :: ReadPrec VariableDefinition
$creadPrec :: ReadPrec VariableDefinition
readList :: ReadS [VariableDefinition]
$creadList :: ReadS [VariableDefinition]
readsPrec :: Int -> ReadS VariableDefinition
$creadsPrec :: Int -> ReadS VariableDefinition
Prelude.Read, Int -> VariableDefinition -> ShowS
[VariableDefinition] -> ShowS
VariableDefinition -> String
(Int -> VariableDefinition -> ShowS)
-> (VariableDefinition -> String)
-> ([VariableDefinition] -> ShowS)
-> Show VariableDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VariableDefinition] -> ShowS
$cshowList :: [VariableDefinition] -> ShowS
show :: VariableDefinition -> String
$cshow :: VariableDefinition -> String
showsPrec :: Int -> VariableDefinition -> ShowS
$cshowsPrec :: Int -> VariableDefinition -> ShowS
Prelude.Show, (forall x. VariableDefinition -> Rep VariableDefinition x)
-> (forall x. Rep VariableDefinition x -> VariableDefinition)
-> Generic VariableDefinition
forall x. Rep VariableDefinition x -> VariableDefinition
forall x. VariableDefinition -> Rep VariableDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VariableDefinition x -> VariableDefinition
$cfrom :: forall x. VariableDefinition -> Rep VariableDefinition x
Prelude.Generic)

-- |
-- Create a value of 'VariableDefinition' 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', 'variableDefinition_name' - The name of the variable.
--
-- 'value', 'variableDefinition_value' - The new value of the variable.
newVariableDefinition ::
  -- | 'name'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  VariableDefinition
newVariableDefinition :: Text -> Text -> VariableDefinition
newVariableDefinition Text
pName_ Text
pValue_ =
  VariableDefinition' :: Text -> Text -> VariableDefinition
VariableDefinition' {$sel:name:VariableDefinition' :: Text
name = Text
pName_, $sel:value:VariableDefinition' :: Text
value = Text
pValue_}

-- | The name of the variable.
variableDefinition_name :: Lens.Lens' VariableDefinition Prelude.Text
variableDefinition_name :: (Text -> f Text) -> VariableDefinition -> f VariableDefinition
variableDefinition_name = (VariableDefinition -> Text)
-> (VariableDefinition -> Text -> VariableDefinition)
-> Lens VariableDefinition VariableDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VariableDefinition' {Text
name :: Text
$sel:name:VariableDefinition' :: VariableDefinition -> Text
name} -> Text
name) (\s :: VariableDefinition
s@VariableDefinition' {} Text
a -> VariableDefinition
s {$sel:name:VariableDefinition' :: Text
name = Text
a} :: VariableDefinition)

-- | The new value of the variable.
variableDefinition_value :: Lens.Lens' VariableDefinition Prelude.Text
variableDefinition_value :: (Text -> f Text) -> VariableDefinition -> f VariableDefinition
variableDefinition_value = (VariableDefinition -> Text)
-> (VariableDefinition -> Text -> VariableDefinition)
-> Lens VariableDefinition VariableDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VariableDefinition' {Text
value :: Text
$sel:value:VariableDefinition' :: VariableDefinition -> Text
value} -> Text
value) (\s :: VariableDefinition
s@VariableDefinition' {} Text
a -> VariableDefinition
s {$sel:value:VariableDefinition' :: Text
value = Text
a} :: VariableDefinition)

instance Prelude.Hashable VariableDefinition

instance Prelude.NFData VariableDefinition

instance Core.ToJSON VariableDefinition where
  toJSON :: VariableDefinition -> Value
toJSON VariableDefinition' {Text
value :: Text
name :: Text
$sel:value:VariableDefinition' :: VariableDefinition -> Text
$sel:name:VariableDefinition' :: VariableDefinition -> 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)
          ]
      )