{-# 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.EMR.Types.InstanceTimeline
-- 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.EMR.Types.InstanceTimeline where

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

-- | The timeline of the instance lifecycle.
--
-- /See:/ 'newInstanceTimeline' smart constructor.
data InstanceTimeline = InstanceTimeline'
  { -- | The date and time when the instance was ready to perform tasks.
    InstanceTimeline -> Maybe POSIX
readyDateTime :: Prelude.Maybe Core.POSIX,
    -- | The creation date and time of the instance.
    InstanceTimeline -> Maybe POSIX
creationDateTime :: Prelude.Maybe Core.POSIX,
    -- | The date and time when the instance was terminated.
    InstanceTimeline -> Maybe POSIX
endDateTime :: Prelude.Maybe Core.POSIX
  }
  deriving (InstanceTimeline -> InstanceTimeline -> Bool
(InstanceTimeline -> InstanceTimeline -> Bool)
-> (InstanceTimeline -> InstanceTimeline -> Bool)
-> Eq InstanceTimeline
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceTimeline -> InstanceTimeline -> Bool
$c/= :: InstanceTimeline -> InstanceTimeline -> Bool
== :: InstanceTimeline -> InstanceTimeline -> Bool
$c== :: InstanceTimeline -> InstanceTimeline -> Bool
Prelude.Eq, ReadPrec [InstanceTimeline]
ReadPrec InstanceTimeline
Int -> ReadS InstanceTimeline
ReadS [InstanceTimeline]
(Int -> ReadS InstanceTimeline)
-> ReadS [InstanceTimeline]
-> ReadPrec InstanceTimeline
-> ReadPrec [InstanceTimeline]
-> Read InstanceTimeline
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceTimeline]
$creadListPrec :: ReadPrec [InstanceTimeline]
readPrec :: ReadPrec InstanceTimeline
$creadPrec :: ReadPrec InstanceTimeline
readList :: ReadS [InstanceTimeline]
$creadList :: ReadS [InstanceTimeline]
readsPrec :: Int -> ReadS InstanceTimeline
$creadsPrec :: Int -> ReadS InstanceTimeline
Prelude.Read, Int -> InstanceTimeline -> ShowS
[InstanceTimeline] -> ShowS
InstanceTimeline -> String
(Int -> InstanceTimeline -> ShowS)
-> (InstanceTimeline -> String)
-> ([InstanceTimeline] -> ShowS)
-> Show InstanceTimeline
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceTimeline] -> ShowS
$cshowList :: [InstanceTimeline] -> ShowS
show :: InstanceTimeline -> String
$cshow :: InstanceTimeline -> String
showsPrec :: Int -> InstanceTimeline -> ShowS
$cshowsPrec :: Int -> InstanceTimeline -> ShowS
Prelude.Show, (forall x. InstanceTimeline -> Rep InstanceTimeline x)
-> (forall x. Rep InstanceTimeline x -> InstanceTimeline)
-> Generic InstanceTimeline
forall x. Rep InstanceTimeline x -> InstanceTimeline
forall x. InstanceTimeline -> Rep InstanceTimeline x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceTimeline x -> InstanceTimeline
$cfrom :: forall x. InstanceTimeline -> Rep InstanceTimeline x
Prelude.Generic)

-- |
-- Create a value of 'InstanceTimeline' 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:
--
-- 'readyDateTime', 'instanceTimeline_readyDateTime' - The date and time when the instance was ready to perform tasks.
--
-- 'creationDateTime', 'instanceTimeline_creationDateTime' - The creation date and time of the instance.
--
-- 'endDateTime', 'instanceTimeline_endDateTime' - The date and time when the instance was terminated.
newInstanceTimeline ::
  InstanceTimeline
newInstanceTimeline :: InstanceTimeline
newInstanceTimeline =
  InstanceTimeline' :: Maybe POSIX -> Maybe POSIX -> Maybe POSIX -> InstanceTimeline
InstanceTimeline'
    { $sel:readyDateTime:InstanceTimeline' :: Maybe POSIX
readyDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:creationDateTime:InstanceTimeline' :: Maybe POSIX
creationDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:endDateTime:InstanceTimeline' :: Maybe POSIX
endDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time when the instance was ready to perform tasks.
instanceTimeline_readyDateTime :: Lens.Lens' InstanceTimeline (Prelude.Maybe Prelude.UTCTime)
instanceTimeline_readyDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> InstanceTimeline -> f InstanceTimeline
instanceTimeline_readyDateTime = (InstanceTimeline -> Maybe POSIX)
-> (InstanceTimeline -> Maybe POSIX -> InstanceTimeline)
-> Lens
     InstanceTimeline InstanceTimeline (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceTimeline' {Maybe POSIX
readyDateTime :: Maybe POSIX
$sel:readyDateTime:InstanceTimeline' :: InstanceTimeline -> Maybe POSIX
readyDateTime} -> Maybe POSIX
readyDateTime) (\s :: InstanceTimeline
s@InstanceTimeline' {} Maybe POSIX
a -> InstanceTimeline
s {$sel:readyDateTime:InstanceTimeline' :: Maybe POSIX
readyDateTime = Maybe POSIX
a} :: InstanceTimeline) ((Maybe POSIX -> f (Maybe POSIX))
 -> InstanceTimeline -> f InstanceTimeline)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> InstanceTimeline
-> f InstanceTimeline
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 creation date and time of the instance.
instanceTimeline_creationDateTime :: Lens.Lens' InstanceTimeline (Prelude.Maybe Prelude.UTCTime)
instanceTimeline_creationDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> InstanceTimeline -> f InstanceTimeline
instanceTimeline_creationDateTime = (InstanceTimeline -> Maybe POSIX)
-> (InstanceTimeline -> Maybe POSIX -> InstanceTimeline)
-> Lens
     InstanceTimeline InstanceTimeline (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceTimeline' {Maybe POSIX
creationDateTime :: Maybe POSIX
$sel:creationDateTime:InstanceTimeline' :: InstanceTimeline -> Maybe POSIX
creationDateTime} -> Maybe POSIX
creationDateTime) (\s :: InstanceTimeline
s@InstanceTimeline' {} Maybe POSIX
a -> InstanceTimeline
s {$sel:creationDateTime:InstanceTimeline' :: Maybe POSIX
creationDateTime = Maybe POSIX
a} :: InstanceTimeline) ((Maybe POSIX -> f (Maybe POSIX))
 -> InstanceTimeline -> f InstanceTimeline)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> InstanceTimeline
-> f InstanceTimeline
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 date and time when the instance was terminated.
instanceTimeline_endDateTime :: Lens.Lens' InstanceTimeline (Prelude.Maybe Prelude.UTCTime)
instanceTimeline_endDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> InstanceTimeline -> f InstanceTimeline
instanceTimeline_endDateTime = (InstanceTimeline -> Maybe POSIX)
-> (InstanceTimeline -> Maybe POSIX -> InstanceTimeline)
-> Lens
     InstanceTimeline InstanceTimeline (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceTimeline' {Maybe POSIX
endDateTime :: Maybe POSIX
$sel:endDateTime:InstanceTimeline' :: InstanceTimeline -> Maybe POSIX
endDateTime} -> Maybe POSIX
endDateTime) (\s :: InstanceTimeline
s@InstanceTimeline' {} Maybe POSIX
a -> InstanceTimeline
s {$sel:endDateTime:InstanceTimeline' :: Maybe POSIX
endDateTime = Maybe POSIX
a} :: InstanceTimeline) ((Maybe POSIX -> f (Maybe POSIX))
 -> InstanceTimeline -> f InstanceTimeline)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> InstanceTimeline
-> f InstanceTimeline
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 InstanceTimeline where
  parseJSON :: Value -> Parser InstanceTimeline
parseJSON =
    String
-> (Object -> Parser InstanceTimeline)
-> Value
-> Parser InstanceTimeline
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InstanceTimeline"
      ( \Object
x ->
          Maybe POSIX -> Maybe POSIX -> Maybe POSIX -> InstanceTimeline
InstanceTimeline'
            (Maybe POSIX -> Maybe POSIX -> Maybe POSIX -> InstanceTimeline)
-> Parser (Maybe POSIX)
-> Parser (Maybe POSIX -> Maybe POSIX -> InstanceTimeline)
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
"ReadyDateTime")
            Parser (Maybe POSIX -> Maybe POSIX -> InstanceTimeline)
-> Parser (Maybe POSIX) -> Parser (Maybe POSIX -> InstanceTimeline)
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
"CreationDateTime")
            Parser (Maybe POSIX -> InstanceTimeline)
-> Parser (Maybe POSIX) -> Parser InstanceTimeline
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
"EndDateTime")
      )

instance Prelude.Hashable InstanceTimeline

instance Prelude.NFData InstanceTimeline