{-# 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.Config.Types.ConfigStreamDeliveryInfo
-- 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.Config.Types.ConfigStreamDeliveryInfo where

import Amazonka.Config.Types.DeliveryStatus
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A list that contains the status of the delivery of the configuration
-- stream notification to the Amazon SNS topic.
--
-- /See:/ 'newConfigStreamDeliveryInfo' smart constructor.
data ConfigStreamDeliveryInfo = ConfigStreamDeliveryInfo'
  { -- | The error code from the last attempted delivery.
    ConfigStreamDeliveryInfo -> Maybe Text
lastErrorCode :: Prelude.Maybe Prelude.Text,
    -- | The time from the last status change.
    ConfigStreamDeliveryInfo -> Maybe POSIX
lastStatusChangeTime :: Prelude.Maybe Core.POSIX,
    -- | Status of the last attempted delivery.
    --
    -- __Note__ Providing an SNS topic on a
    -- <https://docs.aws.amazon.com/config/latest/APIReference/API_DeliveryChannel.html DeliveryChannel>
    -- for Config is optional. If the SNS delivery is turned off, the last
    -- status will be __Not_Applicable__.
    ConfigStreamDeliveryInfo -> Maybe DeliveryStatus
lastStatus :: Prelude.Maybe DeliveryStatus,
    -- | The error message from the last attempted delivery.
    ConfigStreamDeliveryInfo -> Maybe Text
lastErrorMessage :: Prelude.Maybe Prelude.Text
  }
  deriving (ConfigStreamDeliveryInfo -> ConfigStreamDeliveryInfo -> Bool
(ConfigStreamDeliveryInfo -> ConfigStreamDeliveryInfo -> Bool)
-> (ConfigStreamDeliveryInfo -> ConfigStreamDeliveryInfo -> Bool)
-> Eq ConfigStreamDeliveryInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfigStreamDeliveryInfo -> ConfigStreamDeliveryInfo -> Bool
$c/= :: ConfigStreamDeliveryInfo -> ConfigStreamDeliveryInfo -> Bool
== :: ConfigStreamDeliveryInfo -> ConfigStreamDeliveryInfo -> Bool
$c== :: ConfigStreamDeliveryInfo -> ConfigStreamDeliveryInfo -> Bool
Prelude.Eq, ReadPrec [ConfigStreamDeliveryInfo]
ReadPrec ConfigStreamDeliveryInfo
Int -> ReadS ConfigStreamDeliveryInfo
ReadS [ConfigStreamDeliveryInfo]
(Int -> ReadS ConfigStreamDeliveryInfo)
-> ReadS [ConfigStreamDeliveryInfo]
-> ReadPrec ConfigStreamDeliveryInfo
-> ReadPrec [ConfigStreamDeliveryInfo]
-> Read ConfigStreamDeliveryInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfigStreamDeliveryInfo]
$creadListPrec :: ReadPrec [ConfigStreamDeliveryInfo]
readPrec :: ReadPrec ConfigStreamDeliveryInfo
$creadPrec :: ReadPrec ConfigStreamDeliveryInfo
readList :: ReadS [ConfigStreamDeliveryInfo]
$creadList :: ReadS [ConfigStreamDeliveryInfo]
readsPrec :: Int -> ReadS ConfigStreamDeliveryInfo
$creadsPrec :: Int -> ReadS ConfigStreamDeliveryInfo
Prelude.Read, Int -> ConfigStreamDeliveryInfo -> ShowS
[ConfigStreamDeliveryInfo] -> ShowS
ConfigStreamDeliveryInfo -> String
(Int -> ConfigStreamDeliveryInfo -> ShowS)
-> (ConfigStreamDeliveryInfo -> String)
-> ([ConfigStreamDeliveryInfo] -> ShowS)
-> Show ConfigStreamDeliveryInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfigStreamDeliveryInfo] -> ShowS
$cshowList :: [ConfigStreamDeliveryInfo] -> ShowS
show :: ConfigStreamDeliveryInfo -> String
$cshow :: ConfigStreamDeliveryInfo -> String
showsPrec :: Int -> ConfigStreamDeliveryInfo -> ShowS
$cshowsPrec :: Int -> ConfigStreamDeliveryInfo -> ShowS
Prelude.Show, (forall x.
 ConfigStreamDeliveryInfo -> Rep ConfigStreamDeliveryInfo x)
-> (forall x.
    Rep ConfigStreamDeliveryInfo x -> ConfigStreamDeliveryInfo)
-> Generic ConfigStreamDeliveryInfo
forall x.
Rep ConfigStreamDeliveryInfo x -> ConfigStreamDeliveryInfo
forall x.
ConfigStreamDeliveryInfo -> Rep ConfigStreamDeliveryInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ConfigStreamDeliveryInfo x -> ConfigStreamDeliveryInfo
$cfrom :: forall x.
ConfigStreamDeliveryInfo -> Rep ConfigStreamDeliveryInfo x
Prelude.Generic)

-- |
-- Create a value of 'ConfigStreamDeliveryInfo' 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:
--
-- 'lastErrorCode', 'configStreamDeliveryInfo_lastErrorCode' - The error code from the last attempted delivery.
--
-- 'lastStatusChangeTime', 'configStreamDeliveryInfo_lastStatusChangeTime' - The time from the last status change.
--
-- 'lastStatus', 'configStreamDeliveryInfo_lastStatus' - Status of the last attempted delivery.
--
-- __Note__ Providing an SNS topic on a
-- <https://docs.aws.amazon.com/config/latest/APIReference/API_DeliveryChannel.html DeliveryChannel>
-- for Config is optional. If the SNS delivery is turned off, the last
-- status will be __Not_Applicable__.
--
-- 'lastErrorMessage', 'configStreamDeliveryInfo_lastErrorMessage' - The error message from the last attempted delivery.
newConfigStreamDeliveryInfo ::
  ConfigStreamDeliveryInfo
newConfigStreamDeliveryInfo :: ConfigStreamDeliveryInfo
newConfigStreamDeliveryInfo =
  ConfigStreamDeliveryInfo' :: Maybe Text
-> Maybe POSIX
-> Maybe DeliveryStatus
-> Maybe Text
-> ConfigStreamDeliveryInfo
ConfigStreamDeliveryInfo'
    { $sel:lastErrorCode:ConfigStreamDeliveryInfo' :: Maybe Text
lastErrorCode =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastStatusChangeTime:ConfigStreamDeliveryInfo' :: Maybe POSIX
lastStatusChangeTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:lastStatus:ConfigStreamDeliveryInfo' :: Maybe DeliveryStatus
lastStatus = Maybe DeliveryStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:lastErrorMessage:ConfigStreamDeliveryInfo' :: Maybe Text
lastErrorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The error code from the last attempted delivery.
configStreamDeliveryInfo_lastErrorCode :: Lens.Lens' ConfigStreamDeliveryInfo (Prelude.Maybe Prelude.Text)
configStreamDeliveryInfo_lastErrorCode :: (Maybe Text -> f (Maybe Text))
-> ConfigStreamDeliveryInfo -> f ConfigStreamDeliveryInfo
configStreamDeliveryInfo_lastErrorCode = (ConfigStreamDeliveryInfo -> Maybe Text)
-> (ConfigStreamDeliveryInfo
    -> Maybe Text -> ConfigStreamDeliveryInfo)
-> Lens
     ConfigStreamDeliveryInfo
     ConfigStreamDeliveryInfo
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigStreamDeliveryInfo' {Maybe Text
lastErrorCode :: Maybe Text
$sel:lastErrorCode:ConfigStreamDeliveryInfo' :: ConfigStreamDeliveryInfo -> Maybe Text
lastErrorCode} -> Maybe Text
lastErrorCode) (\s :: ConfigStreamDeliveryInfo
s@ConfigStreamDeliveryInfo' {} Maybe Text
a -> ConfigStreamDeliveryInfo
s {$sel:lastErrorCode:ConfigStreamDeliveryInfo' :: Maybe Text
lastErrorCode = Maybe Text
a} :: ConfigStreamDeliveryInfo)

-- | The time from the last status change.
configStreamDeliveryInfo_lastStatusChangeTime :: Lens.Lens' ConfigStreamDeliveryInfo (Prelude.Maybe Prelude.UTCTime)
configStreamDeliveryInfo_lastStatusChangeTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ConfigStreamDeliveryInfo -> f ConfigStreamDeliveryInfo
configStreamDeliveryInfo_lastStatusChangeTime = (ConfigStreamDeliveryInfo -> Maybe POSIX)
-> (ConfigStreamDeliveryInfo
    -> Maybe POSIX -> ConfigStreamDeliveryInfo)
-> Lens
     ConfigStreamDeliveryInfo
     ConfigStreamDeliveryInfo
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigStreamDeliveryInfo' {Maybe POSIX
lastStatusChangeTime :: Maybe POSIX
$sel:lastStatusChangeTime:ConfigStreamDeliveryInfo' :: ConfigStreamDeliveryInfo -> Maybe POSIX
lastStatusChangeTime} -> Maybe POSIX
lastStatusChangeTime) (\s :: ConfigStreamDeliveryInfo
s@ConfigStreamDeliveryInfo' {} Maybe POSIX
a -> ConfigStreamDeliveryInfo
s {$sel:lastStatusChangeTime:ConfigStreamDeliveryInfo' :: Maybe POSIX
lastStatusChangeTime = Maybe POSIX
a} :: ConfigStreamDeliveryInfo) ((Maybe POSIX -> f (Maybe POSIX))
 -> ConfigStreamDeliveryInfo -> f ConfigStreamDeliveryInfo)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ConfigStreamDeliveryInfo
-> f ConfigStreamDeliveryInfo
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

-- | Status of the last attempted delivery.
--
-- __Note__ Providing an SNS topic on a
-- <https://docs.aws.amazon.com/config/latest/APIReference/API_DeliveryChannel.html DeliveryChannel>
-- for Config is optional. If the SNS delivery is turned off, the last
-- status will be __Not_Applicable__.
configStreamDeliveryInfo_lastStatus :: Lens.Lens' ConfigStreamDeliveryInfo (Prelude.Maybe DeliveryStatus)
configStreamDeliveryInfo_lastStatus :: (Maybe DeliveryStatus -> f (Maybe DeliveryStatus))
-> ConfigStreamDeliveryInfo -> f ConfigStreamDeliveryInfo
configStreamDeliveryInfo_lastStatus = (ConfigStreamDeliveryInfo -> Maybe DeliveryStatus)
-> (ConfigStreamDeliveryInfo
    -> Maybe DeliveryStatus -> ConfigStreamDeliveryInfo)
-> Lens
     ConfigStreamDeliveryInfo
     ConfigStreamDeliveryInfo
     (Maybe DeliveryStatus)
     (Maybe DeliveryStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigStreamDeliveryInfo' {Maybe DeliveryStatus
lastStatus :: Maybe DeliveryStatus
$sel:lastStatus:ConfigStreamDeliveryInfo' :: ConfigStreamDeliveryInfo -> Maybe DeliveryStatus
lastStatus} -> Maybe DeliveryStatus
lastStatus) (\s :: ConfigStreamDeliveryInfo
s@ConfigStreamDeliveryInfo' {} Maybe DeliveryStatus
a -> ConfigStreamDeliveryInfo
s {$sel:lastStatus:ConfigStreamDeliveryInfo' :: Maybe DeliveryStatus
lastStatus = Maybe DeliveryStatus
a} :: ConfigStreamDeliveryInfo)

-- | The error message from the last attempted delivery.
configStreamDeliveryInfo_lastErrorMessage :: Lens.Lens' ConfigStreamDeliveryInfo (Prelude.Maybe Prelude.Text)
configStreamDeliveryInfo_lastErrorMessage :: (Maybe Text -> f (Maybe Text))
-> ConfigStreamDeliveryInfo -> f ConfigStreamDeliveryInfo
configStreamDeliveryInfo_lastErrorMessage = (ConfigStreamDeliveryInfo -> Maybe Text)
-> (ConfigStreamDeliveryInfo
    -> Maybe Text -> ConfigStreamDeliveryInfo)
-> Lens
     ConfigStreamDeliveryInfo
     ConfigStreamDeliveryInfo
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigStreamDeliveryInfo' {Maybe Text
lastErrorMessage :: Maybe Text
$sel:lastErrorMessage:ConfigStreamDeliveryInfo' :: ConfigStreamDeliveryInfo -> Maybe Text
lastErrorMessage} -> Maybe Text
lastErrorMessage) (\s :: ConfigStreamDeliveryInfo
s@ConfigStreamDeliveryInfo' {} Maybe Text
a -> ConfigStreamDeliveryInfo
s {$sel:lastErrorMessage:ConfigStreamDeliveryInfo' :: Maybe Text
lastErrorMessage = Maybe Text
a} :: ConfigStreamDeliveryInfo)

instance Core.FromJSON ConfigStreamDeliveryInfo where
  parseJSON :: Value -> Parser ConfigStreamDeliveryInfo
parseJSON =
    String
-> (Object -> Parser ConfigStreamDeliveryInfo)
-> Value
-> Parser ConfigStreamDeliveryInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConfigStreamDeliveryInfo"
      ( \Object
x ->
          Maybe Text
-> Maybe POSIX
-> Maybe DeliveryStatus
-> Maybe Text
-> ConfigStreamDeliveryInfo
ConfigStreamDeliveryInfo'
            (Maybe Text
 -> Maybe POSIX
 -> Maybe DeliveryStatus
 -> Maybe Text
 -> ConfigStreamDeliveryInfo)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe DeliveryStatus -> Maybe Text -> ConfigStreamDeliveryInfo)
forall (f :: * -> *) a b. Functor 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
"lastErrorCode")
            Parser
  (Maybe POSIX
   -> Maybe DeliveryStatus -> Maybe Text -> ConfigStreamDeliveryInfo)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe DeliveryStatus -> Maybe Text -> ConfigStreamDeliveryInfo)
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
"lastStatusChangeTime")
            Parser
  (Maybe DeliveryStatus -> Maybe Text -> ConfigStreamDeliveryInfo)
-> Parser (Maybe DeliveryStatus)
-> Parser (Maybe Text -> ConfigStreamDeliveryInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DeliveryStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lastStatus")
            Parser (Maybe Text -> ConfigStreamDeliveryInfo)
-> Parser (Maybe Text) -> Parser ConfigStreamDeliveryInfo
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
"lastErrorMessage")
      )

instance Prelude.Hashable ConfigStreamDeliveryInfo

instance Prelude.NFData ConfigStreamDeliveryInfo