{-# 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.ELB.ConfigureHealthCheck
-- 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)
--
-- Specifies the health check settings to use when evaluating the health
-- state of your EC2 instances.
--
-- For more information, see
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-healthchecks.html Configure Health Checks for Your Load Balancer>
-- in the /Classic Load Balancers Guide/.
module Amazonka.ELB.ConfigureHealthCheck
  ( -- * Creating a Request
    ConfigureHealthCheck (..),
    newConfigureHealthCheck,

    -- * Request Lenses
    configureHealthCheck_loadBalancerName,
    configureHealthCheck_healthCheck,

    -- * Destructuring the Response
    ConfigureHealthCheckResponse (..),
    newConfigureHealthCheckResponse,

    -- * Response Lenses
    configureHealthCheckResponse_healthCheck,
    configureHealthCheckResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.ELB.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Contains the parameters for ConfigureHealthCheck.
--
-- /See:/ 'newConfigureHealthCheck' smart constructor.
data ConfigureHealthCheck = ConfigureHealthCheck'
  { -- | The name of the load balancer.
    ConfigureHealthCheck -> Text
loadBalancerName :: Prelude.Text,
    -- | The configuration information.
    ConfigureHealthCheck -> HealthCheck
healthCheck :: HealthCheck
  }
  deriving (ConfigureHealthCheck -> ConfigureHealthCheck -> Bool
(ConfigureHealthCheck -> ConfigureHealthCheck -> Bool)
-> (ConfigureHealthCheck -> ConfigureHealthCheck -> Bool)
-> Eq ConfigureHealthCheck
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfigureHealthCheck -> ConfigureHealthCheck -> Bool
$c/= :: ConfigureHealthCheck -> ConfigureHealthCheck -> Bool
== :: ConfigureHealthCheck -> ConfigureHealthCheck -> Bool
$c== :: ConfigureHealthCheck -> ConfigureHealthCheck -> Bool
Prelude.Eq, ReadPrec [ConfigureHealthCheck]
ReadPrec ConfigureHealthCheck
Int -> ReadS ConfigureHealthCheck
ReadS [ConfigureHealthCheck]
(Int -> ReadS ConfigureHealthCheck)
-> ReadS [ConfigureHealthCheck]
-> ReadPrec ConfigureHealthCheck
-> ReadPrec [ConfigureHealthCheck]
-> Read ConfigureHealthCheck
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfigureHealthCheck]
$creadListPrec :: ReadPrec [ConfigureHealthCheck]
readPrec :: ReadPrec ConfigureHealthCheck
$creadPrec :: ReadPrec ConfigureHealthCheck
readList :: ReadS [ConfigureHealthCheck]
$creadList :: ReadS [ConfigureHealthCheck]
readsPrec :: Int -> ReadS ConfigureHealthCheck
$creadsPrec :: Int -> ReadS ConfigureHealthCheck
Prelude.Read, Int -> ConfigureHealthCheck -> ShowS
[ConfigureHealthCheck] -> ShowS
ConfigureHealthCheck -> String
(Int -> ConfigureHealthCheck -> ShowS)
-> (ConfigureHealthCheck -> String)
-> ([ConfigureHealthCheck] -> ShowS)
-> Show ConfigureHealthCheck
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfigureHealthCheck] -> ShowS
$cshowList :: [ConfigureHealthCheck] -> ShowS
show :: ConfigureHealthCheck -> String
$cshow :: ConfigureHealthCheck -> String
showsPrec :: Int -> ConfigureHealthCheck -> ShowS
$cshowsPrec :: Int -> ConfigureHealthCheck -> ShowS
Prelude.Show, (forall x. ConfigureHealthCheck -> Rep ConfigureHealthCheck x)
-> (forall x. Rep ConfigureHealthCheck x -> ConfigureHealthCheck)
-> Generic ConfigureHealthCheck
forall x. Rep ConfigureHealthCheck x -> ConfigureHealthCheck
forall x. ConfigureHealthCheck -> Rep ConfigureHealthCheck x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConfigureHealthCheck x -> ConfigureHealthCheck
$cfrom :: forall x. ConfigureHealthCheck -> Rep ConfigureHealthCheck x
Prelude.Generic)

-- |
-- Create a value of 'ConfigureHealthCheck' 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:
--
-- 'loadBalancerName', 'configureHealthCheck_loadBalancerName' - The name of the load balancer.
--
-- 'healthCheck', 'configureHealthCheck_healthCheck' - The configuration information.
newConfigureHealthCheck ::
  -- | 'loadBalancerName'
  Prelude.Text ->
  -- | 'healthCheck'
  HealthCheck ->
  ConfigureHealthCheck
newConfigureHealthCheck :: Text -> HealthCheck -> ConfigureHealthCheck
newConfigureHealthCheck
  Text
pLoadBalancerName_
  HealthCheck
pHealthCheck_ =
    ConfigureHealthCheck' :: Text -> HealthCheck -> ConfigureHealthCheck
ConfigureHealthCheck'
      { $sel:loadBalancerName:ConfigureHealthCheck' :: Text
loadBalancerName =
          Text
pLoadBalancerName_,
        $sel:healthCheck:ConfigureHealthCheck' :: HealthCheck
healthCheck = HealthCheck
pHealthCheck_
      }

-- | The name of the load balancer.
configureHealthCheck_loadBalancerName :: Lens.Lens' ConfigureHealthCheck Prelude.Text
configureHealthCheck_loadBalancerName :: (Text -> f Text) -> ConfigureHealthCheck -> f ConfigureHealthCheck
configureHealthCheck_loadBalancerName = (ConfigureHealthCheck -> Text)
-> (ConfigureHealthCheck -> Text -> ConfigureHealthCheck)
-> Lens ConfigureHealthCheck ConfigureHealthCheck Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigureHealthCheck' {Text
loadBalancerName :: Text
$sel:loadBalancerName:ConfigureHealthCheck' :: ConfigureHealthCheck -> Text
loadBalancerName} -> Text
loadBalancerName) (\s :: ConfigureHealthCheck
s@ConfigureHealthCheck' {} Text
a -> ConfigureHealthCheck
s {$sel:loadBalancerName:ConfigureHealthCheck' :: Text
loadBalancerName = Text
a} :: ConfigureHealthCheck)

-- | The configuration information.
configureHealthCheck_healthCheck :: Lens.Lens' ConfigureHealthCheck HealthCheck
configureHealthCheck_healthCheck :: (HealthCheck -> f HealthCheck)
-> ConfigureHealthCheck -> f ConfigureHealthCheck
configureHealthCheck_healthCheck = (ConfigureHealthCheck -> HealthCheck)
-> (ConfigureHealthCheck -> HealthCheck -> ConfigureHealthCheck)
-> Lens
     ConfigureHealthCheck ConfigureHealthCheck HealthCheck HealthCheck
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigureHealthCheck' {HealthCheck
healthCheck :: HealthCheck
$sel:healthCheck:ConfigureHealthCheck' :: ConfigureHealthCheck -> HealthCheck
healthCheck} -> HealthCheck
healthCheck) (\s :: ConfigureHealthCheck
s@ConfigureHealthCheck' {} HealthCheck
a -> ConfigureHealthCheck
s {$sel:healthCheck:ConfigureHealthCheck' :: HealthCheck
healthCheck = HealthCheck
a} :: ConfigureHealthCheck)

instance Core.AWSRequest ConfigureHealthCheck where
  type
    AWSResponse ConfigureHealthCheck =
      ConfigureHealthCheckResponse
  request :: ConfigureHealthCheck -> Request ConfigureHealthCheck
request = Service -> ConfigureHealthCheck -> Request ConfigureHealthCheck
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ConfigureHealthCheck
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ConfigureHealthCheck)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ConfigureHealthCheck))
-> Logger
-> Service
-> Proxy ConfigureHealthCheck
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ConfigureHealthCheck)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"ConfigureHealthCheckResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe HealthCheck -> Int -> ConfigureHealthCheckResponse
ConfigureHealthCheckResponse'
            (Maybe HealthCheck -> Int -> ConfigureHealthCheckResponse)
-> Either String (Maybe HealthCheck)
-> Either String (Int -> ConfigureHealthCheckResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe HealthCheck)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"HealthCheck")
            Either String (Int -> ConfigureHealthCheckResponse)
-> Either String Int -> Either String ConfigureHealthCheckResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ConfigureHealthCheck

instance Prelude.NFData ConfigureHealthCheck

instance Core.ToHeaders ConfigureHealthCheck where
  toHeaders :: ConfigureHealthCheck -> ResponseHeaders
toHeaders = ResponseHeaders -> ConfigureHealthCheck -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery ConfigureHealthCheck where
  toQuery :: ConfigureHealthCheck -> QueryString
toQuery ConfigureHealthCheck' {Text
HealthCheck
healthCheck :: HealthCheck
loadBalancerName :: Text
$sel:healthCheck:ConfigureHealthCheck' :: ConfigureHealthCheck -> HealthCheck
$sel:loadBalancerName:ConfigureHealthCheck' :: ConfigureHealthCheck -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"ConfigureHealthCheck" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-06-01" :: Prelude.ByteString),
        ByteString
"LoadBalancerName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
loadBalancerName,
        ByteString
"HealthCheck" ByteString -> HealthCheck -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: HealthCheck
healthCheck
      ]

-- | Contains the output of ConfigureHealthCheck.
--
-- /See:/ 'newConfigureHealthCheckResponse' smart constructor.
data ConfigureHealthCheckResponse = ConfigureHealthCheckResponse'
  { -- | The updated health check.
    ConfigureHealthCheckResponse -> Maybe HealthCheck
healthCheck :: Prelude.Maybe HealthCheck,
    -- | The response's http status code.
    ConfigureHealthCheckResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ConfigureHealthCheckResponse
-> ConfigureHealthCheckResponse -> Bool
(ConfigureHealthCheckResponse
 -> ConfigureHealthCheckResponse -> Bool)
-> (ConfigureHealthCheckResponse
    -> ConfigureHealthCheckResponse -> Bool)
-> Eq ConfigureHealthCheckResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfigureHealthCheckResponse
-> ConfigureHealthCheckResponse -> Bool
$c/= :: ConfigureHealthCheckResponse
-> ConfigureHealthCheckResponse -> Bool
== :: ConfigureHealthCheckResponse
-> ConfigureHealthCheckResponse -> Bool
$c== :: ConfigureHealthCheckResponse
-> ConfigureHealthCheckResponse -> Bool
Prelude.Eq, ReadPrec [ConfigureHealthCheckResponse]
ReadPrec ConfigureHealthCheckResponse
Int -> ReadS ConfigureHealthCheckResponse
ReadS [ConfigureHealthCheckResponse]
(Int -> ReadS ConfigureHealthCheckResponse)
-> ReadS [ConfigureHealthCheckResponse]
-> ReadPrec ConfigureHealthCheckResponse
-> ReadPrec [ConfigureHealthCheckResponse]
-> Read ConfigureHealthCheckResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfigureHealthCheckResponse]
$creadListPrec :: ReadPrec [ConfigureHealthCheckResponse]
readPrec :: ReadPrec ConfigureHealthCheckResponse
$creadPrec :: ReadPrec ConfigureHealthCheckResponse
readList :: ReadS [ConfigureHealthCheckResponse]
$creadList :: ReadS [ConfigureHealthCheckResponse]
readsPrec :: Int -> ReadS ConfigureHealthCheckResponse
$creadsPrec :: Int -> ReadS ConfigureHealthCheckResponse
Prelude.Read, Int -> ConfigureHealthCheckResponse -> ShowS
[ConfigureHealthCheckResponse] -> ShowS
ConfigureHealthCheckResponse -> String
(Int -> ConfigureHealthCheckResponse -> ShowS)
-> (ConfigureHealthCheckResponse -> String)
-> ([ConfigureHealthCheckResponse] -> ShowS)
-> Show ConfigureHealthCheckResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfigureHealthCheckResponse] -> ShowS
$cshowList :: [ConfigureHealthCheckResponse] -> ShowS
show :: ConfigureHealthCheckResponse -> String
$cshow :: ConfigureHealthCheckResponse -> String
showsPrec :: Int -> ConfigureHealthCheckResponse -> ShowS
$cshowsPrec :: Int -> ConfigureHealthCheckResponse -> ShowS
Prelude.Show, (forall x.
 ConfigureHealthCheckResponse -> Rep ConfigureHealthCheckResponse x)
-> (forall x.
    Rep ConfigureHealthCheckResponse x -> ConfigureHealthCheckResponse)
-> Generic ConfigureHealthCheckResponse
forall x.
Rep ConfigureHealthCheckResponse x -> ConfigureHealthCheckResponse
forall x.
ConfigureHealthCheckResponse -> Rep ConfigureHealthCheckResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ConfigureHealthCheckResponse x -> ConfigureHealthCheckResponse
$cfrom :: forall x.
ConfigureHealthCheckResponse -> Rep ConfigureHealthCheckResponse x
Prelude.Generic)

-- |
-- Create a value of 'ConfigureHealthCheckResponse' 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:
--
-- 'healthCheck', 'configureHealthCheckResponse_healthCheck' - The updated health check.
--
-- 'httpStatus', 'configureHealthCheckResponse_httpStatus' - The response's http status code.
newConfigureHealthCheckResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ConfigureHealthCheckResponse
newConfigureHealthCheckResponse :: Int -> ConfigureHealthCheckResponse
newConfigureHealthCheckResponse Int
pHttpStatus_ =
  ConfigureHealthCheckResponse' :: Maybe HealthCheck -> Int -> ConfigureHealthCheckResponse
ConfigureHealthCheckResponse'
    { $sel:healthCheck:ConfigureHealthCheckResponse' :: Maybe HealthCheck
healthCheck =
        Maybe HealthCheck
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ConfigureHealthCheckResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The updated health check.
configureHealthCheckResponse_healthCheck :: Lens.Lens' ConfigureHealthCheckResponse (Prelude.Maybe HealthCheck)
configureHealthCheckResponse_healthCheck :: (Maybe HealthCheck -> f (Maybe HealthCheck))
-> ConfigureHealthCheckResponse -> f ConfigureHealthCheckResponse
configureHealthCheckResponse_healthCheck = (ConfigureHealthCheckResponse -> Maybe HealthCheck)
-> (ConfigureHealthCheckResponse
    -> Maybe HealthCheck -> ConfigureHealthCheckResponse)
-> Lens
     ConfigureHealthCheckResponse
     ConfigureHealthCheckResponse
     (Maybe HealthCheck)
     (Maybe HealthCheck)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigureHealthCheckResponse' {Maybe HealthCheck
healthCheck :: Maybe HealthCheck
$sel:healthCheck:ConfigureHealthCheckResponse' :: ConfigureHealthCheckResponse -> Maybe HealthCheck
healthCheck} -> Maybe HealthCheck
healthCheck) (\s :: ConfigureHealthCheckResponse
s@ConfigureHealthCheckResponse' {} Maybe HealthCheck
a -> ConfigureHealthCheckResponse
s {$sel:healthCheck:ConfigureHealthCheckResponse' :: Maybe HealthCheck
healthCheck = Maybe HealthCheck
a} :: ConfigureHealthCheckResponse)

-- | The response's http status code.
configureHealthCheckResponse_httpStatus :: Lens.Lens' ConfigureHealthCheckResponse Prelude.Int
configureHealthCheckResponse_httpStatus :: (Int -> f Int)
-> ConfigureHealthCheckResponse -> f ConfigureHealthCheckResponse
configureHealthCheckResponse_httpStatus = (ConfigureHealthCheckResponse -> Int)
-> (ConfigureHealthCheckResponse
    -> Int -> ConfigureHealthCheckResponse)
-> Lens
     ConfigureHealthCheckResponse ConfigureHealthCheckResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigureHealthCheckResponse' {Int
httpStatus :: Int
$sel:httpStatus:ConfigureHealthCheckResponse' :: ConfigureHealthCheckResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ConfigureHealthCheckResponse
s@ConfigureHealthCheckResponse' {} Int
a -> ConfigureHealthCheckResponse
s {$sel:httpStatus:ConfigureHealthCheckResponse' :: Int
httpStatus = Int
a} :: ConfigureHealthCheckResponse)

instance Prelude.NFData ConfigureHealthCheckResponse