{-# 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.ClusterTimeline
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.EMR.Types.ClusterTimeline where

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

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

-- |
-- Create a value of 'ClusterTimeline' 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:
--
-- 'creationDateTime', 'clusterTimeline_creationDateTime' - The creation date and time of the cluster.
--
-- 'endDateTime', 'clusterTimeline_endDateTime' - The date and time when the cluster was terminated.
--
-- 'readyDateTime', 'clusterTimeline_readyDateTime' - The date and time when the cluster was ready to run steps.
newClusterTimeline ::
  ClusterTimeline
newClusterTimeline :: ClusterTimeline
newClusterTimeline =
  ClusterTimeline'
    { $sel:creationDateTime:ClusterTimeline' :: Maybe POSIX
creationDateTime =
        forall a. Maybe a
Prelude.Nothing,
      $sel:endDateTime:ClusterTimeline' :: Maybe POSIX
endDateTime = forall a. Maybe a
Prelude.Nothing,
      $sel:readyDateTime:ClusterTimeline' :: Maybe POSIX
readyDateTime = forall a. Maybe a
Prelude.Nothing
    }

-- | The creation date and time of the cluster.
clusterTimeline_creationDateTime :: Lens.Lens' ClusterTimeline (Prelude.Maybe Prelude.UTCTime)
clusterTimeline_creationDateTime :: Lens' ClusterTimeline (Maybe UTCTime)
clusterTimeline_creationDateTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterTimeline' {Maybe POSIX
creationDateTime :: Maybe POSIX
$sel:creationDateTime:ClusterTimeline' :: ClusterTimeline -> Maybe POSIX
creationDateTime} -> Maybe POSIX
creationDateTime) (\s :: ClusterTimeline
s@ClusterTimeline' {} Maybe POSIX
a -> ClusterTimeline
s {$sel:creationDateTime:ClusterTimeline' :: Maybe POSIX
creationDateTime = Maybe POSIX
a} :: ClusterTimeline) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The date and time when the cluster was terminated.
clusterTimeline_endDateTime :: Lens.Lens' ClusterTimeline (Prelude.Maybe Prelude.UTCTime)
clusterTimeline_endDateTime :: Lens' ClusterTimeline (Maybe UTCTime)
clusterTimeline_endDateTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterTimeline' {Maybe POSIX
endDateTime :: Maybe POSIX
$sel:endDateTime:ClusterTimeline' :: ClusterTimeline -> Maybe POSIX
endDateTime} -> Maybe POSIX
endDateTime) (\s :: ClusterTimeline
s@ClusterTimeline' {} Maybe POSIX
a -> ClusterTimeline
s {$sel:endDateTime:ClusterTimeline' :: Maybe POSIX
endDateTime = Maybe POSIX
a} :: ClusterTimeline) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The date and time when the cluster was ready to run steps.
clusterTimeline_readyDateTime :: Lens.Lens' ClusterTimeline (Prelude.Maybe Prelude.UTCTime)
clusterTimeline_readyDateTime :: Lens' ClusterTimeline (Maybe UTCTime)
clusterTimeline_readyDateTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterTimeline' {Maybe POSIX
readyDateTime :: Maybe POSIX
$sel:readyDateTime:ClusterTimeline' :: ClusterTimeline -> Maybe POSIX
readyDateTime} -> Maybe POSIX
readyDateTime) (\s :: ClusterTimeline
s@ClusterTimeline' {} Maybe POSIX
a -> ClusterTimeline
s {$sel:readyDateTime:ClusterTimeline' :: Maybe POSIX
readyDateTime = Maybe POSIX
a} :: ClusterTimeline) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON ClusterTimeline where
  parseJSON :: Value -> Parser ClusterTimeline
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ClusterTimeline"
      ( \Object
x ->
          Maybe POSIX -> Maybe POSIX -> Maybe POSIX -> ClusterTimeline
ClusterTimeline'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CreationDateTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"EndDateTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ReadyDateTime")
      )

instance Prelude.Hashable ClusterTimeline where
  hashWithSalt :: Int -> ClusterTimeline -> Int
hashWithSalt Int
_salt ClusterTimeline' {Maybe POSIX
readyDateTime :: Maybe POSIX
endDateTime :: Maybe POSIX
creationDateTime :: Maybe POSIX
$sel:readyDateTime:ClusterTimeline' :: ClusterTimeline -> Maybe POSIX
$sel:endDateTime:ClusterTimeline' :: ClusterTimeline -> Maybe POSIX
$sel:creationDateTime:ClusterTimeline' :: ClusterTimeline -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationDateTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
endDateTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
readyDateTime

instance Prelude.NFData ClusterTimeline where
  rnf :: ClusterTimeline -> ()
rnf ClusterTimeline' {Maybe POSIX
readyDateTime :: Maybe POSIX
endDateTime :: Maybe POSIX
creationDateTime :: Maybe POSIX
$sel:readyDateTime:ClusterTimeline' :: ClusterTimeline -> Maybe POSIX
$sel:endDateTime:ClusterTimeline' :: ClusterTimeline -> Maybe POSIX
$sel:creationDateTime:ClusterTimeline' :: ClusterTimeline -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationDateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
endDateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
readyDateTime