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

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

-- | Contains asset property information.
--
-- /See:/ 'newAssetProperty' smart constructor.
data AssetProperty = AssetProperty'
  { -- | The data type of the structure for this property. This parameter exists
    -- on properties that have the @STRUCT@ data type.
    AssetProperty -> Maybe Text
dataTypeSpec :: Prelude.Maybe Prelude.Text,
    -- | The asset property\'s notification topic and state. For more
    -- information, see
    -- <https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_UpdateAssetProperty.html UpdateAssetProperty>.
    AssetProperty -> Maybe PropertyNotification
notification :: Prelude.Maybe PropertyNotification,
    -- | The alias that identifies the property, such as an OPC-UA server data
    -- stream path (for example,
    -- @\/company\/windfarm\/3\/turbine\/7\/temperature@). For more
    -- information, see
    -- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/connect-data-streams.html Mapping industrial data streams to asset properties>
    -- in the /IoT SiteWise User Guide/.
    AssetProperty -> Maybe Text
alias :: Prelude.Maybe Prelude.Text,
    -- | The unit (such as @Newtons@ or @RPM@) of the asset property.
    AssetProperty -> Maybe Text
unit :: Prelude.Maybe Prelude.Text,
    -- | The ID of the asset property.
    AssetProperty -> Text
id :: Prelude.Text,
    -- | The name of the property.
    AssetProperty -> Text
name :: Prelude.Text,
    -- | The data type of the asset property.
    AssetProperty -> PropertyDataType
dataType :: PropertyDataType
  }
  deriving (AssetProperty -> AssetProperty -> Bool
(AssetProperty -> AssetProperty -> Bool)
-> (AssetProperty -> AssetProperty -> Bool) -> Eq AssetProperty
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetProperty -> AssetProperty -> Bool
$c/= :: AssetProperty -> AssetProperty -> Bool
== :: AssetProperty -> AssetProperty -> Bool
$c== :: AssetProperty -> AssetProperty -> Bool
Prelude.Eq, ReadPrec [AssetProperty]
ReadPrec AssetProperty
Int -> ReadS AssetProperty
ReadS [AssetProperty]
(Int -> ReadS AssetProperty)
-> ReadS [AssetProperty]
-> ReadPrec AssetProperty
-> ReadPrec [AssetProperty]
-> Read AssetProperty
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssetProperty]
$creadListPrec :: ReadPrec [AssetProperty]
readPrec :: ReadPrec AssetProperty
$creadPrec :: ReadPrec AssetProperty
readList :: ReadS [AssetProperty]
$creadList :: ReadS [AssetProperty]
readsPrec :: Int -> ReadS AssetProperty
$creadsPrec :: Int -> ReadS AssetProperty
Prelude.Read, Int -> AssetProperty -> ShowS
[AssetProperty] -> ShowS
AssetProperty -> String
(Int -> AssetProperty -> ShowS)
-> (AssetProperty -> String)
-> ([AssetProperty] -> ShowS)
-> Show AssetProperty
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetProperty] -> ShowS
$cshowList :: [AssetProperty] -> ShowS
show :: AssetProperty -> String
$cshow :: AssetProperty -> String
showsPrec :: Int -> AssetProperty -> ShowS
$cshowsPrec :: Int -> AssetProperty -> ShowS
Prelude.Show, (forall x. AssetProperty -> Rep AssetProperty x)
-> (forall x. Rep AssetProperty x -> AssetProperty)
-> Generic AssetProperty
forall x. Rep AssetProperty x -> AssetProperty
forall x. AssetProperty -> Rep AssetProperty x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssetProperty x -> AssetProperty
$cfrom :: forall x. AssetProperty -> Rep AssetProperty x
Prelude.Generic)

-- |
-- Create a value of 'AssetProperty' 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', 'assetProperty_dataTypeSpec' - The data type of the structure for this property. This parameter exists
-- on properties that have the @STRUCT@ data type.
--
-- 'notification', 'assetProperty_notification' - The asset property\'s notification topic and state. For more
-- information, see
-- <https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_UpdateAssetProperty.html UpdateAssetProperty>.
--
-- 'alias', 'assetProperty_alias' - The alias that identifies the property, such as an OPC-UA server data
-- stream path (for example,
-- @\/company\/windfarm\/3\/turbine\/7\/temperature@). For more
-- information, see
-- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/connect-data-streams.html Mapping industrial data streams to asset properties>
-- in the /IoT SiteWise User Guide/.
--
-- 'unit', 'assetProperty_unit' - The unit (such as @Newtons@ or @RPM@) of the asset property.
--
-- 'id', 'assetProperty_id' - The ID of the asset property.
--
-- 'name', 'assetProperty_name' - The name of the property.
--
-- 'dataType', 'assetProperty_dataType' - The data type of the asset property.
newAssetProperty ::
  -- | 'id'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'dataType'
  PropertyDataType ->
  AssetProperty
newAssetProperty :: Text -> Text -> PropertyDataType -> AssetProperty
newAssetProperty Text
pId_ Text
pName_ PropertyDataType
pDataType_ =
  AssetProperty' :: Maybe Text
-> Maybe PropertyNotification
-> Maybe Text
-> Maybe Text
-> Text
-> Text
-> PropertyDataType
-> AssetProperty
AssetProperty'
    { $sel:dataTypeSpec:AssetProperty' :: Maybe Text
dataTypeSpec = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:notification:AssetProperty' :: Maybe PropertyNotification
notification = Maybe PropertyNotification
forall a. Maybe a
Prelude.Nothing,
      $sel:alias:AssetProperty' :: Maybe Text
alias = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:unit:AssetProperty' :: Maybe Text
unit = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:AssetProperty' :: Text
id = Text
pId_,
      $sel:name:AssetProperty' :: Text
name = Text
pName_,
      $sel:dataType:AssetProperty' :: PropertyDataType
dataType = PropertyDataType
pDataType_
    }

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

-- | The asset property\'s notification topic and state. For more
-- information, see
-- <https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_UpdateAssetProperty.html UpdateAssetProperty>.
assetProperty_notification :: Lens.Lens' AssetProperty (Prelude.Maybe PropertyNotification)
assetProperty_notification :: (Maybe PropertyNotification -> f (Maybe PropertyNotification))
-> AssetProperty -> f AssetProperty
assetProperty_notification = (AssetProperty -> Maybe PropertyNotification)
-> (AssetProperty -> Maybe PropertyNotification -> AssetProperty)
-> Lens
     AssetProperty
     AssetProperty
     (Maybe PropertyNotification)
     (Maybe PropertyNotification)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetProperty' {Maybe PropertyNotification
notification :: Maybe PropertyNotification
$sel:notification:AssetProperty' :: AssetProperty -> Maybe PropertyNotification
notification} -> Maybe PropertyNotification
notification) (\s :: AssetProperty
s@AssetProperty' {} Maybe PropertyNotification
a -> AssetProperty
s {$sel:notification:AssetProperty' :: Maybe PropertyNotification
notification = Maybe PropertyNotification
a} :: AssetProperty)

-- | The alias that identifies the property, such as an OPC-UA server data
-- stream path (for example,
-- @\/company\/windfarm\/3\/turbine\/7\/temperature@). For more
-- information, see
-- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/connect-data-streams.html Mapping industrial data streams to asset properties>
-- in the /IoT SiteWise User Guide/.
assetProperty_alias :: Lens.Lens' AssetProperty (Prelude.Maybe Prelude.Text)
assetProperty_alias :: (Maybe Text -> f (Maybe Text)) -> AssetProperty -> f AssetProperty
assetProperty_alias = (AssetProperty -> Maybe Text)
-> (AssetProperty -> Maybe Text -> AssetProperty)
-> Lens AssetProperty AssetProperty (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetProperty' {Maybe Text
alias :: Maybe Text
$sel:alias:AssetProperty' :: AssetProperty -> Maybe Text
alias} -> Maybe Text
alias) (\s :: AssetProperty
s@AssetProperty' {} Maybe Text
a -> AssetProperty
s {$sel:alias:AssetProperty' :: Maybe Text
alias = Maybe Text
a} :: AssetProperty)

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

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

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

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

instance Core.FromJSON AssetProperty where
  parseJSON :: Value -> Parser AssetProperty
parseJSON =
    String
-> (Object -> Parser AssetProperty)
-> Value
-> Parser AssetProperty
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AssetProperty"
      ( \Object
x ->
          Maybe Text
-> Maybe PropertyNotification
-> Maybe Text
-> Maybe Text
-> Text
-> Text
-> PropertyDataType
-> AssetProperty
AssetProperty'
            (Maybe Text
 -> Maybe PropertyNotification
 -> Maybe Text
 -> Maybe Text
 -> Text
 -> Text
 -> PropertyDataType
 -> AssetProperty)
-> Parser (Maybe Text)
-> Parser
     (Maybe PropertyNotification
      -> Maybe Text
      -> Maybe Text
      -> Text
      -> Text
      -> PropertyDataType
      -> AssetProperty)
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 PropertyNotification
   -> Maybe Text
   -> Maybe Text
   -> Text
   -> Text
   -> PropertyDataType
   -> AssetProperty)
-> Parser (Maybe PropertyNotification)
-> Parser
     (Maybe Text
      -> Maybe Text -> Text -> Text -> PropertyDataType -> AssetProperty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe PropertyNotification)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"notification")
            Parser
  (Maybe Text
   -> Maybe Text -> Text -> Text -> PropertyDataType -> AssetProperty)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Text -> Text -> PropertyDataType -> AssetProperty)
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
"alias")
            Parser
  (Maybe Text -> Text -> Text -> PropertyDataType -> AssetProperty)
-> Parser (Maybe Text)
-> Parser (Text -> Text -> PropertyDataType -> AssetProperty)
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 -> Text -> PropertyDataType -> AssetProperty)
-> Parser Text
-> Parser (Text -> PropertyDataType -> AssetProperty)
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
"id")
            Parser (Text -> PropertyDataType -> AssetProperty)
-> Parser Text -> Parser (PropertyDataType -> AssetProperty)
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 -> AssetProperty)
-> Parser PropertyDataType -> Parser AssetProperty
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")
      )

instance Prelude.Hashable AssetProperty

instance Prelude.NFData AssetProperty