{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTSiteWise.Types.Property where

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

-- | Contains asset property information.
--
-- /See:/ 'newProperty' smart constructor.
data Property = 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 -> Maybe Text
alias :: 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>.
    Property -> Maybe PropertyNotification
notification :: Prelude.Maybe PropertyNotification,
    -- | 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
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]
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
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. 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:
--
-- '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/.
--
-- '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>.
--
-- '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'
    { $sel:alias:Property' :: Maybe Text
alias = forall a. Maybe a
Prelude.Nothing,
      $sel:notification:Property' :: Maybe PropertyNotification
notification = forall a. Maybe a
Prelude.Nothing,
      $sel:type':Property' :: Maybe PropertyType
type' = forall a. Maybe a
Prelude.Nothing,
      $sel:unit:Property' :: Maybe Text
unit = 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 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 :: Lens' Property (Maybe Text)
property_alias = 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 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 :: Lens' Property (Maybe PropertyNotification)
property_notification = 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 property type (see @PropertyType@). A property contains one type.
property_type :: Lens.Lens' Property (Prelude.Maybe PropertyType)
property_type :: Lens' Property (Maybe PropertyType)
property_type = 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 :: Lens' Property (Maybe Text)
property_unit = 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 :: Lens' Property Text
property_id = 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 :: Lens' Property Text
property_name = 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 :: Lens' Property PropertyDataType
property_dataType = 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 Data.FromJSON Property where
  parseJSON :: Value -> Parser Property
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Property"
      ( \Object
x ->
          Maybe Text
-> Maybe PropertyNotification
-> Maybe PropertyType
-> Maybe Text
-> Text
-> Text
-> PropertyDataType
-> Property
Property'
            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
"alias")
            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
"notification")
            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
"type")
            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
"id")
            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
"name")
            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 Property where
  hashWithSalt :: Int -> Property -> Int
hashWithSalt Int
_salt Property' {Maybe Text
Maybe PropertyNotification
Maybe PropertyType
Text
PropertyDataType
dataType :: PropertyDataType
name :: Text
id :: Text
unit :: Maybe Text
type' :: Maybe PropertyType
notification :: Maybe PropertyNotification
alias :: Maybe Text
$sel:dataType:Property' :: Property -> PropertyDataType
$sel:name:Property' :: Property -> Text
$sel:id:Property' :: Property -> Text
$sel:unit:Property' :: Property -> Maybe Text
$sel:type':Property' :: Property -> Maybe PropertyType
$sel:notification:Property' :: Property -> Maybe PropertyNotification
$sel:alias:Property' :: Property -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
alias
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PropertyNotification
notification
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PropertyType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
unit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PropertyDataType
dataType

instance Prelude.NFData Property where
  rnf :: Property -> ()
rnf Property' {Maybe Text
Maybe PropertyNotification
Maybe PropertyType
Text
PropertyDataType
dataType :: PropertyDataType
name :: Text
id :: Text
unit :: Maybe Text
type' :: Maybe PropertyType
notification :: Maybe PropertyNotification
alias :: Maybe Text
$sel:dataType:Property' :: Property -> PropertyDataType
$sel:name:Property' :: Property -> Text
$sel:id:Property' :: Property -> Text
$sel:unit:Property' :: Property -> Maybe Text
$sel:type':Property' :: Property -> Maybe PropertyType
$sel:notification:Property' :: Property -> Maybe PropertyNotification
$sel:alias:Property' :: Property -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
alias
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PropertyNotification
notification
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PropertyType
type'
      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
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PropertyDataType
dataType