{-# 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.IoTFleetWise.Types.Actuator
-- 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.IoTFleetWise.Types.Actuator where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTFleetWise.Types.NodeDataType
import qualified Amazonka.Prelude as Prelude

-- | A signal that represents a vehicle device such as the engine, heater,
-- and door locks. Data from an actuator reports the state of a certain
-- vehicle device.
--
-- Updating actuator data can change the state of a device. For example,
-- you can turn on or off the heater by updating its actuator data.
--
-- /See:/ 'newActuator' smart constructor.
data Actuator = Actuator'
  { -- | A list of possible values an actuator can take.
    Actuator -> Maybe [Text]
allowedValues :: Prelude.Maybe [Prelude.Text],
    -- | A specified value for the actuator.
    Actuator -> Maybe Text
assignedValue :: Prelude.Maybe Prelude.Text,
    -- | A brief description of the actuator.
    Actuator -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The specified possible maximum value of an actuator.
    Actuator -> Maybe Double
max :: Prelude.Maybe Prelude.Double,
    -- | The specified possible minimum value of an actuator.
    Actuator -> Maybe Double
min :: Prelude.Maybe Prelude.Double,
    -- | The scientific unit for the actuator.
    Actuator -> Maybe Text
unit :: Prelude.Maybe Prelude.Text,
    -- | The fully qualified name of the actuator. For example, the fully
    -- qualified name of an actuator might be @Vehicle.Front.Left.Door.Lock@.
    Actuator -> Text
fullyQualifiedName :: Prelude.Text,
    -- | The specified data type of the actuator.
    Actuator -> NodeDataType
dataType :: NodeDataType
  }
  deriving (Actuator -> Actuator -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Actuator -> Actuator -> Bool
$c/= :: Actuator -> Actuator -> Bool
== :: Actuator -> Actuator -> Bool
$c== :: Actuator -> Actuator -> Bool
Prelude.Eq, ReadPrec [Actuator]
ReadPrec Actuator
Int -> ReadS Actuator
ReadS [Actuator]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Actuator]
$creadListPrec :: ReadPrec [Actuator]
readPrec :: ReadPrec Actuator
$creadPrec :: ReadPrec Actuator
readList :: ReadS [Actuator]
$creadList :: ReadS [Actuator]
readsPrec :: Int -> ReadS Actuator
$creadsPrec :: Int -> ReadS Actuator
Prelude.Read, Int -> Actuator -> ShowS
[Actuator] -> ShowS
Actuator -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Actuator] -> ShowS
$cshowList :: [Actuator] -> ShowS
show :: Actuator -> String
$cshow :: Actuator -> String
showsPrec :: Int -> Actuator -> ShowS
$cshowsPrec :: Int -> Actuator -> ShowS
Prelude.Show, forall x. Rep Actuator x -> Actuator
forall x. Actuator -> Rep Actuator x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Actuator x -> Actuator
$cfrom :: forall x. Actuator -> Rep Actuator x
Prelude.Generic)

-- |
-- Create a value of 'Actuator' 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:
--
-- 'allowedValues', 'actuator_allowedValues' - A list of possible values an actuator can take.
--
-- 'assignedValue', 'actuator_assignedValue' - A specified value for the actuator.
--
-- 'description', 'actuator_description' - A brief description of the actuator.
--
-- 'max', 'actuator_max' - The specified possible maximum value of an actuator.
--
-- 'min', 'actuator_min' - The specified possible minimum value of an actuator.
--
-- 'unit', 'actuator_unit' - The scientific unit for the actuator.
--
-- 'fullyQualifiedName', 'actuator_fullyQualifiedName' - The fully qualified name of the actuator. For example, the fully
-- qualified name of an actuator might be @Vehicle.Front.Left.Door.Lock@.
--
-- 'dataType', 'actuator_dataType' - The specified data type of the actuator.
newActuator ::
  -- | 'fullyQualifiedName'
  Prelude.Text ->
  -- | 'dataType'
  NodeDataType ->
  Actuator
newActuator :: Text -> NodeDataType -> Actuator
newActuator Text
pFullyQualifiedName_ NodeDataType
pDataType_ =
  Actuator'
    { $sel:allowedValues:Actuator' :: Maybe [Text]
allowedValues = forall a. Maybe a
Prelude.Nothing,
      $sel:assignedValue:Actuator' :: Maybe Text
assignedValue = forall a. Maybe a
Prelude.Nothing,
      $sel:description:Actuator' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:max:Actuator' :: Maybe Double
max = forall a. Maybe a
Prelude.Nothing,
      $sel:min:Actuator' :: Maybe Double
min = forall a. Maybe a
Prelude.Nothing,
      $sel:unit:Actuator' :: Maybe Text
unit = forall a. Maybe a
Prelude.Nothing,
      $sel:fullyQualifiedName:Actuator' :: Text
fullyQualifiedName = Text
pFullyQualifiedName_,
      $sel:dataType:Actuator' :: NodeDataType
dataType = NodeDataType
pDataType_
    }

-- | A list of possible values an actuator can take.
actuator_allowedValues :: Lens.Lens' Actuator (Prelude.Maybe [Prelude.Text])
actuator_allowedValues :: Lens' Actuator (Maybe [Text])
actuator_allowedValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Actuator' {Maybe [Text]
allowedValues :: Maybe [Text]
$sel:allowedValues:Actuator' :: Actuator -> Maybe [Text]
allowedValues} -> Maybe [Text]
allowedValues) (\s :: Actuator
s@Actuator' {} Maybe [Text]
a -> Actuator
s {$sel:allowedValues:Actuator' :: Maybe [Text]
allowedValues = Maybe [Text]
a} :: Actuator) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A specified value for the actuator.
actuator_assignedValue :: Lens.Lens' Actuator (Prelude.Maybe Prelude.Text)
actuator_assignedValue :: Lens' Actuator (Maybe Text)
actuator_assignedValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Actuator' {Maybe Text
assignedValue :: Maybe Text
$sel:assignedValue:Actuator' :: Actuator -> Maybe Text
assignedValue} -> Maybe Text
assignedValue) (\s :: Actuator
s@Actuator' {} Maybe Text
a -> Actuator
s {$sel:assignedValue:Actuator' :: Maybe Text
assignedValue = Maybe Text
a} :: Actuator)

-- | A brief description of the actuator.
actuator_description :: Lens.Lens' Actuator (Prelude.Maybe Prelude.Text)
actuator_description :: Lens' Actuator (Maybe Text)
actuator_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Actuator' {Maybe Text
description :: Maybe Text
$sel:description:Actuator' :: Actuator -> Maybe Text
description} -> Maybe Text
description) (\s :: Actuator
s@Actuator' {} Maybe Text
a -> Actuator
s {$sel:description:Actuator' :: Maybe Text
description = Maybe Text
a} :: Actuator)

-- | The specified possible maximum value of an actuator.
actuator_max :: Lens.Lens' Actuator (Prelude.Maybe Prelude.Double)
actuator_max :: Lens' Actuator (Maybe Double)
actuator_max = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Actuator' {Maybe Double
max :: Maybe Double
$sel:max:Actuator' :: Actuator -> Maybe Double
max} -> Maybe Double
max) (\s :: Actuator
s@Actuator' {} Maybe Double
a -> Actuator
s {$sel:max:Actuator' :: Maybe Double
max = Maybe Double
a} :: Actuator)

-- | The specified possible minimum value of an actuator.
actuator_min :: Lens.Lens' Actuator (Prelude.Maybe Prelude.Double)
actuator_min :: Lens' Actuator (Maybe Double)
actuator_min = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Actuator' {Maybe Double
min :: Maybe Double
$sel:min:Actuator' :: Actuator -> Maybe Double
min} -> Maybe Double
min) (\s :: Actuator
s@Actuator' {} Maybe Double
a -> Actuator
s {$sel:min:Actuator' :: Maybe Double
min = Maybe Double
a} :: Actuator)

-- | The scientific unit for the actuator.
actuator_unit :: Lens.Lens' Actuator (Prelude.Maybe Prelude.Text)
actuator_unit :: Lens' Actuator (Maybe Text)
actuator_unit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Actuator' {Maybe Text
unit :: Maybe Text
$sel:unit:Actuator' :: Actuator -> Maybe Text
unit} -> Maybe Text
unit) (\s :: Actuator
s@Actuator' {} Maybe Text
a -> Actuator
s {$sel:unit:Actuator' :: Maybe Text
unit = Maybe Text
a} :: Actuator)

-- | The fully qualified name of the actuator. For example, the fully
-- qualified name of an actuator might be @Vehicle.Front.Left.Door.Lock@.
actuator_fullyQualifiedName :: Lens.Lens' Actuator Prelude.Text
actuator_fullyQualifiedName :: Lens' Actuator Text
actuator_fullyQualifiedName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Actuator' {Text
fullyQualifiedName :: Text
$sel:fullyQualifiedName:Actuator' :: Actuator -> Text
fullyQualifiedName} -> Text
fullyQualifiedName) (\s :: Actuator
s@Actuator' {} Text
a -> Actuator
s {$sel:fullyQualifiedName:Actuator' :: Text
fullyQualifiedName = Text
a} :: Actuator)

-- | The specified data type of the actuator.
actuator_dataType :: Lens.Lens' Actuator NodeDataType
actuator_dataType :: Lens' Actuator NodeDataType
actuator_dataType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Actuator' {NodeDataType
dataType :: NodeDataType
$sel:dataType:Actuator' :: Actuator -> NodeDataType
dataType} -> NodeDataType
dataType) (\s :: Actuator
s@Actuator' {} NodeDataType
a -> Actuator
s {$sel:dataType:Actuator' :: NodeDataType
dataType = NodeDataType
a} :: Actuator)

instance Data.FromJSON Actuator where
  parseJSON :: Value -> Parser Actuator
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Actuator"
      ( \Object
x ->
          Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Double
-> Maybe Double
-> Maybe Text
-> Text
-> NodeDataType
-> Actuator
Actuator'
            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
"allowedValues" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"assignedValue")
            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
"description")
            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
"max")
            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
"min")
            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
"unit")
            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
"fullyQualifiedName")
            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
"dataType")
      )

instance Prelude.Hashable Actuator where
  hashWithSalt :: Int -> Actuator -> Int
hashWithSalt Int
_salt Actuator' {Maybe Double
Maybe [Text]
Maybe Text
Text
NodeDataType
dataType :: NodeDataType
fullyQualifiedName :: Text
unit :: Maybe Text
min :: Maybe Double
max :: Maybe Double
description :: Maybe Text
assignedValue :: Maybe Text
allowedValues :: Maybe [Text]
$sel:dataType:Actuator' :: Actuator -> NodeDataType
$sel:fullyQualifiedName:Actuator' :: Actuator -> Text
$sel:unit:Actuator' :: Actuator -> Maybe Text
$sel:min:Actuator' :: Actuator -> Maybe Double
$sel:max:Actuator' :: Actuator -> Maybe Double
$sel:description:Actuator' :: Actuator -> Maybe Text
$sel:assignedValue:Actuator' :: Actuator -> Maybe Text
$sel:allowedValues:Actuator' :: Actuator -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
allowedValues
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
assignedValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
max
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
min
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
unit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
fullyQualifiedName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NodeDataType
dataType

instance Prelude.NFData Actuator where
  rnf :: Actuator -> ()
rnf Actuator' {Maybe Double
Maybe [Text]
Maybe Text
Text
NodeDataType
dataType :: NodeDataType
fullyQualifiedName :: Text
unit :: Maybe Text
min :: Maybe Double
max :: Maybe Double
description :: Maybe Text
assignedValue :: Maybe Text
allowedValues :: Maybe [Text]
$sel:dataType:Actuator' :: Actuator -> NodeDataType
$sel:fullyQualifiedName:Actuator' :: Actuator -> Text
$sel:unit:Actuator' :: Actuator -> Maybe Text
$sel:min:Actuator' :: Actuator -> Maybe Double
$sel:max:Actuator' :: Actuator -> Maybe Double
$sel:description:Actuator' :: Actuator -> Maybe Text
$sel:assignedValue:Actuator' :: Actuator -> Maybe Text
$sel:allowedValues:Actuator' :: Actuator -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
allowedValues
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
assignedValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
max
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
min
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
unit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
fullyQualifiedName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NodeDataType
dataType

instance Data.ToJSON Actuator where
  toJSON :: Actuator -> Value
toJSON Actuator' {Maybe Double
Maybe [Text]
Maybe Text
Text
NodeDataType
dataType :: NodeDataType
fullyQualifiedName :: Text
unit :: Maybe Text
min :: Maybe Double
max :: Maybe Double
description :: Maybe Text
assignedValue :: Maybe Text
allowedValues :: Maybe [Text]
$sel:dataType:Actuator' :: Actuator -> NodeDataType
$sel:fullyQualifiedName:Actuator' :: Actuator -> Text
$sel:unit:Actuator' :: Actuator -> Maybe Text
$sel:min:Actuator' :: Actuator -> Maybe Double
$sel:max:Actuator' :: Actuator -> Maybe Double
$sel:description:Actuator' :: Actuator -> Maybe Text
$sel:assignedValue:Actuator' :: Actuator -> Maybe Text
$sel:allowedValues:Actuator' :: Actuator -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"allowedValues" 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]
allowedValues,
            (Key
"assignedValue" 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
assignedValue,
            (Key
"description" 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
description,
            (Key
"max" 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
max,
            (Key
"min" 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
min,
            (Key
"unit" 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
unit,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"fullyQualifiedName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
fullyQualifiedName),
            forall a. a -> Maybe a
Prelude.Just (Key
"dataType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NodeDataType
dataType)
          ]
      )