{-# 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.IoTAnalytics.Types.Variable
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTAnalytics.Types.Variable where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTAnalytics.Types.DatasetContentVersionValue
import Amazonka.IoTAnalytics.Types.OutputFileUriValue
import qualified Amazonka.Prelude as Prelude

-- | An instance of a variable to be passed to the @containerAction@
-- execution. Each variable must have a name and a value given by one of
-- @stringValue@, @datasetContentVersionValue@, or @outputFileUriValue@.
--
-- /See:/ 'newVariable' smart constructor.
data Variable = Variable'
  { -- | The value of the variable as a structure that specifies a dataset
    -- content version.
    Variable -> Maybe DatasetContentVersionValue
datasetContentVersionValue :: Prelude.Maybe DatasetContentVersionValue,
    -- | The value of the variable as a double (numeric).
    Variable -> Maybe Double
doubleValue :: Prelude.Maybe Prelude.Double,
    -- | The value of the variable as a structure that specifies an output file
    -- URI.
    Variable -> Maybe OutputFileUriValue
outputFileUriValue :: Prelude.Maybe OutputFileUriValue,
    -- | The value of the variable as a string.
    Variable -> Maybe Text
stringValue :: Prelude.Maybe Prelude.Text,
    -- | The name of the variable.
    Variable -> Text
name :: Prelude.Text
  }
  deriving (Variable -> Variable -> Bool
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]
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
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. 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:
--
-- 'datasetContentVersionValue', 'variable_datasetContentVersionValue' - The value of the variable as a structure that specifies a dataset
-- content version.
--
-- 'doubleValue', 'variable_doubleValue' - The value of the variable as a double (numeric).
--
-- 'outputFileUriValue', 'variable_outputFileUriValue' - The value of the variable as a structure that specifies an output file
-- URI.
--
-- 'stringValue', 'variable_stringValue' - The value of the variable as a string.
--
-- 'name', 'variable_name' - The name of the variable.
newVariable ::
  -- | 'name'
  Prelude.Text ->
  Variable
newVariable :: Text -> Variable
newVariable Text
pName_ =
  Variable'
    { $sel:datasetContentVersionValue:Variable' :: Maybe DatasetContentVersionValue
datasetContentVersionValue =
        forall a. Maybe a
Prelude.Nothing,
      $sel:doubleValue:Variable' :: Maybe Double
doubleValue = forall a. Maybe a
Prelude.Nothing,
      $sel:outputFileUriValue:Variable' :: Maybe OutputFileUriValue
outputFileUriValue = forall a. Maybe a
Prelude.Nothing,
      $sel:stringValue:Variable' :: Maybe Text
stringValue = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Variable' :: Text
name = Text
pName_
    }

-- | The value of the variable as a structure that specifies a dataset
-- content version.
variable_datasetContentVersionValue :: Lens.Lens' Variable (Prelude.Maybe DatasetContentVersionValue)
variable_datasetContentVersionValue :: Lens' Variable (Maybe DatasetContentVersionValue)
variable_datasetContentVersionValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Variable' {Maybe DatasetContentVersionValue
datasetContentVersionValue :: Maybe DatasetContentVersionValue
$sel:datasetContentVersionValue:Variable' :: Variable -> Maybe DatasetContentVersionValue
datasetContentVersionValue} -> Maybe DatasetContentVersionValue
datasetContentVersionValue) (\s :: Variable
s@Variable' {} Maybe DatasetContentVersionValue
a -> Variable
s {$sel:datasetContentVersionValue:Variable' :: Maybe DatasetContentVersionValue
datasetContentVersionValue = Maybe DatasetContentVersionValue
a} :: Variable)

-- | The value of the variable as a double (numeric).
variable_doubleValue :: Lens.Lens' Variable (Prelude.Maybe Prelude.Double)
variable_doubleValue :: Lens' Variable (Maybe Double)
variable_doubleValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Variable' {Maybe Double
doubleValue :: Maybe Double
$sel:doubleValue:Variable' :: Variable -> Maybe Double
doubleValue} -> Maybe Double
doubleValue) (\s :: Variable
s@Variable' {} Maybe Double
a -> Variable
s {$sel:doubleValue:Variable' :: Maybe Double
doubleValue = Maybe Double
a} :: Variable)

-- | The value of the variable as a structure that specifies an output file
-- URI.
variable_outputFileUriValue :: Lens.Lens' Variable (Prelude.Maybe OutputFileUriValue)
variable_outputFileUriValue :: Lens' Variable (Maybe OutputFileUriValue)
variable_outputFileUriValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Variable' {Maybe OutputFileUriValue
outputFileUriValue :: Maybe OutputFileUriValue
$sel:outputFileUriValue:Variable' :: Variable -> Maybe OutputFileUriValue
outputFileUriValue} -> Maybe OutputFileUriValue
outputFileUriValue) (\s :: Variable
s@Variable' {} Maybe OutputFileUriValue
a -> Variable
s {$sel:outputFileUriValue:Variable' :: Maybe OutputFileUriValue
outputFileUriValue = Maybe OutputFileUriValue
a} :: Variable)

-- | The value of the variable as a string.
variable_stringValue :: Lens.Lens' Variable (Prelude.Maybe Prelude.Text)
variable_stringValue :: Lens' Variable (Maybe Text)
variable_stringValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Variable' {Maybe Text
stringValue :: Maybe Text
$sel:stringValue:Variable' :: Variable -> Maybe Text
stringValue} -> Maybe Text
stringValue) (\s :: Variable
s@Variable' {} Maybe Text
a -> Variable
s {$sel:stringValue:Variable' :: Maybe Text
stringValue = Maybe Text
a} :: Variable)

-- | The name of the variable.
variable_name :: Lens.Lens' Variable Prelude.Text
variable_name :: Lens' Variable Text
variable_name = 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)

instance Data.FromJSON Variable where
  parseJSON :: Value -> Parser Variable
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Variable"
      ( \Object
x ->
          Maybe DatasetContentVersionValue
-> Maybe Double
-> Maybe OutputFileUriValue
-> Maybe Text
-> Text
-> Variable
Variable'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"datasetContentVersionValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"doubleValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"outputFileUriValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"stringValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"name")
      )

instance Prelude.Hashable Variable where
  hashWithSalt :: Int -> Variable -> Int
hashWithSalt Int
_salt Variable' {Maybe Double
Maybe Text
Maybe DatasetContentVersionValue
Maybe OutputFileUriValue
Text
name :: Text
stringValue :: Maybe Text
outputFileUriValue :: Maybe OutputFileUriValue
doubleValue :: Maybe Double
datasetContentVersionValue :: Maybe DatasetContentVersionValue
$sel:name:Variable' :: Variable -> Text
$sel:stringValue:Variable' :: Variable -> Maybe Text
$sel:outputFileUriValue:Variable' :: Variable -> Maybe OutputFileUriValue
$sel:doubleValue:Variable' :: Variable -> Maybe Double
$sel:datasetContentVersionValue:Variable' :: Variable -> Maybe DatasetContentVersionValue
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DatasetContentVersionValue
datasetContentVersionValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
doubleValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe OutputFileUriValue
outputFileUriValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
stringValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData Variable where
  rnf :: Variable -> ()
rnf Variable' {Maybe Double
Maybe Text
Maybe DatasetContentVersionValue
Maybe OutputFileUriValue
Text
name :: Text
stringValue :: Maybe Text
outputFileUriValue :: Maybe OutputFileUriValue
doubleValue :: Maybe Double
datasetContentVersionValue :: Maybe DatasetContentVersionValue
$sel:name:Variable' :: Variable -> Text
$sel:stringValue:Variable' :: Variable -> Maybe Text
$sel:outputFileUriValue:Variable' :: Variable -> Maybe OutputFileUriValue
$sel:doubleValue:Variable' :: Variable -> Maybe Double
$sel:datasetContentVersionValue:Variable' :: Variable -> Maybe DatasetContentVersionValue
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DatasetContentVersionValue
datasetContentVersionValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
doubleValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe OutputFileUriValue
outputFileUriValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
stringValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToJSON Variable where
  toJSON :: Variable -> Value
toJSON Variable' {Maybe Double
Maybe Text
Maybe DatasetContentVersionValue
Maybe OutputFileUriValue
Text
name :: Text
stringValue :: Maybe Text
outputFileUriValue :: Maybe OutputFileUriValue
doubleValue :: Maybe Double
datasetContentVersionValue :: Maybe DatasetContentVersionValue
$sel:name:Variable' :: Variable -> Text
$sel:stringValue:Variable' :: Variable -> Maybe Text
$sel:outputFileUriValue:Variable' :: Variable -> Maybe OutputFileUriValue
$sel:doubleValue:Variable' :: Variable -> Maybe Double
$sel:datasetContentVersionValue:Variable' :: Variable -> Maybe DatasetContentVersionValue
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"datasetContentVersionValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DatasetContentVersionValue
datasetContentVersionValue,
            (Key
"doubleValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
doubleValue,
            (Key
"outputFileUriValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OutputFileUriValue
outputFileUriValue,
            (Key
"stringValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
stringValue,
            forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )