{-# 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.EC2.Types.InstanceStateChange
-- 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.EC2.Types.InstanceStateChange where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import Amazonka.EC2.Types.InstanceState
import qualified Amazonka.Prelude as Prelude

-- | Describes an instance state change.
--
-- /See:/ 'newInstanceStateChange' smart constructor.
data InstanceStateChange = InstanceStateChange'
  { -- | The current state of the instance.
    InstanceStateChange -> Maybe InstanceState
currentState :: Prelude.Maybe InstanceState,
    -- | The ID of the instance.
    InstanceStateChange -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text,
    -- | The previous state of the instance.
    InstanceStateChange -> Maybe InstanceState
previousState :: Prelude.Maybe InstanceState
  }
  deriving (InstanceStateChange -> InstanceStateChange -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceStateChange -> InstanceStateChange -> Bool
$c/= :: InstanceStateChange -> InstanceStateChange -> Bool
== :: InstanceStateChange -> InstanceStateChange -> Bool
$c== :: InstanceStateChange -> InstanceStateChange -> Bool
Prelude.Eq, ReadPrec [InstanceStateChange]
ReadPrec InstanceStateChange
Int -> ReadS InstanceStateChange
ReadS [InstanceStateChange]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceStateChange]
$creadListPrec :: ReadPrec [InstanceStateChange]
readPrec :: ReadPrec InstanceStateChange
$creadPrec :: ReadPrec InstanceStateChange
readList :: ReadS [InstanceStateChange]
$creadList :: ReadS [InstanceStateChange]
readsPrec :: Int -> ReadS InstanceStateChange
$creadsPrec :: Int -> ReadS InstanceStateChange
Prelude.Read, Int -> InstanceStateChange -> ShowS
[InstanceStateChange] -> ShowS
InstanceStateChange -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceStateChange] -> ShowS
$cshowList :: [InstanceStateChange] -> ShowS
show :: InstanceStateChange -> String
$cshow :: InstanceStateChange -> String
showsPrec :: Int -> InstanceStateChange -> ShowS
$cshowsPrec :: Int -> InstanceStateChange -> ShowS
Prelude.Show, forall x. Rep InstanceStateChange x -> InstanceStateChange
forall x. InstanceStateChange -> Rep InstanceStateChange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceStateChange x -> InstanceStateChange
$cfrom :: forall x. InstanceStateChange -> Rep InstanceStateChange x
Prelude.Generic)

-- |
-- Create a value of 'InstanceStateChange' 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:
--
-- 'currentState', 'instanceStateChange_currentState' - The current state of the instance.
--
-- 'instanceId', 'instanceStateChange_instanceId' - The ID of the instance.
--
-- 'previousState', 'instanceStateChange_previousState' - The previous state of the instance.
newInstanceStateChange ::
  InstanceStateChange
newInstanceStateChange :: InstanceStateChange
newInstanceStateChange =
  InstanceStateChange'
    { $sel:currentState:InstanceStateChange' :: Maybe InstanceState
currentState =
        forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:InstanceStateChange' :: Maybe Text
instanceId = forall a. Maybe a
Prelude.Nothing,
      $sel:previousState:InstanceStateChange' :: Maybe InstanceState
previousState = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The ID of the instance.
instanceStateChange_instanceId :: Lens.Lens' InstanceStateChange (Prelude.Maybe Prelude.Text)
instanceStateChange_instanceId :: Lens' InstanceStateChange (Maybe Text)
instanceStateChange_instanceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceStateChange' {Maybe Text
instanceId :: Maybe Text
$sel:instanceId:InstanceStateChange' :: InstanceStateChange -> Maybe Text
instanceId} -> Maybe Text
instanceId) (\s :: InstanceStateChange
s@InstanceStateChange' {} Maybe Text
a -> InstanceStateChange
s {$sel:instanceId:InstanceStateChange' :: Maybe Text
instanceId = Maybe Text
a} :: InstanceStateChange)

-- | The previous state of the instance.
instanceStateChange_previousState :: Lens.Lens' InstanceStateChange (Prelude.Maybe InstanceState)
instanceStateChange_previousState :: Lens' InstanceStateChange (Maybe InstanceState)
instanceStateChange_previousState = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceStateChange' {Maybe InstanceState
previousState :: Maybe InstanceState
$sel:previousState:InstanceStateChange' :: InstanceStateChange -> Maybe InstanceState
previousState} -> Maybe InstanceState
previousState) (\s :: InstanceStateChange
s@InstanceStateChange' {} Maybe InstanceState
a -> InstanceStateChange
s {$sel:previousState:InstanceStateChange' :: Maybe InstanceState
previousState = Maybe InstanceState
a} :: InstanceStateChange)

instance Data.FromXML InstanceStateChange where
  parseXML :: [Node] -> Either String InstanceStateChange
parseXML [Node]
x =
    Maybe InstanceState
-> Maybe Text -> Maybe InstanceState -> InstanceStateChange
InstanceStateChange'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"currentState")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"instanceId")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"previousState")

instance Prelude.Hashable InstanceStateChange where
  hashWithSalt :: Int -> InstanceStateChange -> Int
hashWithSalt Int
_salt InstanceStateChange' {Maybe Text
Maybe InstanceState
previousState :: Maybe InstanceState
instanceId :: Maybe Text
currentState :: Maybe InstanceState
$sel:previousState:InstanceStateChange' :: InstanceStateChange -> Maybe InstanceState
$sel:instanceId:InstanceStateChange' :: InstanceStateChange -> Maybe Text
$sel:currentState:InstanceStateChange' :: InstanceStateChange -> Maybe InstanceState
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InstanceState
currentState
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
instanceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InstanceState
previousState

instance Prelude.NFData InstanceStateChange where
  rnf :: InstanceStateChange -> ()
rnf InstanceStateChange' {Maybe Text
Maybe InstanceState
previousState :: Maybe InstanceState
instanceId :: Maybe Text
currentState :: Maybe InstanceState
$sel:previousState:InstanceStateChange' :: InstanceStateChange -> Maybe InstanceState
$sel:instanceId:InstanceStateChange' :: InstanceStateChange -> Maybe Text
$sel:currentState:InstanceStateChange' :: InstanceStateChange -> Maybe InstanceState
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe InstanceState
currentState
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
instanceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe InstanceState
previousState