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

import qualified Amazonka.Core as Core
import Amazonka.EMR.Types.InstanceState
import Amazonka.EMR.Types.InstanceStateChangeReason
import Amazonka.EMR.Types.InstanceTimeline
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The instance status details.
--
-- /See:/ 'newInstanceStatus' smart constructor.
data InstanceStatus = InstanceStatus'
  { -- | The current state of the instance.
    InstanceStatus -> Maybe InstanceState
state :: Prelude.Maybe InstanceState,
    -- | The details of the status change reason for the instance.
    InstanceStatus -> Maybe InstanceStateChangeReason
stateChangeReason :: Prelude.Maybe InstanceStateChangeReason,
    -- | The timeline of the instance status over time.
    InstanceStatus -> Maybe InstanceTimeline
timeline :: Prelude.Maybe InstanceTimeline
  }
  deriving (InstanceStatus -> InstanceStatus -> Bool
(InstanceStatus -> InstanceStatus -> Bool)
-> (InstanceStatus -> InstanceStatus -> Bool) -> Eq InstanceStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceStatus -> InstanceStatus -> Bool
$c/= :: InstanceStatus -> InstanceStatus -> Bool
== :: InstanceStatus -> InstanceStatus -> Bool
$c== :: InstanceStatus -> InstanceStatus -> Bool
Prelude.Eq, ReadPrec [InstanceStatus]
ReadPrec InstanceStatus
Int -> ReadS InstanceStatus
ReadS [InstanceStatus]
(Int -> ReadS InstanceStatus)
-> ReadS [InstanceStatus]
-> ReadPrec InstanceStatus
-> ReadPrec [InstanceStatus]
-> Read InstanceStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceStatus]
$creadListPrec :: ReadPrec [InstanceStatus]
readPrec :: ReadPrec InstanceStatus
$creadPrec :: ReadPrec InstanceStatus
readList :: ReadS [InstanceStatus]
$creadList :: ReadS [InstanceStatus]
readsPrec :: Int -> ReadS InstanceStatus
$creadsPrec :: Int -> ReadS InstanceStatus
Prelude.Read, Int -> InstanceStatus -> ShowS
[InstanceStatus] -> ShowS
InstanceStatus -> String
(Int -> InstanceStatus -> ShowS)
-> (InstanceStatus -> String)
-> ([InstanceStatus] -> ShowS)
-> Show InstanceStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceStatus] -> ShowS
$cshowList :: [InstanceStatus] -> ShowS
show :: InstanceStatus -> String
$cshow :: InstanceStatus -> String
showsPrec :: Int -> InstanceStatus -> ShowS
$cshowsPrec :: Int -> InstanceStatus -> ShowS
Prelude.Show, (forall x. InstanceStatus -> Rep InstanceStatus x)
-> (forall x. Rep InstanceStatus x -> InstanceStatus)
-> Generic InstanceStatus
forall x. Rep InstanceStatus x -> InstanceStatus
forall x. InstanceStatus -> Rep InstanceStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceStatus x -> InstanceStatus
$cfrom :: forall x. InstanceStatus -> Rep InstanceStatus x
Prelude.Generic)

-- |
-- Create a value of 'InstanceStatus' 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', 'instanceStatus_state' - The current state of the instance.
--
-- 'stateChangeReason', 'instanceStatus_stateChangeReason' - The details of the status change reason for the instance.
--
-- 'timeline', 'instanceStatus_timeline' - The timeline of the instance status over time.
newInstanceStatus ::
  InstanceStatus
newInstanceStatus :: InstanceStatus
newInstanceStatus =
  InstanceStatus' :: Maybe InstanceState
-> Maybe InstanceStateChangeReason
-> Maybe InstanceTimeline
-> InstanceStatus
InstanceStatus'
    { $sel:state:InstanceStatus' :: Maybe InstanceState
state = Maybe InstanceState
forall a. Maybe a
Prelude.Nothing,
      $sel:stateChangeReason:InstanceStatus' :: Maybe InstanceStateChangeReason
stateChangeReason = Maybe InstanceStateChangeReason
forall a. Maybe a
Prelude.Nothing,
      $sel:timeline:InstanceStatus' :: Maybe InstanceTimeline
timeline = Maybe InstanceTimeline
forall a. Maybe a
Prelude.Nothing
    }

-- | The current state of the instance.
instanceStatus_state :: Lens.Lens' InstanceStatus (Prelude.Maybe InstanceState)
instanceStatus_state :: (Maybe InstanceState -> f (Maybe InstanceState))
-> InstanceStatus -> f InstanceStatus
instanceStatus_state = (InstanceStatus -> Maybe InstanceState)
-> (InstanceStatus -> Maybe InstanceState -> InstanceStatus)
-> Lens
     InstanceStatus
     InstanceStatus
     (Maybe InstanceState)
     (Maybe InstanceState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceStatus' {Maybe InstanceState
state :: Maybe InstanceState
$sel:state:InstanceStatus' :: InstanceStatus -> Maybe InstanceState
state} -> Maybe InstanceState
state) (\s :: InstanceStatus
s@InstanceStatus' {} Maybe InstanceState
a -> InstanceStatus
s {$sel:state:InstanceStatus' :: Maybe InstanceState
state = Maybe InstanceState
a} :: InstanceStatus)

-- | The details of the status change reason for the instance.
instanceStatus_stateChangeReason :: Lens.Lens' InstanceStatus (Prelude.Maybe InstanceStateChangeReason)
instanceStatus_stateChangeReason :: (Maybe InstanceStateChangeReason
 -> f (Maybe InstanceStateChangeReason))
-> InstanceStatus -> f InstanceStatus
instanceStatus_stateChangeReason = (InstanceStatus -> Maybe InstanceStateChangeReason)
-> (InstanceStatus
    -> Maybe InstanceStateChangeReason -> InstanceStatus)
-> Lens
     InstanceStatus
     InstanceStatus
     (Maybe InstanceStateChangeReason)
     (Maybe InstanceStateChangeReason)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceStatus' {Maybe InstanceStateChangeReason
stateChangeReason :: Maybe InstanceStateChangeReason
$sel:stateChangeReason:InstanceStatus' :: InstanceStatus -> Maybe InstanceStateChangeReason
stateChangeReason} -> Maybe InstanceStateChangeReason
stateChangeReason) (\s :: InstanceStatus
s@InstanceStatus' {} Maybe InstanceStateChangeReason
a -> InstanceStatus
s {$sel:stateChangeReason:InstanceStatus' :: Maybe InstanceStateChangeReason
stateChangeReason = Maybe InstanceStateChangeReason
a} :: InstanceStatus)

-- | The timeline of the instance status over time.
instanceStatus_timeline :: Lens.Lens' InstanceStatus (Prelude.Maybe InstanceTimeline)
instanceStatus_timeline :: (Maybe InstanceTimeline -> f (Maybe InstanceTimeline))
-> InstanceStatus -> f InstanceStatus
instanceStatus_timeline = (InstanceStatus -> Maybe InstanceTimeline)
-> (InstanceStatus -> Maybe InstanceTimeline -> InstanceStatus)
-> Lens
     InstanceStatus
     InstanceStatus
     (Maybe InstanceTimeline)
     (Maybe InstanceTimeline)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceStatus' {Maybe InstanceTimeline
timeline :: Maybe InstanceTimeline
$sel:timeline:InstanceStatus' :: InstanceStatus -> Maybe InstanceTimeline
timeline} -> Maybe InstanceTimeline
timeline) (\s :: InstanceStatus
s@InstanceStatus' {} Maybe InstanceTimeline
a -> InstanceStatus
s {$sel:timeline:InstanceStatus' :: Maybe InstanceTimeline
timeline = Maybe InstanceTimeline
a} :: InstanceStatus)

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

instance Prelude.Hashable InstanceStatus

instance Prelude.NFData InstanceStatus