{-# 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.ClusterStatus
-- 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.ClusterStatus where

import qualified Amazonka.Core as Core
import Amazonka.EMR.Types.ClusterState
import Amazonka.EMR.Types.ClusterStateChangeReason
import Amazonka.EMR.Types.ClusterTimeline
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The detailed status of the cluster.
--
-- /See:/ 'newClusterStatus' smart constructor.
data ClusterStatus = ClusterStatus'
  { -- | The current state of the cluster.
    ClusterStatus -> Maybe ClusterState
state :: Prelude.Maybe ClusterState,
    -- | The reason for the cluster status change.
    ClusterStatus -> Maybe ClusterStateChangeReason
stateChangeReason :: Prelude.Maybe ClusterStateChangeReason,
    -- | A timeline that represents the status of a cluster over the lifetime of
    -- the cluster.
    ClusterStatus -> Maybe ClusterTimeline
timeline :: Prelude.Maybe ClusterTimeline
  }
  deriving (ClusterStatus -> ClusterStatus -> Bool
(ClusterStatus -> ClusterStatus -> Bool)
-> (ClusterStatus -> ClusterStatus -> Bool) -> Eq ClusterStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClusterStatus -> ClusterStatus -> Bool
$c/= :: ClusterStatus -> ClusterStatus -> Bool
== :: ClusterStatus -> ClusterStatus -> Bool
$c== :: ClusterStatus -> ClusterStatus -> Bool
Prelude.Eq, ReadPrec [ClusterStatus]
ReadPrec ClusterStatus
Int -> ReadS ClusterStatus
ReadS [ClusterStatus]
(Int -> ReadS ClusterStatus)
-> ReadS [ClusterStatus]
-> ReadPrec ClusterStatus
-> ReadPrec [ClusterStatus]
-> Read ClusterStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ClusterStatus]
$creadListPrec :: ReadPrec [ClusterStatus]
readPrec :: ReadPrec ClusterStatus
$creadPrec :: ReadPrec ClusterStatus
readList :: ReadS [ClusterStatus]
$creadList :: ReadS [ClusterStatus]
readsPrec :: Int -> ReadS ClusterStatus
$creadsPrec :: Int -> ReadS ClusterStatus
Prelude.Read, Int -> ClusterStatus -> ShowS
[ClusterStatus] -> ShowS
ClusterStatus -> String
(Int -> ClusterStatus -> ShowS)
-> (ClusterStatus -> String)
-> ([ClusterStatus] -> ShowS)
-> Show ClusterStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClusterStatus] -> ShowS
$cshowList :: [ClusterStatus] -> ShowS
show :: ClusterStatus -> String
$cshow :: ClusterStatus -> String
showsPrec :: Int -> ClusterStatus -> ShowS
$cshowsPrec :: Int -> ClusterStatus -> ShowS
Prelude.Show, (forall x. ClusterStatus -> Rep ClusterStatus x)
-> (forall x. Rep ClusterStatus x -> ClusterStatus)
-> Generic ClusterStatus
forall x. Rep ClusterStatus x -> ClusterStatus
forall x. ClusterStatus -> Rep ClusterStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ClusterStatus x -> ClusterStatus
$cfrom :: forall x. ClusterStatus -> Rep ClusterStatus x
Prelude.Generic)

-- |
-- Create a value of 'ClusterStatus' 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:
--
-- 'state', 'clusterStatus_state' - The current state of the cluster.
--
-- 'stateChangeReason', 'clusterStatus_stateChangeReason' - The reason for the cluster status change.
--
-- 'timeline', 'clusterStatus_timeline' - A timeline that represents the status of a cluster over the lifetime of
-- the cluster.
newClusterStatus ::
  ClusterStatus
newClusterStatus :: ClusterStatus
newClusterStatus =
  ClusterStatus' :: Maybe ClusterState
-> Maybe ClusterStateChangeReason
-> Maybe ClusterTimeline
-> ClusterStatus
ClusterStatus'
    { $sel:state:ClusterStatus' :: Maybe ClusterState
state = Maybe ClusterState
forall a. Maybe a
Prelude.Nothing,
      $sel:stateChangeReason:ClusterStatus' :: Maybe ClusterStateChangeReason
stateChangeReason = Maybe ClusterStateChangeReason
forall a. Maybe a
Prelude.Nothing,
      $sel:timeline:ClusterStatus' :: Maybe ClusterTimeline
timeline = Maybe ClusterTimeline
forall a. Maybe a
Prelude.Nothing
    }

-- | The current state of the cluster.
clusterStatus_state :: Lens.Lens' ClusterStatus (Prelude.Maybe ClusterState)
clusterStatus_state :: (Maybe ClusterState -> f (Maybe ClusterState))
-> ClusterStatus -> f ClusterStatus
clusterStatus_state = (ClusterStatus -> Maybe ClusterState)
-> (ClusterStatus -> Maybe ClusterState -> ClusterStatus)
-> Lens
     ClusterStatus
     ClusterStatus
     (Maybe ClusterState)
     (Maybe ClusterState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterStatus' {Maybe ClusterState
state :: Maybe ClusterState
$sel:state:ClusterStatus' :: ClusterStatus -> Maybe ClusterState
state} -> Maybe ClusterState
state) (\s :: ClusterStatus
s@ClusterStatus' {} Maybe ClusterState
a -> ClusterStatus
s {$sel:state:ClusterStatus' :: Maybe ClusterState
state = Maybe ClusterState
a} :: ClusterStatus)

-- | The reason for the cluster status change.
clusterStatus_stateChangeReason :: Lens.Lens' ClusterStatus (Prelude.Maybe ClusterStateChangeReason)
clusterStatus_stateChangeReason :: (Maybe ClusterStateChangeReason
 -> f (Maybe ClusterStateChangeReason))
-> ClusterStatus -> f ClusterStatus
clusterStatus_stateChangeReason = (ClusterStatus -> Maybe ClusterStateChangeReason)
-> (ClusterStatus
    -> Maybe ClusterStateChangeReason -> ClusterStatus)
-> Lens
     ClusterStatus
     ClusterStatus
     (Maybe ClusterStateChangeReason)
     (Maybe ClusterStateChangeReason)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterStatus' {Maybe ClusterStateChangeReason
stateChangeReason :: Maybe ClusterStateChangeReason
$sel:stateChangeReason:ClusterStatus' :: ClusterStatus -> Maybe ClusterStateChangeReason
stateChangeReason} -> Maybe ClusterStateChangeReason
stateChangeReason) (\s :: ClusterStatus
s@ClusterStatus' {} Maybe ClusterStateChangeReason
a -> ClusterStatus
s {$sel:stateChangeReason:ClusterStatus' :: Maybe ClusterStateChangeReason
stateChangeReason = Maybe ClusterStateChangeReason
a} :: ClusterStatus)

-- | A timeline that represents the status of a cluster over the lifetime of
-- the cluster.
clusterStatus_timeline :: Lens.Lens' ClusterStatus (Prelude.Maybe ClusterTimeline)
clusterStatus_timeline :: (Maybe ClusterTimeline -> f (Maybe ClusterTimeline))
-> ClusterStatus -> f ClusterStatus
clusterStatus_timeline = (ClusterStatus -> Maybe ClusterTimeline)
-> (ClusterStatus -> Maybe ClusterTimeline -> ClusterStatus)
-> Lens
     ClusterStatus
     ClusterStatus
     (Maybe ClusterTimeline)
     (Maybe ClusterTimeline)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterStatus' {Maybe ClusterTimeline
timeline :: Maybe ClusterTimeline
$sel:timeline:ClusterStatus' :: ClusterStatus -> Maybe ClusterTimeline
timeline} -> Maybe ClusterTimeline
timeline) (\s :: ClusterStatus
s@ClusterStatus' {} Maybe ClusterTimeline
a -> ClusterStatus
s {$sel:timeline:ClusterStatus' :: Maybe ClusterTimeline
timeline = Maybe ClusterTimeline
a} :: ClusterStatus)

instance Core.FromJSON ClusterStatus where
  parseJSON :: Value -> Parser ClusterStatus
parseJSON =
    String
-> (Object -> Parser ClusterStatus)
-> Value
-> Parser ClusterStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ClusterStatus"
      ( \Object
x ->
          Maybe ClusterState
-> Maybe ClusterStateChangeReason
-> Maybe ClusterTimeline
-> ClusterStatus
ClusterStatus'
            (Maybe ClusterState
 -> Maybe ClusterStateChangeReason
 -> Maybe ClusterTimeline
 -> ClusterStatus)
-> Parser (Maybe ClusterState)
-> Parser
     (Maybe ClusterStateChangeReason
      -> Maybe ClusterTimeline -> ClusterStatus)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ClusterState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"State")
            Parser
  (Maybe ClusterStateChangeReason
   -> Maybe ClusterTimeline -> ClusterStatus)
-> Parser (Maybe ClusterStateChangeReason)
-> Parser (Maybe ClusterTimeline -> ClusterStatus)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ClusterStateChangeReason)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StateChangeReason")
            Parser (Maybe ClusterTimeline -> ClusterStatus)
-> Parser (Maybe ClusterTimeline) -> Parser ClusterStatus
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ClusterTimeline)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Timeline")
      )

instance Prelude.Hashable ClusterStatus

instance Prelude.NFData ClusterStatus