{-# 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.SpotInstanceStateFault
-- 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.SpotInstanceStateFault 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 qualified Amazonka.Prelude as Prelude

-- | Describes a Spot Instance state change.
--
-- /See:/ 'newSpotInstanceStateFault' smart constructor.
data SpotInstanceStateFault = SpotInstanceStateFault'
  { -- | The reason code for the Spot Instance state change.
    SpotInstanceStateFault -> Maybe Text
code :: Prelude.Maybe Prelude.Text,
    -- | The message for the Spot Instance state change.
    SpotInstanceStateFault -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (SpotInstanceStateFault -> SpotInstanceStateFault -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SpotInstanceStateFault -> SpotInstanceStateFault -> Bool
$c/= :: SpotInstanceStateFault -> SpotInstanceStateFault -> Bool
== :: SpotInstanceStateFault -> SpotInstanceStateFault -> Bool
$c== :: SpotInstanceStateFault -> SpotInstanceStateFault -> Bool
Prelude.Eq, ReadPrec [SpotInstanceStateFault]
ReadPrec SpotInstanceStateFault
Int -> ReadS SpotInstanceStateFault
ReadS [SpotInstanceStateFault]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SpotInstanceStateFault]
$creadListPrec :: ReadPrec [SpotInstanceStateFault]
readPrec :: ReadPrec SpotInstanceStateFault
$creadPrec :: ReadPrec SpotInstanceStateFault
readList :: ReadS [SpotInstanceStateFault]
$creadList :: ReadS [SpotInstanceStateFault]
readsPrec :: Int -> ReadS SpotInstanceStateFault
$creadsPrec :: Int -> ReadS SpotInstanceStateFault
Prelude.Read, Int -> SpotInstanceStateFault -> ShowS
[SpotInstanceStateFault] -> ShowS
SpotInstanceStateFault -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SpotInstanceStateFault] -> ShowS
$cshowList :: [SpotInstanceStateFault] -> ShowS
show :: SpotInstanceStateFault -> String
$cshow :: SpotInstanceStateFault -> String
showsPrec :: Int -> SpotInstanceStateFault -> ShowS
$cshowsPrec :: Int -> SpotInstanceStateFault -> ShowS
Prelude.Show, forall x. Rep SpotInstanceStateFault x -> SpotInstanceStateFault
forall x. SpotInstanceStateFault -> Rep SpotInstanceStateFault x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SpotInstanceStateFault x -> SpotInstanceStateFault
$cfrom :: forall x. SpotInstanceStateFault -> Rep SpotInstanceStateFault x
Prelude.Generic)

-- |
-- Create a value of 'SpotInstanceStateFault' 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:
--
-- 'code', 'spotInstanceStateFault_code' - The reason code for the Spot Instance state change.
--
-- 'message', 'spotInstanceStateFault_message' - The message for the Spot Instance state change.
newSpotInstanceStateFault ::
  SpotInstanceStateFault
newSpotInstanceStateFault :: SpotInstanceStateFault
newSpotInstanceStateFault =
  SpotInstanceStateFault'
    { $sel:code:SpotInstanceStateFault' :: Maybe Text
code = forall a. Maybe a
Prelude.Nothing,
      $sel:message:SpotInstanceStateFault' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing
    }

-- | The reason code for the Spot Instance state change.
spotInstanceStateFault_code :: Lens.Lens' SpotInstanceStateFault (Prelude.Maybe Prelude.Text)
spotInstanceStateFault_code :: Lens' SpotInstanceStateFault (Maybe Text)
spotInstanceStateFault_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpotInstanceStateFault' {Maybe Text
code :: Maybe Text
$sel:code:SpotInstanceStateFault' :: SpotInstanceStateFault -> Maybe Text
code} -> Maybe Text
code) (\s :: SpotInstanceStateFault
s@SpotInstanceStateFault' {} Maybe Text
a -> SpotInstanceStateFault
s {$sel:code:SpotInstanceStateFault' :: Maybe Text
code = Maybe Text
a} :: SpotInstanceStateFault)

-- | The message for the Spot Instance state change.
spotInstanceStateFault_message :: Lens.Lens' SpotInstanceStateFault (Prelude.Maybe Prelude.Text)
spotInstanceStateFault_message :: Lens' SpotInstanceStateFault (Maybe Text)
spotInstanceStateFault_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpotInstanceStateFault' {Maybe Text
message :: Maybe Text
$sel:message:SpotInstanceStateFault' :: SpotInstanceStateFault -> Maybe Text
message} -> Maybe Text
message) (\s :: SpotInstanceStateFault
s@SpotInstanceStateFault' {} Maybe Text
a -> SpotInstanceStateFault
s {$sel:message:SpotInstanceStateFault' :: Maybe Text
message = Maybe Text
a} :: SpotInstanceStateFault)

instance Data.FromXML SpotInstanceStateFault where
  parseXML :: [Node] -> Either String SpotInstanceStateFault
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> SpotInstanceStateFault
SpotInstanceStateFault'
      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
"code")
      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
"message")

instance Prelude.Hashable SpotInstanceStateFault where
  hashWithSalt :: Int -> SpotInstanceStateFault -> Int
hashWithSalt Int
_salt SpotInstanceStateFault' {Maybe Text
message :: Maybe Text
code :: Maybe Text
$sel:message:SpotInstanceStateFault' :: SpotInstanceStateFault -> Maybe Text
$sel:code:SpotInstanceStateFault' :: SpotInstanceStateFault -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message

instance Prelude.NFData SpotInstanceStateFault where
  rnf :: SpotInstanceStateFault -> ()
rnf SpotInstanceStateFault' {Maybe Text
message :: Maybe Text
code :: Maybe Text
$sel:message:SpotInstanceStateFault' :: SpotInstanceStateFault -> Maybe Text
$sel:code:SpotInstanceStateFault' :: SpotInstanceStateFault -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
code seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message