{-# 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.CancelledSpotInstanceRequest
-- 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.CancelledSpotInstanceRequest 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.CancelSpotInstanceRequestState
import qualified Amazonka.Prelude as Prelude

-- | Describes a request to cancel a Spot Instance.
--
-- /See:/ 'newCancelledSpotInstanceRequest' smart constructor.
data CancelledSpotInstanceRequest = CancelledSpotInstanceRequest'
  { -- | The ID of the Spot Instance request.
    CancelledSpotInstanceRequest -> Maybe Text
spotInstanceRequestId :: Prelude.Maybe Prelude.Text,
    -- | The state of the Spot Instance request.
    CancelledSpotInstanceRequest
-> Maybe CancelSpotInstanceRequestState
state :: Prelude.Maybe CancelSpotInstanceRequestState
  }
  deriving (CancelledSpotInstanceRequest
-> CancelledSpotInstanceRequest -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelledSpotInstanceRequest
-> CancelledSpotInstanceRequest -> Bool
$c/= :: CancelledSpotInstanceRequest
-> CancelledSpotInstanceRequest -> Bool
== :: CancelledSpotInstanceRequest
-> CancelledSpotInstanceRequest -> Bool
$c== :: CancelledSpotInstanceRequest
-> CancelledSpotInstanceRequest -> Bool
Prelude.Eq, ReadPrec [CancelledSpotInstanceRequest]
ReadPrec CancelledSpotInstanceRequest
Int -> ReadS CancelledSpotInstanceRequest
ReadS [CancelledSpotInstanceRequest]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelledSpotInstanceRequest]
$creadListPrec :: ReadPrec [CancelledSpotInstanceRequest]
readPrec :: ReadPrec CancelledSpotInstanceRequest
$creadPrec :: ReadPrec CancelledSpotInstanceRequest
readList :: ReadS [CancelledSpotInstanceRequest]
$creadList :: ReadS [CancelledSpotInstanceRequest]
readsPrec :: Int -> ReadS CancelledSpotInstanceRequest
$creadsPrec :: Int -> ReadS CancelledSpotInstanceRequest
Prelude.Read, Int -> CancelledSpotInstanceRequest -> ShowS
[CancelledSpotInstanceRequest] -> ShowS
CancelledSpotInstanceRequest -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelledSpotInstanceRequest] -> ShowS
$cshowList :: [CancelledSpotInstanceRequest] -> ShowS
show :: CancelledSpotInstanceRequest -> String
$cshow :: CancelledSpotInstanceRequest -> String
showsPrec :: Int -> CancelledSpotInstanceRequest -> ShowS
$cshowsPrec :: Int -> CancelledSpotInstanceRequest -> ShowS
Prelude.Show, forall x.
Rep CancelledSpotInstanceRequest x -> CancelledSpotInstanceRequest
forall x.
CancelledSpotInstanceRequest -> Rep CancelledSpotInstanceRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelledSpotInstanceRequest x -> CancelledSpotInstanceRequest
$cfrom :: forall x.
CancelledSpotInstanceRequest -> Rep CancelledSpotInstanceRequest x
Prelude.Generic)

-- |
-- Create a value of 'CancelledSpotInstanceRequest' 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:
--
-- 'spotInstanceRequestId', 'cancelledSpotInstanceRequest_spotInstanceRequestId' - The ID of the Spot Instance request.
--
-- 'state', 'cancelledSpotInstanceRequest_state' - The state of the Spot Instance request.
newCancelledSpotInstanceRequest ::
  CancelledSpotInstanceRequest
newCancelledSpotInstanceRequest :: CancelledSpotInstanceRequest
newCancelledSpotInstanceRequest =
  CancelledSpotInstanceRequest'
    { $sel:spotInstanceRequestId:CancelledSpotInstanceRequest' :: Maybe Text
spotInstanceRequestId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:state:CancelledSpotInstanceRequest' :: Maybe CancelSpotInstanceRequestState
state = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the Spot Instance request.
cancelledSpotInstanceRequest_spotInstanceRequestId :: Lens.Lens' CancelledSpotInstanceRequest (Prelude.Maybe Prelude.Text)
cancelledSpotInstanceRequest_spotInstanceRequestId :: Lens' CancelledSpotInstanceRequest (Maybe Text)
cancelledSpotInstanceRequest_spotInstanceRequestId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelledSpotInstanceRequest' {Maybe Text
spotInstanceRequestId :: Maybe Text
$sel:spotInstanceRequestId:CancelledSpotInstanceRequest' :: CancelledSpotInstanceRequest -> Maybe Text
spotInstanceRequestId} -> Maybe Text
spotInstanceRequestId) (\s :: CancelledSpotInstanceRequest
s@CancelledSpotInstanceRequest' {} Maybe Text
a -> CancelledSpotInstanceRequest
s {$sel:spotInstanceRequestId:CancelledSpotInstanceRequest' :: Maybe Text
spotInstanceRequestId = Maybe Text
a} :: CancelledSpotInstanceRequest)

-- | The state of the Spot Instance request.
cancelledSpotInstanceRequest_state :: Lens.Lens' CancelledSpotInstanceRequest (Prelude.Maybe CancelSpotInstanceRequestState)
cancelledSpotInstanceRequest_state :: Lens'
  CancelledSpotInstanceRequest (Maybe CancelSpotInstanceRequestState)
cancelledSpotInstanceRequest_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelledSpotInstanceRequest' {Maybe CancelSpotInstanceRequestState
state :: Maybe CancelSpotInstanceRequestState
$sel:state:CancelledSpotInstanceRequest' :: CancelledSpotInstanceRequest
-> Maybe CancelSpotInstanceRequestState
state} -> Maybe CancelSpotInstanceRequestState
state) (\s :: CancelledSpotInstanceRequest
s@CancelledSpotInstanceRequest' {} Maybe CancelSpotInstanceRequestState
a -> CancelledSpotInstanceRequest
s {$sel:state:CancelledSpotInstanceRequest' :: Maybe CancelSpotInstanceRequestState
state = Maybe CancelSpotInstanceRequestState
a} :: CancelledSpotInstanceRequest)

instance Data.FromXML CancelledSpotInstanceRequest where
  parseXML :: [Node] -> Either String CancelledSpotInstanceRequest
parseXML [Node]
x =
    Maybe Text
-> Maybe CancelSpotInstanceRequestState
-> CancelledSpotInstanceRequest
CancelledSpotInstanceRequest'
      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
"spotInstanceRequestId")
      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
"state")

instance
  Prelude.Hashable
    CancelledSpotInstanceRequest
  where
  hashWithSalt :: Int -> CancelledSpotInstanceRequest -> Int
hashWithSalt Int
_salt CancelledSpotInstanceRequest' {Maybe Text
Maybe CancelSpotInstanceRequestState
state :: Maybe CancelSpotInstanceRequestState
spotInstanceRequestId :: Maybe Text
$sel:state:CancelledSpotInstanceRequest' :: CancelledSpotInstanceRequest
-> Maybe CancelSpotInstanceRequestState
$sel:spotInstanceRequestId:CancelledSpotInstanceRequest' :: CancelledSpotInstanceRequest -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
spotInstanceRequestId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CancelSpotInstanceRequestState
state

instance Prelude.NFData CancelledSpotInstanceRequest where
  rnf :: CancelledSpotInstanceRequest -> ()
rnf CancelledSpotInstanceRequest' {Maybe Text
Maybe CancelSpotInstanceRequestState
state :: Maybe CancelSpotInstanceRequestState
spotInstanceRequestId :: Maybe Text
$sel:state:CancelledSpotInstanceRequest' :: CancelledSpotInstanceRequest
-> Maybe CancelSpotInstanceRequestState
$sel:spotInstanceRequestId:CancelledSpotInstanceRequest' :: CancelledSpotInstanceRequest -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
spotInstanceRequestId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CancelSpotInstanceRequestState
state