{-# 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.IoTData.Types.RetainedMessageSummary
-- 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.IoTData.Types.RetainedMessageSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about a single retained message.
--
-- /See:/ 'newRetainedMessageSummary' smart constructor.
data RetainedMessageSummary = RetainedMessageSummary'
  { -- | The Epoch date and time, in milliseconds, when the retained message was
    -- stored by IoT.
    RetainedMessageSummary -> Maybe Integer
lastModifiedTime :: Prelude.Maybe Prelude.Integer,
    -- | The topic name to which the retained message was published.
    RetainedMessageSummary -> Maybe Text
topic :: Prelude.Maybe Prelude.Text,
    -- | The quality of service (QoS) level used to publish the retained message.
    RetainedMessageSummary -> Maybe Natural
qos :: Prelude.Maybe Prelude.Natural,
    -- | The size of the retained message\'s payload in bytes.
    RetainedMessageSummary -> Maybe Integer
payloadSize :: Prelude.Maybe Prelude.Integer
  }
  deriving (RetainedMessageSummary -> RetainedMessageSummary -> Bool
(RetainedMessageSummary -> RetainedMessageSummary -> Bool)
-> (RetainedMessageSummary -> RetainedMessageSummary -> Bool)
-> Eq RetainedMessageSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RetainedMessageSummary -> RetainedMessageSummary -> Bool
$c/= :: RetainedMessageSummary -> RetainedMessageSummary -> Bool
== :: RetainedMessageSummary -> RetainedMessageSummary -> Bool
$c== :: RetainedMessageSummary -> RetainedMessageSummary -> Bool
Prelude.Eq, ReadPrec [RetainedMessageSummary]
ReadPrec RetainedMessageSummary
Int -> ReadS RetainedMessageSummary
ReadS [RetainedMessageSummary]
(Int -> ReadS RetainedMessageSummary)
-> ReadS [RetainedMessageSummary]
-> ReadPrec RetainedMessageSummary
-> ReadPrec [RetainedMessageSummary]
-> Read RetainedMessageSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RetainedMessageSummary]
$creadListPrec :: ReadPrec [RetainedMessageSummary]
readPrec :: ReadPrec RetainedMessageSummary
$creadPrec :: ReadPrec RetainedMessageSummary
readList :: ReadS [RetainedMessageSummary]
$creadList :: ReadS [RetainedMessageSummary]
readsPrec :: Int -> ReadS RetainedMessageSummary
$creadsPrec :: Int -> ReadS RetainedMessageSummary
Prelude.Read, Int -> RetainedMessageSummary -> ShowS
[RetainedMessageSummary] -> ShowS
RetainedMessageSummary -> String
(Int -> RetainedMessageSummary -> ShowS)
-> (RetainedMessageSummary -> String)
-> ([RetainedMessageSummary] -> ShowS)
-> Show RetainedMessageSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RetainedMessageSummary] -> ShowS
$cshowList :: [RetainedMessageSummary] -> ShowS
show :: RetainedMessageSummary -> String
$cshow :: RetainedMessageSummary -> String
showsPrec :: Int -> RetainedMessageSummary -> ShowS
$cshowsPrec :: Int -> RetainedMessageSummary -> ShowS
Prelude.Show, (forall x. RetainedMessageSummary -> Rep RetainedMessageSummary x)
-> (forall x.
    Rep RetainedMessageSummary x -> RetainedMessageSummary)
-> Generic RetainedMessageSummary
forall x. Rep RetainedMessageSummary x -> RetainedMessageSummary
forall x. RetainedMessageSummary -> Rep RetainedMessageSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RetainedMessageSummary x -> RetainedMessageSummary
$cfrom :: forall x. RetainedMessageSummary -> Rep RetainedMessageSummary x
Prelude.Generic)

-- |
-- Create a value of 'RetainedMessageSummary' 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:
--
-- 'lastModifiedTime', 'retainedMessageSummary_lastModifiedTime' - The Epoch date and time, in milliseconds, when the retained message was
-- stored by IoT.
--
-- 'topic', 'retainedMessageSummary_topic' - The topic name to which the retained message was published.
--
-- 'qos', 'retainedMessageSummary_qos' - The quality of service (QoS) level used to publish the retained message.
--
-- 'payloadSize', 'retainedMessageSummary_payloadSize' - The size of the retained message\'s payload in bytes.
newRetainedMessageSummary ::
  RetainedMessageSummary
newRetainedMessageSummary :: RetainedMessageSummary
newRetainedMessageSummary =
  RetainedMessageSummary' :: Maybe Integer
-> Maybe Text
-> Maybe Natural
-> Maybe Integer
-> RetainedMessageSummary
RetainedMessageSummary'
    { $sel:lastModifiedTime:RetainedMessageSummary' :: Maybe Integer
lastModifiedTime =
        Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:topic:RetainedMessageSummary' :: Maybe Text
topic = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:qos:RetainedMessageSummary' :: Maybe Natural
qos = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:payloadSize:RetainedMessageSummary' :: Maybe Integer
payloadSize = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | The Epoch date and time, in milliseconds, when the retained message was
-- stored by IoT.
retainedMessageSummary_lastModifiedTime :: Lens.Lens' RetainedMessageSummary (Prelude.Maybe Prelude.Integer)
retainedMessageSummary_lastModifiedTime :: (Maybe Integer -> f (Maybe Integer))
-> RetainedMessageSummary -> f RetainedMessageSummary
retainedMessageSummary_lastModifiedTime = (RetainedMessageSummary -> Maybe Integer)
-> (RetainedMessageSummary
    -> Maybe Integer -> RetainedMessageSummary)
-> Lens
     RetainedMessageSummary
     RetainedMessageSummary
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetainedMessageSummary' {Maybe Integer
lastModifiedTime :: Maybe Integer
$sel:lastModifiedTime:RetainedMessageSummary' :: RetainedMessageSummary -> Maybe Integer
lastModifiedTime} -> Maybe Integer
lastModifiedTime) (\s :: RetainedMessageSummary
s@RetainedMessageSummary' {} Maybe Integer
a -> RetainedMessageSummary
s {$sel:lastModifiedTime:RetainedMessageSummary' :: Maybe Integer
lastModifiedTime = Maybe Integer
a} :: RetainedMessageSummary)

-- | The topic name to which the retained message was published.
retainedMessageSummary_topic :: Lens.Lens' RetainedMessageSummary (Prelude.Maybe Prelude.Text)
retainedMessageSummary_topic :: (Maybe Text -> f (Maybe Text))
-> RetainedMessageSummary -> f RetainedMessageSummary
retainedMessageSummary_topic = (RetainedMessageSummary -> Maybe Text)
-> (RetainedMessageSummary -> Maybe Text -> RetainedMessageSummary)
-> Lens
     RetainedMessageSummary
     RetainedMessageSummary
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetainedMessageSummary' {Maybe Text
topic :: Maybe Text
$sel:topic:RetainedMessageSummary' :: RetainedMessageSummary -> Maybe Text
topic} -> Maybe Text
topic) (\s :: RetainedMessageSummary
s@RetainedMessageSummary' {} Maybe Text
a -> RetainedMessageSummary
s {$sel:topic:RetainedMessageSummary' :: Maybe Text
topic = Maybe Text
a} :: RetainedMessageSummary)

-- | The quality of service (QoS) level used to publish the retained message.
retainedMessageSummary_qos :: Lens.Lens' RetainedMessageSummary (Prelude.Maybe Prelude.Natural)
retainedMessageSummary_qos :: (Maybe Natural -> f (Maybe Natural))
-> RetainedMessageSummary -> f RetainedMessageSummary
retainedMessageSummary_qos = (RetainedMessageSummary -> Maybe Natural)
-> (RetainedMessageSummary
    -> Maybe Natural -> RetainedMessageSummary)
-> Lens
     RetainedMessageSummary
     RetainedMessageSummary
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetainedMessageSummary' {Maybe Natural
qos :: Maybe Natural
$sel:qos:RetainedMessageSummary' :: RetainedMessageSummary -> Maybe Natural
qos} -> Maybe Natural
qos) (\s :: RetainedMessageSummary
s@RetainedMessageSummary' {} Maybe Natural
a -> RetainedMessageSummary
s {$sel:qos:RetainedMessageSummary' :: Maybe Natural
qos = Maybe Natural
a} :: RetainedMessageSummary)

-- | The size of the retained message\'s payload in bytes.
retainedMessageSummary_payloadSize :: Lens.Lens' RetainedMessageSummary (Prelude.Maybe Prelude.Integer)
retainedMessageSummary_payloadSize :: (Maybe Integer -> f (Maybe Integer))
-> RetainedMessageSummary -> f RetainedMessageSummary
retainedMessageSummary_payloadSize = (RetainedMessageSummary -> Maybe Integer)
-> (RetainedMessageSummary
    -> Maybe Integer -> RetainedMessageSummary)
-> Lens
     RetainedMessageSummary
     RetainedMessageSummary
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetainedMessageSummary' {Maybe Integer
payloadSize :: Maybe Integer
$sel:payloadSize:RetainedMessageSummary' :: RetainedMessageSummary -> Maybe Integer
payloadSize} -> Maybe Integer
payloadSize) (\s :: RetainedMessageSummary
s@RetainedMessageSummary' {} Maybe Integer
a -> RetainedMessageSummary
s {$sel:payloadSize:RetainedMessageSummary' :: Maybe Integer
payloadSize = Maybe Integer
a} :: RetainedMessageSummary)

instance Core.FromJSON RetainedMessageSummary where
  parseJSON :: Value -> Parser RetainedMessageSummary
parseJSON =
    String
-> (Object -> Parser RetainedMessageSummary)
-> Value
-> Parser RetainedMessageSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RetainedMessageSummary"
      ( \Object
x ->
          Maybe Integer
-> Maybe Text
-> Maybe Natural
-> Maybe Integer
-> RetainedMessageSummary
RetainedMessageSummary'
            (Maybe Integer
 -> Maybe Text
 -> Maybe Natural
 -> Maybe Integer
 -> RetainedMessageSummary)
-> Parser (Maybe Integer)
-> Parser
     (Maybe Text
      -> Maybe Natural -> Maybe Integer -> RetainedMessageSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lastModifiedTime")
            Parser
  (Maybe Text
   -> Maybe Natural -> Maybe Integer -> RetainedMessageSummary)
-> Parser (Maybe Text)
-> Parser
     (Maybe Natural -> Maybe Integer -> RetainedMessageSummary)
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
"topic")
            Parser (Maybe Natural -> Maybe Integer -> RetainedMessageSummary)
-> Parser (Maybe Natural)
-> Parser (Maybe Integer -> RetainedMessageSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"qos")
            Parser (Maybe Integer -> RetainedMessageSummary)
-> Parser (Maybe Integer) -> Parser RetainedMessageSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"payloadSize")
      )

instance Prelude.Hashable RetainedMessageSummary

instance Prelude.NFData RetainedMessageSummary