{-# 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.IoTSiteWise.Types.AssetModelProperty
-- 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.IoTSiteWise.Types.AssetModelProperty where

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.PropertyDataType
import Amazonka.IoTSiteWise.Types.PropertyType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about an asset model property.
--
-- /See:/ 'newAssetModelProperty' smart constructor.
data AssetModelProperty = AssetModelProperty'
  { -- | The data type of the structure for this property. This parameter exists
    -- on properties that have the @STRUCT@ data type.
    AssetModelProperty -> Maybe Text
dataTypeSpec :: Prelude.Maybe Prelude.Text,
    -- | The ID of the asset model property.
    AssetModelProperty -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The unit of the asset model property, such as @Newtons@ or @RPM@.
    AssetModelProperty -> Maybe Text
unit :: Prelude.Maybe Prelude.Text,
    -- | The name of the asset model property.
    AssetModelProperty -> Text
name :: Prelude.Text,
    -- | The data type of the asset model property.
    AssetModelProperty -> PropertyDataType
dataType :: PropertyDataType,
    -- | The property type (see @PropertyType@).
    AssetModelProperty -> PropertyType
type' :: PropertyType
  }
  deriving (AssetModelProperty -> AssetModelProperty -> Bool
(AssetModelProperty -> AssetModelProperty -> Bool)
-> (AssetModelProperty -> AssetModelProperty -> Bool)
-> Eq AssetModelProperty
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetModelProperty -> AssetModelProperty -> Bool
$c/= :: AssetModelProperty -> AssetModelProperty -> Bool
== :: AssetModelProperty -> AssetModelProperty -> Bool
$c== :: AssetModelProperty -> AssetModelProperty -> Bool
Prelude.Eq, ReadPrec [AssetModelProperty]
ReadPrec AssetModelProperty
Int -> ReadS AssetModelProperty
ReadS [AssetModelProperty]
(Int -> ReadS AssetModelProperty)
-> ReadS [AssetModelProperty]
-> ReadPrec AssetModelProperty
-> ReadPrec [AssetModelProperty]
-> Read AssetModelProperty
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssetModelProperty]
$creadListPrec :: ReadPrec [AssetModelProperty]
readPrec :: ReadPrec AssetModelProperty
$creadPrec :: ReadPrec AssetModelProperty
readList :: ReadS [AssetModelProperty]
$creadList :: ReadS [AssetModelProperty]
readsPrec :: Int -> ReadS AssetModelProperty
$creadsPrec :: Int -> ReadS AssetModelProperty
Prelude.Read, Int -> AssetModelProperty -> ShowS
[AssetModelProperty] -> ShowS
AssetModelProperty -> String
(Int -> AssetModelProperty -> ShowS)
-> (AssetModelProperty -> String)
-> ([AssetModelProperty] -> ShowS)
-> Show AssetModelProperty
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetModelProperty] -> ShowS
$cshowList :: [AssetModelProperty] -> ShowS
show :: AssetModelProperty -> String
$cshow :: AssetModelProperty -> String
showsPrec :: Int -> AssetModelProperty -> ShowS
$cshowsPrec :: Int -> AssetModelProperty -> ShowS
Prelude.Show, (forall x. AssetModelProperty -> Rep AssetModelProperty x)
-> (forall x. Rep AssetModelProperty x -> AssetModelProperty)
-> Generic AssetModelProperty
forall x. Rep AssetModelProperty x -> AssetModelProperty
forall x. AssetModelProperty -> Rep AssetModelProperty x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssetModelProperty x -> AssetModelProperty
$cfrom :: forall x. AssetModelProperty -> Rep AssetModelProperty x
Prelude.Generic)

-- |
-- Create a value of 'AssetModelProperty' 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:
--
-- 'dataTypeSpec', 'assetModelProperty_dataTypeSpec' - The data type of the structure for this property. This parameter exists
-- on properties that have the @STRUCT@ data type.
--
-- 'id', 'assetModelProperty_id' - The ID of the asset model property.
--
-- 'unit', 'assetModelProperty_unit' - The unit of the asset model property, such as @Newtons@ or @RPM@.
--
-- 'name', 'assetModelProperty_name' - The name of the asset model property.
--
-- 'dataType', 'assetModelProperty_dataType' - The data type of the asset model property.
--
-- 'type'', 'assetModelProperty_type' - The property type (see @PropertyType@).
newAssetModelProperty ::
  -- | 'name'
  Prelude.Text ->
  -- | 'dataType'
  PropertyDataType ->
  -- | 'type''
  PropertyType ->
  AssetModelProperty
newAssetModelProperty :: Text -> PropertyDataType -> PropertyType -> AssetModelProperty
newAssetModelProperty Text
pName_ PropertyDataType
pDataType_ PropertyType
pType_ =
  AssetModelProperty' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> PropertyDataType
-> PropertyType
-> AssetModelProperty
AssetModelProperty'
    { $sel:dataTypeSpec:AssetModelProperty' :: Maybe Text
dataTypeSpec = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:AssetModelProperty' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:unit:AssetModelProperty' :: Maybe Text
unit = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:AssetModelProperty' :: Text
name = Text
pName_,
      $sel:dataType:AssetModelProperty' :: PropertyDataType
dataType = PropertyDataType
pDataType_,
      $sel:type':AssetModelProperty' :: PropertyType
type' = PropertyType
pType_
    }

-- | The data type of the structure for this property. This parameter exists
-- on properties that have the @STRUCT@ data type.
assetModelProperty_dataTypeSpec :: Lens.Lens' AssetModelProperty (Prelude.Maybe Prelude.Text)
assetModelProperty_dataTypeSpec :: (Maybe Text -> f (Maybe Text))
-> AssetModelProperty -> f AssetModelProperty
assetModelProperty_dataTypeSpec = (AssetModelProperty -> Maybe Text)
-> (AssetModelProperty -> Maybe Text -> AssetModelProperty)
-> Lens
     AssetModelProperty AssetModelProperty (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelProperty' {Maybe Text
dataTypeSpec :: Maybe Text
$sel:dataTypeSpec:AssetModelProperty' :: AssetModelProperty -> Maybe Text
dataTypeSpec} -> Maybe Text
dataTypeSpec) (\s :: AssetModelProperty
s@AssetModelProperty' {} Maybe Text
a -> AssetModelProperty
s {$sel:dataTypeSpec:AssetModelProperty' :: Maybe Text
dataTypeSpec = Maybe Text
a} :: AssetModelProperty)

-- | The ID of the asset model property.
assetModelProperty_id :: Lens.Lens' AssetModelProperty (Prelude.Maybe Prelude.Text)
assetModelProperty_id :: (Maybe Text -> f (Maybe Text))
-> AssetModelProperty -> f AssetModelProperty
assetModelProperty_id = (AssetModelProperty -> Maybe Text)
-> (AssetModelProperty -> Maybe Text -> AssetModelProperty)
-> Lens
     AssetModelProperty AssetModelProperty (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelProperty' {Maybe Text
id :: Maybe Text
$sel:id:AssetModelProperty' :: AssetModelProperty -> Maybe Text
id} -> Maybe Text
id) (\s :: AssetModelProperty
s@AssetModelProperty' {} Maybe Text
a -> AssetModelProperty
s {$sel:id:AssetModelProperty' :: Maybe Text
id = Maybe Text
a} :: AssetModelProperty)

-- | The unit of the asset model property, such as @Newtons@ or @RPM@.
assetModelProperty_unit :: Lens.Lens' AssetModelProperty (Prelude.Maybe Prelude.Text)
assetModelProperty_unit :: (Maybe Text -> f (Maybe Text))
-> AssetModelProperty -> f AssetModelProperty
assetModelProperty_unit = (AssetModelProperty -> Maybe Text)
-> (AssetModelProperty -> Maybe Text -> AssetModelProperty)
-> Lens
     AssetModelProperty AssetModelProperty (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelProperty' {Maybe Text
unit :: Maybe Text
$sel:unit:AssetModelProperty' :: AssetModelProperty -> Maybe Text
unit} -> Maybe Text
unit) (\s :: AssetModelProperty
s@AssetModelProperty' {} Maybe Text
a -> AssetModelProperty
s {$sel:unit:AssetModelProperty' :: Maybe Text
unit = Maybe Text
a} :: AssetModelProperty)

-- | The name of the asset model property.
assetModelProperty_name :: Lens.Lens' AssetModelProperty Prelude.Text
assetModelProperty_name :: (Text -> f Text) -> AssetModelProperty -> f AssetModelProperty
assetModelProperty_name = (AssetModelProperty -> Text)
-> (AssetModelProperty -> Text -> AssetModelProperty)
-> Lens AssetModelProperty AssetModelProperty Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelProperty' {Text
name :: Text
$sel:name:AssetModelProperty' :: AssetModelProperty -> Text
name} -> Text
name) (\s :: AssetModelProperty
s@AssetModelProperty' {} Text
a -> AssetModelProperty
s {$sel:name:AssetModelProperty' :: Text
name = Text
a} :: AssetModelProperty)

-- | The data type of the asset model property.
assetModelProperty_dataType :: Lens.Lens' AssetModelProperty PropertyDataType
assetModelProperty_dataType :: (PropertyDataType -> f PropertyDataType)
-> AssetModelProperty -> f AssetModelProperty
assetModelProperty_dataType = (AssetModelProperty -> PropertyDataType)
-> (AssetModelProperty -> PropertyDataType -> AssetModelProperty)
-> Lens
     AssetModelProperty
     AssetModelProperty
     PropertyDataType
     PropertyDataType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelProperty' {PropertyDataType
dataType :: PropertyDataType
$sel:dataType:AssetModelProperty' :: AssetModelProperty -> PropertyDataType
dataType} -> PropertyDataType
dataType) (\s :: AssetModelProperty
s@AssetModelProperty' {} PropertyDataType
a -> AssetModelProperty
s {$sel:dataType:AssetModelProperty' :: PropertyDataType
dataType = PropertyDataType
a} :: AssetModelProperty)

-- | The property type (see @PropertyType@).
assetModelProperty_type :: Lens.Lens' AssetModelProperty PropertyType
assetModelProperty_type :: (PropertyType -> f PropertyType)
-> AssetModelProperty -> f AssetModelProperty
assetModelProperty_type = (AssetModelProperty -> PropertyType)
-> (AssetModelProperty -> PropertyType -> AssetModelProperty)
-> Lens
     AssetModelProperty AssetModelProperty PropertyType PropertyType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelProperty' {PropertyType
type' :: PropertyType
$sel:type':AssetModelProperty' :: AssetModelProperty -> PropertyType
type'} -> PropertyType
type') (\s :: AssetModelProperty
s@AssetModelProperty' {} PropertyType
a -> AssetModelProperty
s {$sel:type':AssetModelProperty' :: PropertyType
type' = PropertyType
a} :: AssetModelProperty)

instance Core.FromJSON AssetModelProperty where
  parseJSON :: Value -> Parser AssetModelProperty
parseJSON =
    String
-> (Object -> Parser AssetModelProperty)
-> Value
-> Parser AssetModelProperty
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AssetModelProperty"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> PropertyDataType
-> PropertyType
-> AssetModelProperty
AssetModelProperty'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Text
 -> PropertyDataType
 -> PropertyType
 -> AssetModelProperty)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Text
      -> PropertyDataType
      -> PropertyType
      -> AssetModelProperty)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"dataTypeSpec")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Text
   -> PropertyDataType
   -> PropertyType
   -> AssetModelProperty)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Text -> PropertyDataType -> PropertyType -> AssetModelProperty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"id")
            Parser
  (Maybe Text
   -> Text -> PropertyDataType -> PropertyType -> AssetModelProperty)
-> Parser (Maybe Text)
-> Parser
     (Text -> PropertyDataType -> PropertyType -> AssetModelProperty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"unit")
            Parser
  (Text -> PropertyDataType -> PropertyType -> AssetModelProperty)
-> Parser Text
-> Parser (PropertyDataType -> PropertyType -> AssetModelProperty)
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
"name")
            Parser (PropertyDataType -> PropertyType -> AssetModelProperty)
-> Parser PropertyDataType
-> Parser (PropertyType -> AssetModelProperty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser PropertyDataType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"dataType")
            Parser (PropertyType -> AssetModelProperty)
-> Parser PropertyType -> Parser AssetModelProperty
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser PropertyType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"type")
      )

instance Prelude.Hashable AssetModelProperty

instance Prelude.NFData AssetModelProperty

instance Core.ToJSON AssetModelProperty where
  toJSON :: AssetModelProperty -> Value
toJSON AssetModelProperty' {Maybe Text
Text
PropertyDataType
PropertyType
type' :: PropertyType
dataType :: PropertyDataType
name :: Text
unit :: Maybe Text
id :: Maybe Text
dataTypeSpec :: Maybe Text
$sel:type':AssetModelProperty' :: AssetModelProperty -> PropertyType
$sel:dataType:AssetModelProperty' :: AssetModelProperty -> PropertyDataType
$sel:name:AssetModelProperty' :: AssetModelProperty -> Text
$sel:unit:AssetModelProperty' :: AssetModelProperty -> Maybe Text
$sel:id:AssetModelProperty' :: AssetModelProperty -> Maybe Text
$sel:dataTypeSpec:AssetModelProperty' :: AssetModelProperty -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"dataTypeSpec" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
dataTypeSpec,
            (Text
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
id,
            (Text
"unit" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
unit,
            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
"dataType" Text -> PropertyDataType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PropertyDataType
dataType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"type" Text -> PropertyType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PropertyType
type')
          ]
      )