{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.AutoScaling.SetInstanceHealth
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Sets the health status of the specified instance.
--
-- For more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/healthcheck.html Health checks for Auto Scaling instances>
-- in the /Amazon EC2 Auto Scaling User Guide/.
module Amazonka.AutoScaling.SetInstanceHealth
  ( -- * Creating a Request
    SetInstanceHealth (..),
    newSetInstanceHealth,

    -- * Request Lenses
    setInstanceHealth_shouldRespectGracePeriod,
    setInstanceHealth_instanceId,
    setInstanceHealth_healthStatus,

    -- * Destructuring the Response
    SetInstanceHealthResponse (..),
    newSetInstanceHealthResponse,
  )
where

import Amazonka.AutoScaling.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newSetInstanceHealth' smart constructor.
data SetInstanceHealth = SetInstanceHealth'
  { -- | If the Auto Scaling group of the specified instance has a
    -- @HealthCheckGracePeriod@ specified for the group, by default, this call
    -- respects the grace period. Set this to @False@, to have the call not
    -- respect the grace period associated with the group.
    --
    -- For more information about the health check grace period, see
    -- <https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_CreateAutoScalingGroup.html CreateAutoScalingGroup>
    -- in the /Amazon EC2 Auto Scaling API Reference/.
    SetInstanceHealth -> Maybe Bool
shouldRespectGracePeriod :: Prelude.Maybe Prelude.Bool,
    -- | The ID of the instance.
    SetInstanceHealth -> Text
instanceId :: Prelude.Text,
    -- | The health status of the instance. Set to @Healthy@ to have the instance
    -- remain in service. Set to @Unhealthy@ to have the instance be out of
    -- service. Amazon EC2 Auto Scaling terminates and replaces the unhealthy
    -- instance.
    SetInstanceHealth -> Text
healthStatus :: Prelude.Text
  }
  deriving (SetInstanceHealth -> SetInstanceHealth -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetInstanceHealth -> SetInstanceHealth -> Bool
$c/= :: SetInstanceHealth -> SetInstanceHealth -> Bool
== :: SetInstanceHealth -> SetInstanceHealth -> Bool
$c== :: SetInstanceHealth -> SetInstanceHealth -> Bool
Prelude.Eq, ReadPrec [SetInstanceHealth]
ReadPrec SetInstanceHealth
Int -> ReadS SetInstanceHealth
ReadS [SetInstanceHealth]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetInstanceHealth]
$creadListPrec :: ReadPrec [SetInstanceHealth]
readPrec :: ReadPrec SetInstanceHealth
$creadPrec :: ReadPrec SetInstanceHealth
readList :: ReadS [SetInstanceHealth]
$creadList :: ReadS [SetInstanceHealth]
readsPrec :: Int -> ReadS SetInstanceHealth
$creadsPrec :: Int -> ReadS SetInstanceHealth
Prelude.Read, Int -> SetInstanceHealth -> ShowS
[SetInstanceHealth] -> ShowS
SetInstanceHealth -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetInstanceHealth] -> ShowS
$cshowList :: [SetInstanceHealth] -> ShowS
show :: SetInstanceHealth -> String
$cshow :: SetInstanceHealth -> String
showsPrec :: Int -> SetInstanceHealth -> ShowS
$cshowsPrec :: Int -> SetInstanceHealth -> ShowS
Prelude.Show, forall x. Rep SetInstanceHealth x -> SetInstanceHealth
forall x. SetInstanceHealth -> Rep SetInstanceHealth x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SetInstanceHealth x -> SetInstanceHealth
$cfrom :: forall x. SetInstanceHealth -> Rep SetInstanceHealth x
Prelude.Generic)

-- |
-- Create a value of 'SetInstanceHealth' 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:
--
-- 'shouldRespectGracePeriod', 'setInstanceHealth_shouldRespectGracePeriod' - If the Auto Scaling group of the specified instance has a
-- @HealthCheckGracePeriod@ specified for the group, by default, this call
-- respects the grace period. Set this to @False@, to have the call not
-- respect the grace period associated with the group.
--
-- For more information about the health check grace period, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_CreateAutoScalingGroup.html CreateAutoScalingGroup>
-- in the /Amazon EC2 Auto Scaling API Reference/.
--
-- 'instanceId', 'setInstanceHealth_instanceId' - The ID of the instance.
--
-- 'healthStatus', 'setInstanceHealth_healthStatus' - The health status of the instance. Set to @Healthy@ to have the instance
-- remain in service. Set to @Unhealthy@ to have the instance be out of
-- service. Amazon EC2 Auto Scaling terminates and replaces the unhealthy
-- instance.
newSetInstanceHealth ::
  -- | 'instanceId'
  Prelude.Text ->
  -- | 'healthStatus'
  Prelude.Text ->
  SetInstanceHealth
newSetInstanceHealth :: Text -> Text -> SetInstanceHealth
newSetInstanceHealth Text
pInstanceId_ Text
pHealthStatus_ =
  SetInstanceHealth'
    { $sel:shouldRespectGracePeriod:SetInstanceHealth' :: Maybe Bool
shouldRespectGracePeriod =
        forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:SetInstanceHealth' :: Text
instanceId = Text
pInstanceId_,
      $sel:healthStatus:SetInstanceHealth' :: Text
healthStatus = Text
pHealthStatus_
    }

-- | If the Auto Scaling group of the specified instance has a
-- @HealthCheckGracePeriod@ specified for the group, by default, this call
-- respects the grace period. Set this to @False@, to have the call not
-- respect the grace period associated with the group.
--
-- For more information about the health check grace period, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_CreateAutoScalingGroup.html CreateAutoScalingGroup>
-- in the /Amazon EC2 Auto Scaling API Reference/.
setInstanceHealth_shouldRespectGracePeriod :: Lens.Lens' SetInstanceHealth (Prelude.Maybe Prelude.Bool)
setInstanceHealth_shouldRespectGracePeriod :: Lens' SetInstanceHealth (Maybe Bool)
setInstanceHealth_shouldRespectGracePeriod = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetInstanceHealth' {Maybe Bool
shouldRespectGracePeriod :: Maybe Bool
$sel:shouldRespectGracePeriod:SetInstanceHealth' :: SetInstanceHealth -> Maybe Bool
shouldRespectGracePeriod} -> Maybe Bool
shouldRespectGracePeriod) (\s :: SetInstanceHealth
s@SetInstanceHealth' {} Maybe Bool
a -> SetInstanceHealth
s {$sel:shouldRespectGracePeriod:SetInstanceHealth' :: Maybe Bool
shouldRespectGracePeriod = Maybe Bool
a} :: SetInstanceHealth)

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

-- | The health status of the instance. Set to @Healthy@ to have the instance
-- remain in service. Set to @Unhealthy@ to have the instance be out of
-- service. Amazon EC2 Auto Scaling terminates and replaces the unhealthy
-- instance.
setInstanceHealth_healthStatus :: Lens.Lens' SetInstanceHealth Prelude.Text
setInstanceHealth_healthStatus :: Lens' SetInstanceHealth Text
setInstanceHealth_healthStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetInstanceHealth' {Text
healthStatus :: Text
$sel:healthStatus:SetInstanceHealth' :: SetInstanceHealth -> Text
healthStatus} -> Text
healthStatus) (\s :: SetInstanceHealth
s@SetInstanceHealth' {} Text
a -> SetInstanceHealth
s {$sel:healthStatus:SetInstanceHealth' :: Text
healthStatus = Text
a} :: SetInstanceHealth)

instance Core.AWSRequest SetInstanceHealth where
  type
    AWSResponse SetInstanceHealth =
      SetInstanceHealthResponse
  request :: (Service -> Service)
-> SetInstanceHealth -> Request SetInstanceHealth
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy SetInstanceHealth
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SetInstanceHealth)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull SetInstanceHealthResponse
SetInstanceHealthResponse'

instance Prelude.Hashable SetInstanceHealth where
  hashWithSalt :: Int -> SetInstanceHealth -> Int
hashWithSalt Int
_salt SetInstanceHealth' {Maybe Bool
Text
healthStatus :: Text
instanceId :: Text
shouldRespectGracePeriod :: Maybe Bool
$sel:healthStatus:SetInstanceHealth' :: SetInstanceHealth -> Text
$sel:instanceId:SetInstanceHealth' :: SetInstanceHealth -> Text
$sel:shouldRespectGracePeriod:SetInstanceHealth' :: SetInstanceHealth -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
shouldRespectGracePeriod
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
healthStatus

instance Prelude.NFData SetInstanceHealth where
  rnf :: SetInstanceHealth -> ()
rnf SetInstanceHealth' {Maybe Bool
Text
healthStatus :: Text
instanceId :: Text
shouldRespectGracePeriod :: Maybe Bool
$sel:healthStatus:SetInstanceHealth' :: SetInstanceHealth -> Text
$sel:instanceId:SetInstanceHealth' :: SetInstanceHealth -> Text
$sel:shouldRespectGracePeriod:SetInstanceHealth' :: SetInstanceHealth -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
shouldRespectGracePeriod
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
instanceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
healthStatus

instance Data.ToHeaders SetInstanceHealth where
  toHeaders :: SetInstanceHealth -> [Header]
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath SetInstanceHealth where
  toPath :: SetInstanceHealth -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery SetInstanceHealth where
  toQuery :: SetInstanceHealth -> QueryString
toQuery SetInstanceHealth' {Maybe Bool
Text
healthStatus :: Text
instanceId :: Text
shouldRespectGracePeriod :: Maybe Bool
$sel:healthStatus:SetInstanceHealth' :: SetInstanceHealth -> Text
$sel:instanceId:SetInstanceHealth' :: SetInstanceHealth -> Text
$sel:shouldRespectGracePeriod:SetInstanceHealth' :: SetInstanceHealth -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"SetInstanceHealth" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
        ByteString
"ShouldRespectGracePeriod"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
shouldRespectGracePeriod,
        ByteString
"InstanceId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
instanceId,
        ByteString
"HealthStatus" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
healthStatus
      ]

-- | /See:/ 'newSetInstanceHealthResponse' smart constructor.
data SetInstanceHealthResponse = SetInstanceHealthResponse'
  {
  }
  deriving (SetInstanceHealthResponse -> SetInstanceHealthResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetInstanceHealthResponse -> SetInstanceHealthResponse -> Bool
$c/= :: SetInstanceHealthResponse -> SetInstanceHealthResponse -> Bool
== :: SetInstanceHealthResponse -> SetInstanceHealthResponse -> Bool
$c== :: SetInstanceHealthResponse -> SetInstanceHealthResponse -> Bool
Prelude.Eq, ReadPrec [SetInstanceHealthResponse]
ReadPrec SetInstanceHealthResponse
Int -> ReadS SetInstanceHealthResponse
ReadS [SetInstanceHealthResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetInstanceHealthResponse]
$creadListPrec :: ReadPrec [SetInstanceHealthResponse]
readPrec :: ReadPrec SetInstanceHealthResponse
$creadPrec :: ReadPrec SetInstanceHealthResponse
readList :: ReadS [SetInstanceHealthResponse]
$creadList :: ReadS [SetInstanceHealthResponse]
readsPrec :: Int -> ReadS SetInstanceHealthResponse
$creadsPrec :: Int -> ReadS SetInstanceHealthResponse
Prelude.Read, Int -> SetInstanceHealthResponse -> ShowS
[SetInstanceHealthResponse] -> ShowS
SetInstanceHealthResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetInstanceHealthResponse] -> ShowS
$cshowList :: [SetInstanceHealthResponse] -> ShowS
show :: SetInstanceHealthResponse -> String
$cshow :: SetInstanceHealthResponse -> String
showsPrec :: Int -> SetInstanceHealthResponse -> ShowS
$cshowsPrec :: Int -> SetInstanceHealthResponse -> ShowS
Prelude.Show, forall x.
Rep SetInstanceHealthResponse x -> SetInstanceHealthResponse
forall x.
SetInstanceHealthResponse -> Rep SetInstanceHealthResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SetInstanceHealthResponse x -> SetInstanceHealthResponse
$cfrom :: forall x.
SetInstanceHealthResponse -> Rep SetInstanceHealthResponse x
Prelude.Generic)

-- |
-- Create a value of 'SetInstanceHealthResponse' 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.
newSetInstanceHealthResponse ::
  SetInstanceHealthResponse
newSetInstanceHealthResponse :: SetInstanceHealthResponse
newSetInstanceHealthResponse =
  SetInstanceHealthResponse
SetInstanceHealthResponse'

instance Prelude.NFData SetInstanceHealthResponse where
  rnf :: SetInstanceHealthResponse -> ()
rnf SetInstanceHealthResponse
_ = ()