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

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

-- | Contains asset property information.
--
-- /See:/ 'newProperty' smart constructor.
data Property = Property'
  { -- | 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>.
    Property -> 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/.
    Property -> Maybe Text
alias :: Prelude.Maybe Prelude.Text,
    -- | The property type (see @PropertyType@). A property contains one type.
    Property -> Maybe PropertyType
type' :: Prelude.Maybe PropertyType,
    -- | The unit (such as @Newtons@ or @RPM@) of the asset property.
    Property -> Maybe Text
unit :: Prelude.Maybe Prelude.Text,
    -- | The ID of the asset property.
    Property -> Text
id :: Prelude.Text,
    -- | The name of the property.
    Property -> Text
name :: Prelude.Text,
    -- | The property data type.
    Property -> PropertyDataType
dataType :: PropertyDataType
  }
  deriving (Property -> Property -> Bool
(Property -> Property -> Bool)
-> (Property -> Property -> Bool) -> Eq Property
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Property -> Property -> Bool
$c/= :: Property -> Property -> Bool
== :: Property -> Property -> Bool
$c== :: Property -> Property -> Bool
Prelude.Eq, ReadPrec [Property]
ReadPrec Property
Int -> ReadS Property
ReadS [Property]
(Int -> ReadS Property)
-> ReadS [Property]
-> ReadPrec Property
-> ReadPrec [Property]
-> Read Property
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Property]
$creadListPrec :: ReadPrec [Property]
readPrec :: ReadPrec Property
$creadPrec :: ReadPrec Property
readList :: ReadS [Property]
$creadList :: ReadS [Property]
readsPrec :: Int -> ReadS Property
$creadsPrec :: Int -> ReadS Property
Prelude.Read, Int -> Property -> ShowS
[Property] -> ShowS
Property -> String
(Int -> Property -> ShowS)
-> (Property -> String) -> ([Property] -> ShowS) -> Show Property
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Property] -> ShowS
$cshowList :: [Property] -> ShowS
show :: Property -> String
$cshow :: Property -> String
showsPrec :: Int -> Property -> ShowS
$cshowsPrec :: Int -> Property -> ShowS
Prelude.Show, (forall x. Property -> Rep Property x)
-> (forall x. Rep Property x -> Property) -> Generic Property
forall x. Rep Property x -> Property
forall x. Property -> Rep Property x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Property x -> Property
$cfrom :: forall x. Property -> Rep Property x
Prelude.Generic)

-- |
-- Create a value of 'Property' 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:
--
-- 'notification', 'property_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', 'property_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/.
--
-- 'type'', 'property_type' - The property type (see @PropertyType@). A property contains one type.
--
-- 'unit', 'property_unit' - The unit (such as @Newtons@ or @RPM@) of the asset property.
--
-- 'id', 'property_id' - The ID of the asset property.
--
-- 'name', 'property_name' - The name of the property.
--
-- 'dataType', 'property_dataType' - The property data type.
newProperty ::
  -- | 'id'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'dataType'
  PropertyDataType ->
  Property
newProperty :: Text -> Text -> PropertyDataType -> Property
newProperty Text
pId_ Text
pName_ PropertyDataType
pDataType_ =
  Property' :: Maybe PropertyNotification
-> Maybe Text
-> Maybe PropertyType
-> Maybe Text
-> Text
-> Text
-> PropertyDataType
-> Property
Property'
    { $sel:notification:Property' :: Maybe PropertyNotification
notification = Maybe PropertyNotification
forall a. Maybe a
Prelude.Nothing,
      $sel:alias:Property' :: Maybe Text
alias = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Property' :: Maybe PropertyType
type' = Maybe PropertyType
forall a. Maybe a
Prelude.Nothing,
      $sel:unit:Property' :: Maybe Text
unit = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Property' :: Text
id = Text
pId_,
      $sel:name:Property' :: Text
name = Text
pName_,
      $sel:dataType:Property' :: PropertyDataType
dataType = PropertyDataType
pDataType_
    }

-- | 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>.
property_notification :: Lens.Lens' Property (Prelude.Maybe PropertyNotification)
property_notification :: (Maybe PropertyNotification -> f (Maybe PropertyNotification))
-> Property -> f Property
property_notification = (Property -> Maybe PropertyNotification)
-> (Property -> Maybe PropertyNotification -> Property)
-> Lens
     Property
     Property
     (Maybe PropertyNotification)
     (Maybe PropertyNotification)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Property' {Maybe PropertyNotification
notification :: Maybe PropertyNotification
$sel:notification:Property' :: Property -> Maybe PropertyNotification
notification} -> Maybe PropertyNotification
notification) (\s :: Property
s@Property' {} Maybe PropertyNotification
a -> Property
s {$sel:notification:Property' :: Maybe PropertyNotification
notification = Maybe PropertyNotification
a} :: Property)

-- | 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/.
property_alias :: Lens.Lens' Property (Prelude.Maybe Prelude.Text)
property_alias :: (Maybe Text -> f (Maybe Text)) -> Property -> f Property
property_alias = (Property -> Maybe Text)
-> (Property -> Maybe Text -> Property)
-> Lens Property Property (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Property' {Maybe Text
alias :: Maybe Text
$sel:alias:Property' :: Property -> Maybe Text
alias} -> Maybe Text
alias) (\s :: Property
s@Property' {} Maybe Text
a -> Property
s {$sel:alias:Property' :: Maybe Text
alias = Maybe Text
a} :: Property)

-- | The property type (see @PropertyType@). A property contains one type.
property_type :: Lens.Lens' Property (Prelude.Maybe PropertyType)
property_type :: (Maybe PropertyType -> f (Maybe PropertyType))
-> Property -> f Property
property_type = (Property -> Maybe PropertyType)
-> (Property -> Maybe PropertyType -> Property)
-> Lens Property Property (Maybe PropertyType) (Maybe PropertyType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Property' {Maybe PropertyType
type' :: Maybe PropertyType
$sel:type':Property' :: Property -> Maybe PropertyType
type'} -> Maybe PropertyType
type') (\s :: Property
s@Property' {} Maybe PropertyType
a -> Property
s {$sel:type':Property' :: Maybe PropertyType
type' = Maybe PropertyType
a} :: Property)

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

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

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

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

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

instance Prelude.NFData Property