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

-- | Describes a running instance in a Spot Fleet.
--
-- /See:/ 'newActiveInstance' smart constructor.
data ActiveInstance = ActiveInstance'
  { -- | The health status of the instance. If the status of either the instance
    -- status check or the system status check is @impaired@, the health status
    -- of the instance is @unhealthy@. Otherwise, the health status is
    -- @healthy@.
    ActiveInstance -> Maybe InstanceHealthStatus
instanceHealth :: Prelude.Maybe InstanceHealthStatus,
    -- | The ID of the instance.
    ActiveInstance -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text,
    -- | The instance type.
    ActiveInstance -> Maybe Text
instanceType :: Prelude.Maybe Prelude.Text,
    -- | The ID of the Spot Instance request.
    ActiveInstance -> Maybe Text
spotInstanceRequestId :: Prelude.Maybe Prelude.Text
  }
  deriving (ActiveInstance -> ActiveInstance -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActiveInstance -> ActiveInstance -> Bool
$c/= :: ActiveInstance -> ActiveInstance -> Bool
== :: ActiveInstance -> ActiveInstance -> Bool
$c== :: ActiveInstance -> ActiveInstance -> Bool
Prelude.Eq, ReadPrec [ActiveInstance]
ReadPrec ActiveInstance
Int -> ReadS ActiveInstance
ReadS [ActiveInstance]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActiveInstance]
$creadListPrec :: ReadPrec [ActiveInstance]
readPrec :: ReadPrec ActiveInstance
$creadPrec :: ReadPrec ActiveInstance
readList :: ReadS [ActiveInstance]
$creadList :: ReadS [ActiveInstance]
readsPrec :: Int -> ReadS ActiveInstance
$creadsPrec :: Int -> ReadS ActiveInstance
Prelude.Read, Int -> ActiveInstance -> ShowS
[ActiveInstance] -> ShowS
ActiveInstance -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActiveInstance] -> ShowS
$cshowList :: [ActiveInstance] -> ShowS
show :: ActiveInstance -> String
$cshow :: ActiveInstance -> String
showsPrec :: Int -> ActiveInstance -> ShowS
$cshowsPrec :: Int -> ActiveInstance -> ShowS
Prelude.Show, forall x. Rep ActiveInstance x -> ActiveInstance
forall x. ActiveInstance -> Rep ActiveInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActiveInstance x -> ActiveInstance
$cfrom :: forall x. ActiveInstance -> Rep ActiveInstance x
Prelude.Generic)

-- |
-- Create a value of 'ActiveInstance' 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:
--
-- 'instanceHealth', 'activeInstance_instanceHealth' - The health status of the instance. If the status of either the instance
-- status check or the system status check is @impaired@, the health status
-- of the instance is @unhealthy@. Otherwise, the health status is
-- @healthy@.
--
-- 'instanceId', 'activeInstance_instanceId' - The ID of the instance.
--
-- 'instanceType', 'activeInstance_instanceType' - The instance type.
--
-- 'spotInstanceRequestId', 'activeInstance_spotInstanceRequestId' - The ID of the Spot Instance request.
newActiveInstance ::
  ActiveInstance
newActiveInstance :: ActiveInstance
newActiveInstance =
  ActiveInstance'
    { $sel:instanceHealth:ActiveInstance' :: Maybe InstanceHealthStatus
instanceHealth = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:ActiveInstance' :: Maybe Text
instanceId = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceType:ActiveInstance' :: Maybe Text
instanceType = forall a. Maybe a
Prelude.Nothing,
      $sel:spotInstanceRequestId:ActiveInstance' :: Maybe Text
spotInstanceRequestId = forall a. Maybe a
Prelude.Nothing
    }

-- | The health status of the instance. If the status of either the instance
-- status check or the system status check is @impaired@, the health status
-- of the instance is @unhealthy@. Otherwise, the health status is
-- @healthy@.
activeInstance_instanceHealth :: Lens.Lens' ActiveInstance (Prelude.Maybe InstanceHealthStatus)
activeInstance_instanceHealth :: Lens' ActiveInstance (Maybe InstanceHealthStatus)
activeInstance_instanceHealth = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActiveInstance' {Maybe InstanceHealthStatus
instanceHealth :: Maybe InstanceHealthStatus
$sel:instanceHealth:ActiveInstance' :: ActiveInstance -> Maybe InstanceHealthStatus
instanceHealth} -> Maybe InstanceHealthStatus
instanceHealth) (\s :: ActiveInstance
s@ActiveInstance' {} Maybe InstanceHealthStatus
a -> ActiveInstance
s {$sel:instanceHealth:ActiveInstance' :: Maybe InstanceHealthStatus
instanceHealth = Maybe InstanceHealthStatus
a} :: ActiveInstance)

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

-- | The instance type.
activeInstance_instanceType :: Lens.Lens' ActiveInstance (Prelude.Maybe Prelude.Text)
activeInstance_instanceType :: Lens' ActiveInstance (Maybe Text)
activeInstance_instanceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActiveInstance' {Maybe Text
instanceType :: Maybe Text
$sel:instanceType:ActiveInstance' :: ActiveInstance -> Maybe Text
instanceType} -> Maybe Text
instanceType) (\s :: ActiveInstance
s@ActiveInstance' {} Maybe Text
a -> ActiveInstance
s {$sel:instanceType:ActiveInstance' :: Maybe Text
instanceType = Maybe Text
a} :: ActiveInstance)

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

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

instance Prelude.Hashable ActiveInstance where
  hashWithSalt :: Int -> ActiveInstance -> Int
hashWithSalt Int
_salt ActiveInstance' {Maybe Text
Maybe InstanceHealthStatus
spotInstanceRequestId :: Maybe Text
instanceType :: Maybe Text
instanceId :: Maybe Text
instanceHealth :: Maybe InstanceHealthStatus
$sel:spotInstanceRequestId:ActiveInstance' :: ActiveInstance -> Maybe Text
$sel:instanceType:ActiveInstance' :: ActiveInstance -> Maybe Text
$sel:instanceId:ActiveInstance' :: ActiveInstance -> Maybe Text
$sel:instanceHealth:ActiveInstance' :: ActiveInstance -> Maybe InstanceHealthStatus
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InstanceHealthStatus
instanceHealth
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
instanceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
instanceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
spotInstanceRequestId

instance Prelude.NFData ActiveInstance where
  rnf :: ActiveInstance -> ()
rnf ActiveInstance' {Maybe Text
Maybe InstanceHealthStatus
spotInstanceRequestId :: Maybe Text
instanceType :: Maybe Text
instanceId :: Maybe Text
instanceHealth :: Maybe InstanceHealthStatus
$sel:spotInstanceRequestId:ActiveInstance' :: ActiveInstance -> Maybe Text
$sel:instanceType:ActiveInstance' :: ActiveInstance -> Maybe Text
$sel:instanceId:ActiveInstance' :: ActiveInstance -> Maybe Text
$sel:instanceHealth:ActiveInstance' :: ActiveInstance -> Maybe InstanceHealthStatus
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe InstanceHealthStatus
instanceHealth
      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 Text
instanceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
spotInstanceRequestId