{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- 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.Lens as Lens
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
(SetInstanceHealth -> SetInstanceHealth -> Bool)
-> (SetInstanceHealth -> SetInstanceHealth -> Bool)
-> Eq SetInstanceHealth
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]
(Int -> ReadS SetInstanceHealth)
-> ReadS [SetInstanceHealth]
-> ReadPrec SetInstanceHealth
-> ReadPrec [SetInstanceHealth]
-> Read 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
(Int -> SetInstanceHealth -> ShowS)
-> (SetInstanceHealth -> String)
-> ([SetInstanceHealth] -> ShowS)
-> Show SetInstanceHealth
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. SetInstanceHealth -> Rep SetInstanceHealth x)
-> (forall x. Rep SetInstanceHealth x -> SetInstanceHealth)
-> Generic SetInstanceHealth
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' :: Maybe Bool -> Text -> Text -> SetInstanceHealth
SetInstanceHealth'
    { $sel:shouldRespectGracePeriod:SetInstanceHealth' :: Maybe Bool
shouldRespectGracePeriod =
        Maybe Bool
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 :: (Maybe Bool -> f (Maybe Bool))
-> SetInstanceHealth -> f SetInstanceHealth
setInstanceHealth_shouldRespectGracePeriod = (SetInstanceHealth -> Maybe Bool)
-> (SetInstanceHealth -> Maybe Bool -> SetInstanceHealth)
-> Lens
     SetInstanceHealth SetInstanceHealth (Maybe Bool) (Maybe Bool)
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 :: (Text -> f Text) -> SetInstanceHealth -> f SetInstanceHealth
setInstanceHealth_instanceId = (SetInstanceHealth -> Text)
-> (SetInstanceHealth -> Text -> SetInstanceHealth)
-> Lens SetInstanceHealth SetInstanceHealth Text Text
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 :: (Text -> f Text) -> SetInstanceHealth -> f SetInstanceHealth
setInstanceHealth_healthStatus = (SetInstanceHealth -> Text)
-> (SetInstanceHealth -> Text -> SetInstanceHealth)
-> Lens SetInstanceHealth SetInstanceHealth Text Text
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 :: SetInstanceHealth -> Request SetInstanceHealth
request = Service -> SetInstanceHealth -> Request SetInstanceHealth
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy SetInstanceHealth
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SetInstanceHealth)))
response =
    AWSResponse SetInstanceHealth
-> Logger
-> Service
-> Proxy SetInstanceHealth
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SetInstanceHealth)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse SetInstanceHealth
SetInstanceHealthResponse
SetInstanceHealthResponse'

instance Prelude.Hashable SetInstanceHealth

instance Prelude.NFData SetInstanceHealth

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

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

instance Core.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
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"SetInstanceHealth" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
        ByteString
"ShouldRespectGracePeriod"
          ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
shouldRespectGracePeriod,
        ByteString
"InstanceId" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
instanceId,
        ByteString
"HealthStatus" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
healthStatus
      ]

-- | /See:/ 'newSetInstanceHealthResponse' smart constructor.
data SetInstanceHealthResponse = SetInstanceHealthResponse'
  {
  }
  deriving (SetInstanceHealthResponse -> SetInstanceHealthResponse -> Bool
(SetInstanceHealthResponse -> SetInstanceHealthResponse -> Bool)
-> (SetInstanceHealthResponse -> SetInstanceHealthResponse -> Bool)
-> Eq SetInstanceHealthResponse
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]
(Int -> ReadS SetInstanceHealthResponse)
-> ReadS [SetInstanceHealthResponse]
-> ReadPrec SetInstanceHealthResponse
-> ReadPrec [SetInstanceHealthResponse]
-> Read 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
(Int -> SetInstanceHealthResponse -> ShowS)
-> (SetInstanceHealthResponse -> String)
-> ([SetInstanceHealthResponse] -> ShowS)
-> Show SetInstanceHealthResponse
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.
 SetInstanceHealthResponse -> Rep SetInstanceHealthResponse x)
-> (forall x.
    Rep SetInstanceHealthResponse x -> SetInstanceHealthResponse)
-> Generic SetInstanceHealthResponse
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