{-# 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.PropertyNotification
-- 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.PropertyNotification 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.PropertyNotificationState
import qualified Amazonka.Prelude as Prelude

-- | Contains asset property value notification information. When the
-- notification state is enabled, IoT SiteWise publishes property value
-- updates to a unique MQTT topic. For more information, see
-- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/interact-with-other-services.html Interacting with other services>
-- in the /IoT SiteWise User Guide/.
--
-- /See:/ 'newPropertyNotification' smart constructor.
data PropertyNotification = PropertyNotification'
  { -- | The MQTT topic to which IoT SiteWise publishes property value update
    -- notifications.
    PropertyNotification -> Text
topic :: Prelude.Text,
    -- | The current notification state.
    PropertyNotification -> PropertyNotificationState
state :: PropertyNotificationState
  }
  deriving (PropertyNotification -> PropertyNotification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PropertyNotification -> PropertyNotification -> Bool
$c/= :: PropertyNotification -> PropertyNotification -> Bool
== :: PropertyNotification -> PropertyNotification -> Bool
$c== :: PropertyNotification -> PropertyNotification -> Bool
Prelude.Eq, ReadPrec [PropertyNotification]
ReadPrec PropertyNotification
Int -> ReadS PropertyNotification
ReadS [PropertyNotification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PropertyNotification]
$creadListPrec :: ReadPrec [PropertyNotification]
readPrec :: ReadPrec PropertyNotification
$creadPrec :: ReadPrec PropertyNotification
readList :: ReadS [PropertyNotification]
$creadList :: ReadS [PropertyNotification]
readsPrec :: Int -> ReadS PropertyNotification
$creadsPrec :: Int -> ReadS PropertyNotification
Prelude.Read, Int -> PropertyNotification -> ShowS
[PropertyNotification] -> ShowS
PropertyNotification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PropertyNotification] -> ShowS
$cshowList :: [PropertyNotification] -> ShowS
show :: PropertyNotification -> String
$cshow :: PropertyNotification -> String
showsPrec :: Int -> PropertyNotification -> ShowS
$cshowsPrec :: Int -> PropertyNotification -> ShowS
Prelude.Show, forall x. Rep PropertyNotification x -> PropertyNotification
forall x. PropertyNotification -> Rep PropertyNotification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PropertyNotification x -> PropertyNotification
$cfrom :: forall x. PropertyNotification -> Rep PropertyNotification x
Prelude.Generic)

-- |
-- Create a value of 'PropertyNotification' 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:
--
-- 'topic', 'propertyNotification_topic' - The MQTT topic to which IoT SiteWise publishes property value update
-- notifications.
--
-- 'state', 'propertyNotification_state' - The current notification state.
newPropertyNotification ::
  -- | 'topic'
  Prelude.Text ->
  -- | 'state'
  PropertyNotificationState ->
  PropertyNotification
newPropertyNotification :: Text -> PropertyNotificationState -> PropertyNotification
newPropertyNotification Text
pTopic_ PropertyNotificationState
pState_ =
  PropertyNotification'
    { $sel:topic:PropertyNotification' :: Text
topic = Text
pTopic_,
      $sel:state:PropertyNotification' :: PropertyNotificationState
state = PropertyNotificationState
pState_
    }

-- | The MQTT topic to which IoT SiteWise publishes property value update
-- notifications.
propertyNotification_topic :: Lens.Lens' PropertyNotification Prelude.Text
propertyNotification_topic :: Lens' PropertyNotification Text
propertyNotification_topic = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyNotification' {Text
topic :: Text
$sel:topic:PropertyNotification' :: PropertyNotification -> Text
topic} -> Text
topic) (\s :: PropertyNotification
s@PropertyNotification' {} Text
a -> PropertyNotification
s {$sel:topic:PropertyNotification' :: Text
topic = Text
a} :: PropertyNotification)

-- | The current notification state.
propertyNotification_state :: Lens.Lens' PropertyNotification PropertyNotificationState
propertyNotification_state :: Lens' PropertyNotification PropertyNotificationState
propertyNotification_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyNotification' {PropertyNotificationState
state :: PropertyNotificationState
$sel:state:PropertyNotification' :: PropertyNotification -> PropertyNotificationState
state} -> PropertyNotificationState
state) (\s :: PropertyNotification
s@PropertyNotification' {} PropertyNotificationState
a -> PropertyNotification
s {$sel:state:PropertyNotification' :: PropertyNotificationState
state = PropertyNotificationState
a} :: PropertyNotification)

instance Data.FromJSON PropertyNotification where
  parseJSON :: Value -> Parser PropertyNotification
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PropertyNotification"
      ( \Object
x ->
          Text -> PropertyNotificationState -> PropertyNotification
PropertyNotification'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"topic")
            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
"state")
      )

instance Prelude.Hashable PropertyNotification where
  hashWithSalt :: Int -> PropertyNotification -> Int
hashWithSalt Int
_salt PropertyNotification' {Text
PropertyNotificationState
state :: PropertyNotificationState
topic :: Text
$sel:state:PropertyNotification' :: PropertyNotification -> PropertyNotificationState
$sel:topic:PropertyNotification' :: PropertyNotification -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
topic
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PropertyNotificationState
state

instance Prelude.NFData PropertyNotification where
  rnf :: PropertyNotification -> ()
rnf PropertyNotification' {Text
PropertyNotificationState
state :: PropertyNotificationState
topic :: Text
$sel:state:PropertyNotification' :: PropertyNotification -> PropertyNotificationState
$sel:topic:PropertyNotification' :: PropertyNotification -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
topic seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PropertyNotificationState
state