{-# 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.MwAA.Types.LastUpdate
-- 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.MwAA.Types.LastUpdate where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MwAA.Types.UpdateError
import Amazonka.MwAA.Types.UpdateStatus
import qualified Amazonka.Prelude as Prelude

-- | The status of the last update on the environment, and any errors that
-- were encountered.
--
-- /See:/ 'newLastUpdate' smart constructor.
data LastUpdate = LastUpdate'
  { -- | The status of the last update on the environment. Valid values:
    -- @SUCCESS@, @PENDING@, @FAILED@.
    LastUpdate -> Maybe UpdateStatus
status :: Prelude.Maybe UpdateStatus,
    -- | The day and time of the last update on the environment.
    LastUpdate -> Maybe POSIX
createdAt :: Prelude.Maybe Core.POSIX,
    -- | The error that was encountered during the last update of the
    -- environment.
    LastUpdate -> Maybe UpdateError
error :: Prelude.Maybe UpdateError
  }
  deriving (LastUpdate -> LastUpdate -> Bool
(LastUpdate -> LastUpdate -> Bool)
-> (LastUpdate -> LastUpdate -> Bool) -> Eq LastUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LastUpdate -> LastUpdate -> Bool
$c/= :: LastUpdate -> LastUpdate -> Bool
== :: LastUpdate -> LastUpdate -> Bool
$c== :: LastUpdate -> LastUpdate -> Bool
Prelude.Eq, ReadPrec [LastUpdate]
ReadPrec LastUpdate
Int -> ReadS LastUpdate
ReadS [LastUpdate]
(Int -> ReadS LastUpdate)
-> ReadS [LastUpdate]
-> ReadPrec LastUpdate
-> ReadPrec [LastUpdate]
-> Read LastUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LastUpdate]
$creadListPrec :: ReadPrec [LastUpdate]
readPrec :: ReadPrec LastUpdate
$creadPrec :: ReadPrec LastUpdate
readList :: ReadS [LastUpdate]
$creadList :: ReadS [LastUpdate]
readsPrec :: Int -> ReadS LastUpdate
$creadsPrec :: Int -> ReadS LastUpdate
Prelude.Read, Int -> LastUpdate -> ShowS
[LastUpdate] -> ShowS
LastUpdate -> String
(Int -> LastUpdate -> ShowS)
-> (LastUpdate -> String)
-> ([LastUpdate] -> ShowS)
-> Show LastUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LastUpdate] -> ShowS
$cshowList :: [LastUpdate] -> ShowS
show :: LastUpdate -> String
$cshow :: LastUpdate -> String
showsPrec :: Int -> LastUpdate -> ShowS
$cshowsPrec :: Int -> LastUpdate -> ShowS
Prelude.Show, (forall x. LastUpdate -> Rep LastUpdate x)
-> (forall x. Rep LastUpdate x -> LastUpdate) -> Generic LastUpdate
forall x. Rep LastUpdate x -> LastUpdate
forall x. LastUpdate -> Rep LastUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LastUpdate x -> LastUpdate
$cfrom :: forall x. LastUpdate -> Rep LastUpdate x
Prelude.Generic)

-- |
-- Create a value of 'LastUpdate' 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:
--
-- 'status', 'lastUpdate_status' - The status of the last update on the environment. Valid values:
-- @SUCCESS@, @PENDING@, @FAILED@.
--
-- 'createdAt', 'lastUpdate_createdAt' - The day and time of the last update on the environment.
--
-- 'error', 'lastUpdate_error' - The error that was encountered during the last update of the
-- environment.
newLastUpdate ::
  LastUpdate
newLastUpdate :: LastUpdate
newLastUpdate =
  LastUpdate' :: Maybe UpdateStatus
-> Maybe POSIX -> Maybe UpdateError -> LastUpdate
LastUpdate'
    { $sel:status:LastUpdate' :: Maybe UpdateStatus
status = Maybe UpdateStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:createdAt:LastUpdate' :: Maybe POSIX
createdAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:error:LastUpdate' :: Maybe UpdateError
error = Maybe UpdateError
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the last update on the environment. Valid values:
-- @SUCCESS@, @PENDING@, @FAILED@.
lastUpdate_status :: Lens.Lens' LastUpdate (Prelude.Maybe UpdateStatus)
lastUpdate_status :: (Maybe UpdateStatus -> f (Maybe UpdateStatus))
-> LastUpdate -> f LastUpdate
lastUpdate_status = (LastUpdate -> Maybe UpdateStatus)
-> (LastUpdate -> Maybe UpdateStatus -> LastUpdate)
-> Lens
     LastUpdate LastUpdate (Maybe UpdateStatus) (Maybe UpdateStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LastUpdate' {Maybe UpdateStatus
status :: Maybe UpdateStatus
$sel:status:LastUpdate' :: LastUpdate -> Maybe UpdateStatus
status} -> Maybe UpdateStatus
status) (\s :: LastUpdate
s@LastUpdate' {} Maybe UpdateStatus
a -> LastUpdate
s {$sel:status:LastUpdate' :: Maybe UpdateStatus
status = Maybe UpdateStatus
a} :: LastUpdate)

-- | The day and time of the last update on the environment.
lastUpdate_createdAt :: Lens.Lens' LastUpdate (Prelude.Maybe Prelude.UTCTime)
lastUpdate_createdAt :: (Maybe UTCTime -> f (Maybe UTCTime)) -> LastUpdate -> f LastUpdate
lastUpdate_createdAt = (LastUpdate -> Maybe POSIX)
-> (LastUpdate -> Maybe POSIX -> LastUpdate)
-> Lens LastUpdate LastUpdate (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LastUpdate' {Maybe POSIX
createdAt :: Maybe POSIX
$sel:createdAt:LastUpdate' :: LastUpdate -> Maybe POSIX
createdAt} -> Maybe POSIX
createdAt) (\s :: LastUpdate
s@LastUpdate' {} Maybe POSIX
a -> LastUpdate
s {$sel:createdAt:LastUpdate' :: Maybe POSIX
createdAt = Maybe POSIX
a} :: LastUpdate) ((Maybe POSIX -> f (Maybe POSIX)) -> LastUpdate -> f LastUpdate)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> LastUpdate
-> f LastUpdate
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 error that was encountered during the last update of the
-- environment.
lastUpdate_error :: Lens.Lens' LastUpdate (Prelude.Maybe UpdateError)
lastUpdate_error :: (Maybe UpdateError -> f (Maybe UpdateError))
-> LastUpdate -> f LastUpdate
lastUpdate_error = (LastUpdate -> Maybe UpdateError)
-> (LastUpdate -> Maybe UpdateError -> LastUpdate)
-> Lens
     LastUpdate LastUpdate (Maybe UpdateError) (Maybe UpdateError)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LastUpdate' {Maybe UpdateError
error :: Maybe UpdateError
$sel:error:LastUpdate' :: LastUpdate -> Maybe UpdateError
error} -> Maybe UpdateError
error) (\s :: LastUpdate
s@LastUpdate' {} Maybe UpdateError
a -> LastUpdate
s {$sel:error:LastUpdate' :: Maybe UpdateError
error = Maybe UpdateError
a} :: LastUpdate)

instance Core.FromJSON LastUpdate where
  parseJSON :: Value -> Parser LastUpdate
parseJSON =
    String
-> (Object -> Parser LastUpdate) -> Value -> Parser LastUpdate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LastUpdate"
      ( \Object
x ->
          Maybe UpdateStatus
-> Maybe POSIX -> Maybe UpdateError -> LastUpdate
LastUpdate'
            (Maybe UpdateStatus
 -> Maybe POSIX -> Maybe UpdateError -> LastUpdate)
-> Parser (Maybe UpdateStatus)
-> Parser (Maybe POSIX -> Maybe UpdateError -> LastUpdate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe UpdateStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser (Maybe POSIX -> Maybe UpdateError -> LastUpdate)
-> Parser (Maybe POSIX) -> Parser (Maybe UpdateError -> LastUpdate)
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
"CreatedAt")
            Parser (Maybe UpdateError -> LastUpdate)
-> Parser (Maybe UpdateError) -> Parser LastUpdate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe UpdateError)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Error")
      )

instance Prelude.Hashable LastUpdate

instance Prelude.NFData LastUpdate