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

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

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

-- |
-- Create a value of 'Variable' 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', 'variable_name' - The name of the variable.
--
-- 'value', 'variable_value' - The current value of the variable.
newVariable ::
  -- | 'name'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  Variable
newVariable :: Text -> Text -> Variable
newVariable Text
pName_ Text
pValue_ =
  Variable' :: Text -> Text -> Variable
Variable' {$sel:name:Variable' :: Text
name = Text
pName_, $sel:value:Variable' :: Text
value = Text
pValue_}

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

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

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

instance Prelude.Hashable Variable

instance Prelude.NFData Variable