{-# 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.IoTAnalytics.Types.ChannelSummary
-- 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.IoTAnalytics.Types.ChannelSummary where

import qualified Amazonka.Core as Core
import Amazonka.IoTAnalytics.Types.ChannelStatus
import Amazonka.IoTAnalytics.Types.ChannelStorageSummary
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A summary of information about a channel.
--
-- /See:/ 'newChannelSummary' smart constructor.
data ChannelSummary = ChannelSummary'
  { -- | When the channel was created.
    ChannelSummary -> Maybe POSIX
creationTime :: Prelude.Maybe Core.POSIX,
    -- | The status of the channel.
    ChannelSummary -> Maybe ChannelStatus
status :: Prelude.Maybe ChannelStatus,
    -- | The last time when a new message arrived in the channel.
    --
    -- IoT Analytics updates this value at most once per minute for one
    -- channel. Hence, the @lastMessageArrivalTime@ value is an approximation.
    --
    -- This feature only applies to messages that arrived in the data store
    -- after October 23, 2020.
    ChannelSummary -> Maybe POSIX
lastMessageArrivalTime :: Prelude.Maybe Core.POSIX,
    -- | The name of the channel.
    ChannelSummary -> Maybe Text
channelName :: Prelude.Maybe Prelude.Text,
    -- | Where channel data is stored.
    ChannelSummary -> Maybe ChannelStorageSummary
channelStorage :: Prelude.Maybe ChannelStorageSummary,
    -- | The last time the channel was updated.
    ChannelSummary -> Maybe POSIX
lastUpdateTime :: Prelude.Maybe Core.POSIX
  }
  deriving (ChannelSummary -> ChannelSummary -> Bool
(ChannelSummary -> ChannelSummary -> Bool)
-> (ChannelSummary -> ChannelSummary -> Bool) -> Eq ChannelSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChannelSummary -> ChannelSummary -> Bool
$c/= :: ChannelSummary -> ChannelSummary -> Bool
== :: ChannelSummary -> ChannelSummary -> Bool
$c== :: ChannelSummary -> ChannelSummary -> Bool
Prelude.Eq, ReadPrec [ChannelSummary]
ReadPrec ChannelSummary
Int -> ReadS ChannelSummary
ReadS [ChannelSummary]
(Int -> ReadS ChannelSummary)
-> ReadS [ChannelSummary]
-> ReadPrec ChannelSummary
-> ReadPrec [ChannelSummary]
-> Read ChannelSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChannelSummary]
$creadListPrec :: ReadPrec [ChannelSummary]
readPrec :: ReadPrec ChannelSummary
$creadPrec :: ReadPrec ChannelSummary
readList :: ReadS [ChannelSummary]
$creadList :: ReadS [ChannelSummary]
readsPrec :: Int -> ReadS ChannelSummary
$creadsPrec :: Int -> ReadS ChannelSummary
Prelude.Read, Int -> ChannelSummary -> ShowS
[ChannelSummary] -> ShowS
ChannelSummary -> String
(Int -> ChannelSummary -> ShowS)
-> (ChannelSummary -> String)
-> ([ChannelSummary] -> ShowS)
-> Show ChannelSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChannelSummary] -> ShowS
$cshowList :: [ChannelSummary] -> ShowS
show :: ChannelSummary -> String
$cshow :: ChannelSummary -> String
showsPrec :: Int -> ChannelSummary -> ShowS
$cshowsPrec :: Int -> ChannelSummary -> ShowS
Prelude.Show, (forall x. ChannelSummary -> Rep ChannelSummary x)
-> (forall x. Rep ChannelSummary x -> ChannelSummary)
-> Generic ChannelSummary
forall x. Rep ChannelSummary x -> ChannelSummary
forall x. ChannelSummary -> Rep ChannelSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChannelSummary x -> ChannelSummary
$cfrom :: forall x. ChannelSummary -> Rep ChannelSummary x
Prelude.Generic)

-- |
-- Create a value of 'ChannelSummary' 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:
--
-- 'creationTime', 'channelSummary_creationTime' - When the channel was created.
--
-- 'status', 'channelSummary_status' - The status of the channel.
--
-- 'lastMessageArrivalTime', 'channelSummary_lastMessageArrivalTime' - The last time when a new message arrived in the channel.
--
-- IoT Analytics updates this value at most once per minute for one
-- channel. Hence, the @lastMessageArrivalTime@ value is an approximation.
--
-- This feature only applies to messages that arrived in the data store
-- after October 23, 2020.
--
-- 'channelName', 'channelSummary_channelName' - The name of the channel.
--
-- 'channelStorage', 'channelSummary_channelStorage' - Where channel data is stored.
--
-- 'lastUpdateTime', 'channelSummary_lastUpdateTime' - The last time the channel was updated.
newChannelSummary ::
  ChannelSummary
newChannelSummary :: ChannelSummary
newChannelSummary =
  ChannelSummary' :: Maybe POSIX
-> Maybe ChannelStatus
-> Maybe POSIX
-> Maybe Text
-> Maybe ChannelStorageSummary
-> Maybe POSIX
-> ChannelSummary
ChannelSummary'
    { $sel:creationTime:ChannelSummary' :: Maybe POSIX
creationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:status:ChannelSummary' :: Maybe ChannelStatus
status = Maybe ChannelStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:lastMessageArrivalTime:ChannelSummary' :: Maybe POSIX
lastMessageArrivalTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:channelName:ChannelSummary' :: Maybe Text
channelName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:channelStorage:ChannelSummary' :: Maybe ChannelStorageSummary
channelStorage = Maybe ChannelStorageSummary
forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdateTime:ChannelSummary' :: Maybe POSIX
lastUpdateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | When the channel was created.
channelSummary_creationTime :: Lens.Lens' ChannelSummary (Prelude.Maybe Prelude.UTCTime)
channelSummary_creationTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ChannelSummary -> f ChannelSummary
channelSummary_creationTime = (ChannelSummary -> Maybe POSIX)
-> (ChannelSummary -> Maybe POSIX -> ChannelSummary)
-> Lens ChannelSummary ChannelSummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelSummary' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:ChannelSummary' :: ChannelSummary -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: ChannelSummary
s@ChannelSummary' {} Maybe POSIX
a -> ChannelSummary
s {$sel:creationTime:ChannelSummary' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: ChannelSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> ChannelSummary -> f ChannelSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ChannelSummary
-> f ChannelSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The status of the channel.
channelSummary_status :: Lens.Lens' ChannelSummary (Prelude.Maybe ChannelStatus)
channelSummary_status :: (Maybe ChannelStatus -> f (Maybe ChannelStatus))
-> ChannelSummary -> f ChannelSummary
channelSummary_status = (ChannelSummary -> Maybe ChannelStatus)
-> (ChannelSummary -> Maybe ChannelStatus -> ChannelSummary)
-> Lens
     ChannelSummary
     ChannelSummary
     (Maybe ChannelStatus)
     (Maybe ChannelStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelSummary' {Maybe ChannelStatus
status :: Maybe ChannelStatus
$sel:status:ChannelSummary' :: ChannelSummary -> Maybe ChannelStatus
status} -> Maybe ChannelStatus
status) (\s :: ChannelSummary
s@ChannelSummary' {} Maybe ChannelStatus
a -> ChannelSummary
s {$sel:status:ChannelSummary' :: Maybe ChannelStatus
status = Maybe ChannelStatus
a} :: ChannelSummary)

-- | The last time when a new message arrived in the channel.
--
-- IoT Analytics updates this value at most once per minute for one
-- channel. Hence, the @lastMessageArrivalTime@ value is an approximation.
--
-- This feature only applies to messages that arrived in the data store
-- after October 23, 2020.
channelSummary_lastMessageArrivalTime :: Lens.Lens' ChannelSummary (Prelude.Maybe Prelude.UTCTime)
channelSummary_lastMessageArrivalTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ChannelSummary -> f ChannelSummary
channelSummary_lastMessageArrivalTime = (ChannelSummary -> Maybe POSIX)
-> (ChannelSummary -> Maybe POSIX -> ChannelSummary)
-> Lens ChannelSummary ChannelSummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelSummary' {Maybe POSIX
lastMessageArrivalTime :: Maybe POSIX
$sel:lastMessageArrivalTime:ChannelSummary' :: ChannelSummary -> Maybe POSIX
lastMessageArrivalTime} -> Maybe POSIX
lastMessageArrivalTime) (\s :: ChannelSummary
s@ChannelSummary' {} Maybe POSIX
a -> ChannelSummary
s {$sel:lastMessageArrivalTime:ChannelSummary' :: Maybe POSIX
lastMessageArrivalTime = Maybe POSIX
a} :: ChannelSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> ChannelSummary -> f ChannelSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ChannelSummary
-> f ChannelSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The name of the channel.
channelSummary_channelName :: Lens.Lens' ChannelSummary (Prelude.Maybe Prelude.Text)
channelSummary_channelName :: (Maybe Text -> f (Maybe Text))
-> ChannelSummary -> f ChannelSummary
channelSummary_channelName = (ChannelSummary -> Maybe Text)
-> (ChannelSummary -> Maybe Text -> ChannelSummary)
-> Lens ChannelSummary ChannelSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelSummary' {Maybe Text
channelName :: Maybe Text
$sel:channelName:ChannelSummary' :: ChannelSummary -> Maybe Text
channelName} -> Maybe Text
channelName) (\s :: ChannelSummary
s@ChannelSummary' {} Maybe Text
a -> ChannelSummary
s {$sel:channelName:ChannelSummary' :: Maybe Text
channelName = Maybe Text
a} :: ChannelSummary)

-- | Where channel data is stored.
channelSummary_channelStorage :: Lens.Lens' ChannelSummary (Prelude.Maybe ChannelStorageSummary)
channelSummary_channelStorage :: (Maybe ChannelStorageSummary -> f (Maybe ChannelStorageSummary))
-> ChannelSummary -> f ChannelSummary
channelSummary_channelStorage = (ChannelSummary -> Maybe ChannelStorageSummary)
-> (ChannelSummary
    -> Maybe ChannelStorageSummary -> ChannelSummary)
-> Lens
     ChannelSummary
     ChannelSummary
     (Maybe ChannelStorageSummary)
     (Maybe ChannelStorageSummary)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelSummary' {Maybe ChannelStorageSummary
channelStorage :: Maybe ChannelStorageSummary
$sel:channelStorage:ChannelSummary' :: ChannelSummary -> Maybe ChannelStorageSummary
channelStorage} -> Maybe ChannelStorageSummary
channelStorage) (\s :: ChannelSummary
s@ChannelSummary' {} Maybe ChannelStorageSummary
a -> ChannelSummary
s {$sel:channelStorage:ChannelSummary' :: Maybe ChannelStorageSummary
channelStorage = Maybe ChannelStorageSummary
a} :: ChannelSummary)

-- | The last time the channel was updated.
channelSummary_lastUpdateTime :: Lens.Lens' ChannelSummary (Prelude.Maybe Prelude.UTCTime)
channelSummary_lastUpdateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ChannelSummary -> f ChannelSummary
channelSummary_lastUpdateTime = (ChannelSummary -> Maybe POSIX)
-> (ChannelSummary -> Maybe POSIX -> ChannelSummary)
-> Lens ChannelSummary ChannelSummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelSummary' {Maybe POSIX
lastUpdateTime :: Maybe POSIX
$sel:lastUpdateTime:ChannelSummary' :: ChannelSummary -> Maybe POSIX
lastUpdateTime} -> Maybe POSIX
lastUpdateTime) (\s :: ChannelSummary
s@ChannelSummary' {} Maybe POSIX
a -> ChannelSummary
s {$sel:lastUpdateTime:ChannelSummary' :: Maybe POSIX
lastUpdateTime = Maybe POSIX
a} :: ChannelSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> ChannelSummary -> f ChannelSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ChannelSummary
-> f ChannelSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON ChannelSummary where
  parseJSON :: Value -> Parser ChannelSummary
parseJSON =
    String
-> (Object -> Parser ChannelSummary)
-> Value
-> Parser ChannelSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ChannelSummary"
      ( \Object
x ->
          Maybe POSIX
-> Maybe ChannelStatus
-> Maybe POSIX
-> Maybe Text
-> Maybe ChannelStorageSummary
-> Maybe POSIX
-> ChannelSummary
ChannelSummary'
            (Maybe POSIX
 -> Maybe ChannelStatus
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe ChannelStorageSummary
 -> Maybe POSIX
 -> ChannelSummary)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe ChannelStatus
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe ChannelStorageSummary
      -> Maybe POSIX
      -> ChannelSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"creationTime")
            Parser
  (Maybe ChannelStatus
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe ChannelStorageSummary
   -> Maybe POSIX
   -> ChannelSummary)
-> Parser (Maybe ChannelStatus)
-> Parser
     (Maybe POSIX
      -> Maybe Text
      -> Maybe ChannelStorageSummary
      -> Maybe POSIX
      -> ChannelSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ChannelStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"status")
            Parser
  (Maybe POSIX
   -> Maybe Text
   -> Maybe ChannelStorageSummary
   -> Maybe POSIX
   -> ChannelSummary)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text
      -> Maybe ChannelStorageSummary -> Maybe POSIX -> ChannelSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lastMessageArrivalTime")
            Parser
  (Maybe Text
   -> Maybe ChannelStorageSummary -> Maybe POSIX -> ChannelSummary)
-> Parser (Maybe Text)
-> Parser
     (Maybe ChannelStorageSummary -> Maybe POSIX -> ChannelSummary)
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
"channelName")
            Parser
  (Maybe ChannelStorageSummary -> Maybe POSIX -> ChannelSummary)
-> Parser (Maybe ChannelStorageSummary)
-> Parser (Maybe POSIX -> ChannelSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ChannelStorageSummary)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"channelStorage")
            Parser (Maybe POSIX -> ChannelSummary)
-> Parser (Maybe POSIX) -> Parser ChannelSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lastUpdateTime")
      )

instance Prelude.Hashable ChannelSummary

instance Prelude.NFData ChannelSummary