{-# 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.Attribute
-- 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.Attribute 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 static information about the vehicle, such as
-- engine type or manufacturing date.
--
-- /See:/ 'newAttribute' smart constructor.
data Attribute = Attribute'
  { -- | A list of possible values an attribute can be assigned.
    Attribute -> Maybe [Text]
allowedValues :: Prelude.Maybe [Prelude.Text],
    -- | A specified value for the attribute.
    Attribute -> Maybe Text
assignedValue :: Prelude.Maybe Prelude.Text,
    -- | The default value of the attribute.
    Attribute -> Maybe Text
defaultValue :: Prelude.Maybe Prelude.Text,
    -- | A brief description of the attribute.
    Attribute -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The specified possible maximum value of the attribute.
    Attribute -> Maybe Double
max :: Prelude.Maybe Prelude.Double,
    -- | The specified possible minimum value of the attribute.
    Attribute -> Maybe Double
min :: Prelude.Maybe Prelude.Double,
    -- | The scientific unit for the attribute.
    Attribute -> Maybe Text
unit :: Prelude.Maybe Prelude.Text,
    -- | The fully qualified name of the attribute. For example, the fully
    -- qualified name of an attribute might be @Vehicle.Body.Engine.Type@.
    Attribute -> Text
fullyQualifiedName :: Prelude.Text,
    -- | The specified data type of the attribute.
    Attribute -> NodeDataType
dataType :: NodeDataType
  }
  deriving (Attribute -> Attribute -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Attribute -> Attribute -> Bool
$c/= :: Attribute -> Attribute -> Bool
== :: Attribute -> Attribute -> Bool
$c== :: Attribute -> Attribute -> Bool
Prelude.Eq, ReadPrec [Attribute]
ReadPrec Attribute
Int -> ReadS Attribute
ReadS [Attribute]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Attribute]
$creadListPrec :: ReadPrec [Attribute]
readPrec :: ReadPrec Attribute
$creadPrec :: ReadPrec Attribute
readList :: ReadS [Attribute]
$creadList :: ReadS [Attribute]
readsPrec :: Int -> ReadS Attribute
$creadsPrec :: Int -> ReadS Attribute
Prelude.Read, Int -> Attribute -> ShowS
[Attribute] -> ShowS
Attribute -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Attribute] -> ShowS
$cshowList :: [Attribute] -> ShowS
show :: Attribute -> String
$cshow :: Attribute -> String
showsPrec :: Int -> Attribute -> ShowS
$cshowsPrec :: Int -> Attribute -> ShowS
Prelude.Show, forall x. Rep Attribute x -> Attribute
forall x. Attribute -> Rep Attribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Attribute x -> Attribute
$cfrom :: forall x. Attribute -> Rep Attribute x
Prelude.Generic)

-- |
-- Create a value of 'Attribute' 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', 'attribute_allowedValues' - A list of possible values an attribute can be assigned.
--
-- 'assignedValue', 'attribute_assignedValue' - A specified value for the attribute.
--
-- 'defaultValue', 'attribute_defaultValue' - The default value of the attribute.
--
-- 'description', 'attribute_description' - A brief description of the attribute.
--
-- 'max', 'attribute_max' - The specified possible maximum value of the attribute.
--
-- 'min', 'attribute_min' - The specified possible minimum value of the attribute.
--
-- 'unit', 'attribute_unit' - The scientific unit for the attribute.
--
-- 'fullyQualifiedName', 'attribute_fullyQualifiedName' - The fully qualified name of the attribute. For example, the fully
-- qualified name of an attribute might be @Vehicle.Body.Engine.Type@.
--
-- 'dataType', 'attribute_dataType' - The specified data type of the attribute.
newAttribute ::
  -- | 'fullyQualifiedName'
  Prelude.Text ->
  -- | 'dataType'
  NodeDataType ->
  Attribute
newAttribute :: Text -> NodeDataType -> Attribute
newAttribute Text
pFullyQualifiedName_ NodeDataType
pDataType_ =
  Attribute'
    { $sel:allowedValues:Attribute' :: Maybe [Text]
allowedValues = forall a. Maybe a
Prelude.Nothing,
      $sel:assignedValue:Attribute' :: Maybe Text
assignedValue = forall a. Maybe a
Prelude.Nothing,
      $sel:defaultValue:Attribute' :: Maybe Text
defaultValue = forall a. Maybe a
Prelude.Nothing,
      $sel:description:Attribute' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:max:Attribute' :: Maybe Double
max = forall a. Maybe a
Prelude.Nothing,
      $sel:min:Attribute' :: Maybe Double
min = forall a. Maybe a
Prelude.Nothing,
      $sel:unit:Attribute' :: Maybe Text
unit = forall a. Maybe a
Prelude.Nothing,
      $sel:fullyQualifiedName:Attribute' :: Text
fullyQualifiedName = Text
pFullyQualifiedName_,
      $sel:dataType:Attribute' :: NodeDataType
dataType = NodeDataType
pDataType_
    }

-- | A list of possible values an attribute can be assigned.
attribute_allowedValues :: Lens.Lens' Attribute (Prelude.Maybe [Prelude.Text])
attribute_allowedValues :: Lens' Attribute (Maybe [Text])
attribute_allowedValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Attribute' {Maybe [Text]
allowedValues :: Maybe [Text]
$sel:allowedValues:Attribute' :: Attribute -> Maybe [Text]
allowedValues} -> Maybe [Text]
allowedValues) (\s :: Attribute
s@Attribute' {} Maybe [Text]
a -> Attribute
s {$sel:allowedValues:Attribute' :: Maybe [Text]
allowedValues = Maybe [Text]
a} :: Attribute) 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 attribute.
attribute_assignedValue :: Lens.Lens' Attribute (Prelude.Maybe Prelude.Text)
attribute_assignedValue :: Lens' Attribute (Maybe Text)
attribute_assignedValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Attribute' {Maybe Text
assignedValue :: Maybe Text
$sel:assignedValue:Attribute' :: Attribute -> Maybe Text
assignedValue} -> Maybe Text
assignedValue) (\s :: Attribute
s@Attribute' {} Maybe Text
a -> Attribute
s {$sel:assignedValue:Attribute' :: Maybe Text
assignedValue = Maybe Text
a} :: Attribute)

-- | The default value of the attribute.
attribute_defaultValue :: Lens.Lens' Attribute (Prelude.Maybe Prelude.Text)
attribute_defaultValue :: Lens' Attribute (Maybe Text)
attribute_defaultValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Attribute' {Maybe Text
defaultValue :: Maybe Text
$sel:defaultValue:Attribute' :: Attribute -> Maybe Text
defaultValue} -> Maybe Text
defaultValue) (\s :: Attribute
s@Attribute' {} Maybe Text
a -> Attribute
s {$sel:defaultValue:Attribute' :: Maybe Text
defaultValue = Maybe Text
a} :: Attribute)

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

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

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

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

-- | The fully qualified name of the attribute. For example, the fully
-- qualified name of an attribute might be @Vehicle.Body.Engine.Type@.
attribute_fullyQualifiedName :: Lens.Lens' Attribute Prelude.Text
attribute_fullyQualifiedName :: Lens' Attribute Text
attribute_fullyQualifiedName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Attribute' {Text
fullyQualifiedName :: Text
$sel:fullyQualifiedName:Attribute' :: Attribute -> Text
fullyQualifiedName} -> Text
fullyQualifiedName) (\s :: Attribute
s@Attribute' {} Text
a -> Attribute
s {$sel:fullyQualifiedName:Attribute' :: Text
fullyQualifiedName = Text
a} :: Attribute)

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

instance Data.FromJSON Attribute where
  parseJSON :: Value -> Parser Attribute
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Attribute"
      ( \Object
x ->
          Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Double
-> Maybe Double
-> Maybe Text
-> Text
-> NodeDataType
-> Attribute
Attribute'
            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
"defaultValue")
            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 Attribute where
  hashWithSalt :: Int -> Attribute -> Int
hashWithSalt Int
_salt Attribute' {Maybe Double
Maybe [Text]
Maybe Text
Text
NodeDataType
dataType :: NodeDataType
fullyQualifiedName :: Text
unit :: Maybe Text
min :: Maybe Double
max :: Maybe Double
description :: Maybe Text
defaultValue :: Maybe Text
assignedValue :: Maybe Text
allowedValues :: Maybe [Text]
$sel:dataType:Attribute' :: Attribute -> NodeDataType
$sel:fullyQualifiedName:Attribute' :: Attribute -> Text
$sel:unit:Attribute' :: Attribute -> Maybe Text
$sel:min:Attribute' :: Attribute -> Maybe Double
$sel:max:Attribute' :: Attribute -> Maybe Double
$sel:description:Attribute' :: Attribute -> Maybe Text
$sel:defaultValue:Attribute' :: Attribute -> Maybe Text
$sel:assignedValue:Attribute' :: Attribute -> Maybe Text
$sel:allowedValues:Attribute' :: Attribute -> 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
defaultValue
      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 Attribute where
  rnf :: Attribute -> ()
rnf Attribute' {Maybe Double
Maybe [Text]
Maybe Text
Text
NodeDataType
dataType :: NodeDataType
fullyQualifiedName :: Text
unit :: Maybe Text
min :: Maybe Double
max :: Maybe Double
description :: Maybe Text
defaultValue :: Maybe Text
assignedValue :: Maybe Text
allowedValues :: Maybe [Text]
$sel:dataType:Attribute' :: Attribute -> NodeDataType
$sel:fullyQualifiedName:Attribute' :: Attribute -> Text
$sel:unit:Attribute' :: Attribute -> Maybe Text
$sel:min:Attribute' :: Attribute -> Maybe Double
$sel:max:Attribute' :: Attribute -> Maybe Double
$sel:description:Attribute' :: Attribute -> Maybe Text
$sel:defaultValue:Attribute' :: Attribute -> Maybe Text
$sel:assignedValue:Attribute' :: Attribute -> Maybe Text
$sel:allowedValues:Attribute' :: Attribute -> 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
defaultValue
      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 Attribute where
  toJSON :: Attribute -> Value
toJSON Attribute' {Maybe Double
Maybe [Text]
Maybe Text
Text
NodeDataType
dataType :: NodeDataType
fullyQualifiedName :: Text
unit :: Maybe Text
min :: Maybe Double
max :: Maybe Double
description :: Maybe Text
defaultValue :: Maybe Text
assignedValue :: Maybe Text
allowedValues :: Maybe [Text]
$sel:dataType:Attribute' :: Attribute -> NodeDataType
$sel:fullyQualifiedName:Attribute' :: Attribute -> Text
$sel:unit:Attribute' :: Attribute -> Maybe Text
$sel:min:Attribute' :: Attribute -> Maybe Double
$sel:max:Attribute' :: Attribute -> Maybe Double
$sel:description:Attribute' :: Attribute -> Maybe Text
$sel:defaultValue:Attribute' :: Attribute -> Maybe Text
$sel:assignedValue:Attribute' :: Attribute -> Maybe Text
$sel:allowedValues:Attribute' :: Attribute -> 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
"defaultValue" 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
defaultValue,
            (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)
          ]
      )