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

import qualified Amazonka.Core as Core
import Amazonka.EMR.Types.InstanceFleetState
import Amazonka.EMR.Types.InstanceFleetStateChangeReason
import Amazonka.EMR.Types.InstanceFleetTimeline
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The status of the instance fleet.
--
-- The instance fleet configuration is available only in Amazon EMR
-- versions 4.8.0 and later, excluding 5.0.x versions.
--
-- /See:/ 'newInstanceFleetStatus' smart constructor.
data InstanceFleetStatus = InstanceFleetStatus'
  { -- | A code representing the instance fleet status.
    --
    -- -   @PROVISIONING@—The instance fleet is provisioning EC2 resources and
    --     is not yet ready to run jobs.
    --
    -- -   @BOOTSTRAPPING@—EC2 instances and other resources have been
    --     provisioned and the bootstrap actions specified for the instances
    --     are underway.
    --
    -- -   @RUNNING@—EC2 instances and other resources are running. They are
    --     either executing jobs or waiting to execute jobs.
    --
    -- -   @RESIZING@—A resize operation is underway. EC2 instances are either
    --     being added or removed.
    --
    -- -   @SUSPENDED@—A resize operation could not complete. Existing EC2
    --     instances are running, but instances can\'t be added or removed.
    --
    -- -   @TERMINATING@—The instance fleet is terminating EC2 instances.
    --
    -- -   @TERMINATED@—The instance fleet is no longer active, and all EC2
    --     instances have been terminated.
    InstanceFleetStatus -> Maybe InstanceFleetState
state :: Prelude.Maybe InstanceFleetState,
    -- | Provides status change reason details for the instance fleet.
    InstanceFleetStatus -> Maybe InstanceFleetStateChangeReason
stateChangeReason :: Prelude.Maybe InstanceFleetStateChangeReason,
    -- | Provides historical timestamps for the instance fleet, including the
    -- time of creation, the time it became ready to run jobs, and the time of
    -- termination.
    InstanceFleetStatus -> Maybe InstanceFleetTimeline
timeline :: Prelude.Maybe InstanceFleetTimeline
  }
  deriving (InstanceFleetStatus -> InstanceFleetStatus -> Bool
(InstanceFleetStatus -> InstanceFleetStatus -> Bool)
-> (InstanceFleetStatus -> InstanceFleetStatus -> Bool)
-> Eq InstanceFleetStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceFleetStatus -> InstanceFleetStatus -> Bool
$c/= :: InstanceFleetStatus -> InstanceFleetStatus -> Bool
== :: InstanceFleetStatus -> InstanceFleetStatus -> Bool
$c== :: InstanceFleetStatus -> InstanceFleetStatus -> Bool
Prelude.Eq, ReadPrec [InstanceFleetStatus]
ReadPrec InstanceFleetStatus
Int -> ReadS InstanceFleetStatus
ReadS [InstanceFleetStatus]
(Int -> ReadS InstanceFleetStatus)
-> ReadS [InstanceFleetStatus]
-> ReadPrec InstanceFleetStatus
-> ReadPrec [InstanceFleetStatus]
-> Read InstanceFleetStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceFleetStatus]
$creadListPrec :: ReadPrec [InstanceFleetStatus]
readPrec :: ReadPrec InstanceFleetStatus
$creadPrec :: ReadPrec InstanceFleetStatus
readList :: ReadS [InstanceFleetStatus]
$creadList :: ReadS [InstanceFleetStatus]
readsPrec :: Int -> ReadS InstanceFleetStatus
$creadsPrec :: Int -> ReadS InstanceFleetStatus
Prelude.Read, Int -> InstanceFleetStatus -> ShowS
[InstanceFleetStatus] -> ShowS
InstanceFleetStatus -> String
(Int -> InstanceFleetStatus -> ShowS)
-> (InstanceFleetStatus -> String)
-> ([InstanceFleetStatus] -> ShowS)
-> Show InstanceFleetStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceFleetStatus] -> ShowS
$cshowList :: [InstanceFleetStatus] -> ShowS
show :: InstanceFleetStatus -> String
$cshow :: InstanceFleetStatus -> String
showsPrec :: Int -> InstanceFleetStatus -> ShowS
$cshowsPrec :: Int -> InstanceFleetStatus -> ShowS
Prelude.Show, (forall x. InstanceFleetStatus -> Rep InstanceFleetStatus x)
-> (forall x. Rep InstanceFleetStatus x -> InstanceFleetStatus)
-> Generic InstanceFleetStatus
forall x. Rep InstanceFleetStatus x -> InstanceFleetStatus
forall x. InstanceFleetStatus -> Rep InstanceFleetStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceFleetStatus x -> InstanceFleetStatus
$cfrom :: forall x. InstanceFleetStatus -> Rep InstanceFleetStatus x
Prelude.Generic)

-- |
-- Create a value of 'InstanceFleetStatus' 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', 'instanceFleetStatus_state' - A code representing the instance fleet status.
--
-- -   @PROVISIONING@—The instance fleet is provisioning EC2 resources and
--     is not yet ready to run jobs.
--
-- -   @BOOTSTRAPPING@—EC2 instances and other resources have been
--     provisioned and the bootstrap actions specified for the instances
--     are underway.
--
-- -   @RUNNING@—EC2 instances and other resources are running. They are
--     either executing jobs or waiting to execute jobs.
--
-- -   @RESIZING@—A resize operation is underway. EC2 instances are either
--     being added or removed.
--
-- -   @SUSPENDED@—A resize operation could not complete. Existing EC2
--     instances are running, but instances can\'t be added or removed.
--
-- -   @TERMINATING@—The instance fleet is terminating EC2 instances.
--
-- -   @TERMINATED@—The instance fleet is no longer active, and all EC2
--     instances have been terminated.
--
-- 'stateChangeReason', 'instanceFleetStatus_stateChangeReason' - Provides status change reason details for the instance fleet.
--
-- 'timeline', 'instanceFleetStatus_timeline' - Provides historical timestamps for the instance fleet, including the
-- time of creation, the time it became ready to run jobs, and the time of
-- termination.
newInstanceFleetStatus ::
  InstanceFleetStatus
newInstanceFleetStatus :: InstanceFleetStatus
newInstanceFleetStatus =
  InstanceFleetStatus' :: Maybe InstanceFleetState
-> Maybe InstanceFleetStateChangeReason
-> Maybe InstanceFleetTimeline
-> InstanceFleetStatus
InstanceFleetStatus'
    { $sel:state:InstanceFleetStatus' :: Maybe InstanceFleetState
state = Maybe InstanceFleetState
forall a. Maybe a
Prelude.Nothing,
      $sel:stateChangeReason:InstanceFleetStatus' :: Maybe InstanceFleetStateChangeReason
stateChangeReason = Maybe InstanceFleetStateChangeReason
forall a. Maybe a
Prelude.Nothing,
      $sel:timeline:InstanceFleetStatus' :: Maybe InstanceFleetTimeline
timeline = Maybe InstanceFleetTimeline
forall a. Maybe a
Prelude.Nothing
    }

-- | A code representing the instance fleet status.
--
-- -   @PROVISIONING@—The instance fleet is provisioning EC2 resources and
--     is not yet ready to run jobs.
--
-- -   @BOOTSTRAPPING@—EC2 instances and other resources have been
--     provisioned and the bootstrap actions specified for the instances
--     are underway.
--
-- -   @RUNNING@—EC2 instances and other resources are running. They are
--     either executing jobs or waiting to execute jobs.
--
-- -   @RESIZING@—A resize operation is underway. EC2 instances are either
--     being added or removed.
--
-- -   @SUSPENDED@—A resize operation could not complete. Existing EC2
--     instances are running, but instances can\'t be added or removed.
--
-- -   @TERMINATING@—The instance fleet is terminating EC2 instances.
--
-- -   @TERMINATED@—The instance fleet is no longer active, and all EC2
--     instances have been terminated.
instanceFleetStatus_state :: Lens.Lens' InstanceFleetStatus (Prelude.Maybe InstanceFleetState)
instanceFleetStatus_state :: (Maybe InstanceFleetState -> f (Maybe InstanceFleetState))
-> InstanceFleetStatus -> f InstanceFleetStatus
instanceFleetStatus_state = (InstanceFleetStatus -> Maybe InstanceFleetState)
-> (InstanceFleetStatus
    -> Maybe InstanceFleetState -> InstanceFleetStatus)
-> Lens
     InstanceFleetStatus
     InstanceFleetStatus
     (Maybe InstanceFleetState)
     (Maybe InstanceFleetState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceFleetStatus' {Maybe InstanceFleetState
state :: Maybe InstanceFleetState
$sel:state:InstanceFleetStatus' :: InstanceFleetStatus -> Maybe InstanceFleetState
state} -> Maybe InstanceFleetState
state) (\s :: InstanceFleetStatus
s@InstanceFleetStatus' {} Maybe InstanceFleetState
a -> InstanceFleetStatus
s {$sel:state:InstanceFleetStatus' :: Maybe InstanceFleetState
state = Maybe InstanceFleetState
a} :: InstanceFleetStatus)

-- | Provides status change reason details for the instance fleet.
instanceFleetStatus_stateChangeReason :: Lens.Lens' InstanceFleetStatus (Prelude.Maybe InstanceFleetStateChangeReason)
instanceFleetStatus_stateChangeReason :: (Maybe InstanceFleetStateChangeReason
 -> f (Maybe InstanceFleetStateChangeReason))
-> InstanceFleetStatus -> f InstanceFleetStatus
instanceFleetStatus_stateChangeReason = (InstanceFleetStatus -> Maybe InstanceFleetStateChangeReason)
-> (InstanceFleetStatus
    -> Maybe InstanceFleetStateChangeReason -> InstanceFleetStatus)
-> Lens
     InstanceFleetStatus
     InstanceFleetStatus
     (Maybe InstanceFleetStateChangeReason)
     (Maybe InstanceFleetStateChangeReason)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceFleetStatus' {Maybe InstanceFleetStateChangeReason
stateChangeReason :: Maybe InstanceFleetStateChangeReason
$sel:stateChangeReason:InstanceFleetStatus' :: InstanceFleetStatus -> Maybe InstanceFleetStateChangeReason
stateChangeReason} -> Maybe InstanceFleetStateChangeReason
stateChangeReason) (\s :: InstanceFleetStatus
s@InstanceFleetStatus' {} Maybe InstanceFleetStateChangeReason
a -> InstanceFleetStatus
s {$sel:stateChangeReason:InstanceFleetStatus' :: Maybe InstanceFleetStateChangeReason
stateChangeReason = Maybe InstanceFleetStateChangeReason
a} :: InstanceFleetStatus)

-- | Provides historical timestamps for the instance fleet, including the
-- time of creation, the time it became ready to run jobs, and the time of
-- termination.
instanceFleetStatus_timeline :: Lens.Lens' InstanceFleetStatus (Prelude.Maybe InstanceFleetTimeline)
instanceFleetStatus_timeline :: (Maybe InstanceFleetTimeline -> f (Maybe InstanceFleetTimeline))
-> InstanceFleetStatus -> f InstanceFleetStatus
instanceFleetStatus_timeline = (InstanceFleetStatus -> Maybe InstanceFleetTimeline)
-> (InstanceFleetStatus
    -> Maybe InstanceFleetTimeline -> InstanceFleetStatus)
-> Lens
     InstanceFleetStatus
     InstanceFleetStatus
     (Maybe InstanceFleetTimeline)
     (Maybe InstanceFleetTimeline)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceFleetStatus' {Maybe InstanceFleetTimeline
timeline :: Maybe InstanceFleetTimeline
$sel:timeline:InstanceFleetStatus' :: InstanceFleetStatus -> Maybe InstanceFleetTimeline
timeline} -> Maybe InstanceFleetTimeline
timeline) (\s :: InstanceFleetStatus
s@InstanceFleetStatus' {} Maybe InstanceFleetTimeline
a -> InstanceFleetStatus
s {$sel:timeline:InstanceFleetStatus' :: Maybe InstanceFleetTimeline
timeline = Maybe InstanceFleetTimeline
a} :: InstanceFleetStatus)

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

instance Prelude.Hashable InstanceFleetStatus

instance Prelude.NFData InstanceFleetStatus