{-# 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.Route53.GetHealthCheck
-- 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)
--
-- Gets information about a specified health check.
module Amazonka.Route53.GetHealthCheck
  ( -- * Creating a Request
    GetHealthCheck (..),
    newGetHealthCheck,

    -- * Request Lenses
    getHealthCheck_healthCheckId,

    -- * Destructuring the Response
    GetHealthCheckResponse (..),
    newGetHealthCheckResponse,

    -- * Response Lenses
    getHealthCheckResponse_httpStatus,
    getHealthCheckResponse_healthCheck,
  )
where

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
import Amazonka.Route53.Types

-- | A request to get information about a specified health check.
--
-- /See:/ 'newGetHealthCheck' smart constructor.
data GetHealthCheck = GetHealthCheck'
  { -- | The identifier that Amazon Route 53 assigned to the health check when
    -- you created it. When you add or update a resource record set, you use
    -- this value to specify which health check to use. The value can be up to
    -- 64 characters long.
    GetHealthCheck -> Text
healthCheckId :: Prelude.Text
  }
  deriving (GetHealthCheck -> GetHealthCheck -> Bool
(GetHealthCheck -> GetHealthCheck -> Bool)
-> (GetHealthCheck -> GetHealthCheck -> Bool) -> Eq GetHealthCheck
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetHealthCheck -> GetHealthCheck -> Bool
$c/= :: GetHealthCheck -> GetHealthCheck -> Bool
== :: GetHealthCheck -> GetHealthCheck -> Bool
$c== :: GetHealthCheck -> GetHealthCheck -> Bool
Prelude.Eq, ReadPrec [GetHealthCheck]
ReadPrec GetHealthCheck
Int -> ReadS GetHealthCheck
ReadS [GetHealthCheck]
(Int -> ReadS GetHealthCheck)
-> ReadS [GetHealthCheck]
-> ReadPrec GetHealthCheck
-> ReadPrec [GetHealthCheck]
-> Read GetHealthCheck
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetHealthCheck]
$creadListPrec :: ReadPrec [GetHealthCheck]
readPrec :: ReadPrec GetHealthCheck
$creadPrec :: ReadPrec GetHealthCheck
readList :: ReadS [GetHealthCheck]
$creadList :: ReadS [GetHealthCheck]
readsPrec :: Int -> ReadS GetHealthCheck
$creadsPrec :: Int -> ReadS GetHealthCheck
Prelude.Read, Int -> GetHealthCheck -> ShowS
[GetHealthCheck] -> ShowS
GetHealthCheck -> String
(Int -> GetHealthCheck -> ShowS)
-> (GetHealthCheck -> String)
-> ([GetHealthCheck] -> ShowS)
-> Show GetHealthCheck
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetHealthCheck] -> ShowS
$cshowList :: [GetHealthCheck] -> ShowS
show :: GetHealthCheck -> String
$cshow :: GetHealthCheck -> String
showsPrec :: Int -> GetHealthCheck -> ShowS
$cshowsPrec :: Int -> GetHealthCheck -> ShowS
Prelude.Show, (forall x. GetHealthCheck -> Rep GetHealthCheck x)
-> (forall x. Rep GetHealthCheck x -> GetHealthCheck)
-> Generic GetHealthCheck
forall x. Rep GetHealthCheck x -> GetHealthCheck
forall x. GetHealthCheck -> Rep GetHealthCheck x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetHealthCheck x -> GetHealthCheck
$cfrom :: forall x. GetHealthCheck -> Rep GetHealthCheck x
Prelude.Generic)

-- |
-- Create a value of 'GetHealthCheck' 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:
--
-- 'healthCheckId', 'getHealthCheck_healthCheckId' - The identifier that Amazon Route 53 assigned to the health check when
-- you created it. When you add or update a resource record set, you use
-- this value to specify which health check to use. The value can be up to
-- 64 characters long.
newGetHealthCheck ::
  -- | 'healthCheckId'
  Prelude.Text ->
  GetHealthCheck
newGetHealthCheck :: Text -> GetHealthCheck
newGetHealthCheck Text
pHealthCheckId_ =
  GetHealthCheck' :: Text -> GetHealthCheck
GetHealthCheck' {$sel:healthCheckId:GetHealthCheck' :: Text
healthCheckId = Text
pHealthCheckId_}

-- | The identifier that Amazon Route 53 assigned to the health check when
-- you created it. When you add or update a resource record set, you use
-- this value to specify which health check to use. The value can be up to
-- 64 characters long.
getHealthCheck_healthCheckId :: Lens.Lens' GetHealthCheck Prelude.Text
getHealthCheck_healthCheckId :: (Text -> f Text) -> GetHealthCheck -> f GetHealthCheck
getHealthCheck_healthCheckId = (GetHealthCheck -> Text)
-> (GetHealthCheck -> Text -> GetHealthCheck)
-> Lens GetHealthCheck GetHealthCheck Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetHealthCheck' {Text
healthCheckId :: Text
$sel:healthCheckId:GetHealthCheck' :: GetHealthCheck -> Text
healthCheckId} -> Text
healthCheckId) (\s :: GetHealthCheck
s@GetHealthCheck' {} Text
a -> GetHealthCheck
s {$sel:healthCheckId:GetHealthCheck' :: Text
healthCheckId = Text
a} :: GetHealthCheck)

instance Core.AWSRequest GetHealthCheck where
  type
    AWSResponse GetHealthCheck =
      GetHealthCheckResponse
  request :: GetHealthCheck -> Request GetHealthCheck
request = Service -> GetHealthCheck -> Request GetHealthCheck
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetHealthCheck
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetHealthCheck)))
response =
    (Int
 -> ResponseHeaders
 -> [Node]
 -> Either String (AWSResponse GetHealthCheck))
-> Logger
-> Service
-> Proxy GetHealthCheck
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetHealthCheck)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> HealthCheck -> GetHealthCheckResponse
GetHealthCheckResponse'
            (Int -> HealthCheck -> GetHealthCheckResponse)
-> Either String Int
-> Either String (HealthCheck -> GetHealthCheckResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (HealthCheck -> GetHealthCheckResponse)
-> Either String HealthCheck
-> Either String GetHealthCheckResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String HealthCheck
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"HealthCheck")
      )

instance Prelude.Hashable GetHealthCheck

instance Prelude.NFData GetHealthCheck

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

instance Core.ToPath GetHealthCheck where
  toPath :: GetHealthCheck -> ByteString
toPath GetHealthCheck' {Text
healthCheckId :: Text
$sel:healthCheckId:GetHealthCheck' :: GetHealthCheck -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2013-04-01/healthcheck/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
healthCheckId]

instance Core.ToQuery GetHealthCheck where
  toQuery :: GetHealthCheck -> QueryString
toQuery = QueryString -> GetHealthCheck -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | A complex type that contains the response to a @GetHealthCheck@ request.
--
-- /See:/ 'newGetHealthCheckResponse' smart constructor.
data GetHealthCheckResponse = GetHealthCheckResponse'
  { -- | The response's http status code.
    GetHealthCheckResponse -> Int
httpStatus :: Prelude.Int,
    -- | A complex type that contains information about one health check that is
    -- associated with the current Amazon Web Services account.
    GetHealthCheckResponse -> HealthCheck
healthCheck :: HealthCheck
  }
  deriving (GetHealthCheckResponse -> GetHealthCheckResponse -> Bool
(GetHealthCheckResponse -> GetHealthCheckResponse -> Bool)
-> (GetHealthCheckResponse -> GetHealthCheckResponse -> Bool)
-> Eq GetHealthCheckResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetHealthCheckResponse -> GetHealthCheckResponse -> Bool
$c/= :: GetHealthCheckResponse -> GetHealthCheckResponse -> Bool
== :: GetHealthCheckResponse -> GetHealthCheckResponse -> Bool
$c== :: GetHealthCheckResponse -> GetHealthCheckResponse -> Bool
Prelude.Eq, ReadPrec [GetHealthCheckResponse]
ReadPrec GetHealthCheckResponse
Int -> ReadS GetHealthCheckResponse
ReadS [GetHealthCheckResponse]
(Int -> ReadS GetHealthCheckResponse)
-> ReadS [GetHealthCheckResponse]
-> ReadPrec GetHealthCheckResponse
-> ReadPrec [GetHealthCheckResponse]
-> Read GetHealthCheckResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetHealthCheckResponse]
$creadListPrec :: ReadPrec [GetHealthCheckResponse]
readPrec :: ReadPrec GetHealthCheckResponse
$creadPrec :: ReadPrec GetHealthCheckResponse
readList :: ReadS [GetHealthCheckResponse]
$creadList :: ReadS [GetHealthCheckResponse]
readsPrec :: Int -> ReadS GetHealthCheckResponse
$creadsPrec :: Int -> ReadS GetHealthCheckResponse
Prelude.Read, Int -> GetHealthCheckResponse -> ShowS
[GetHealthCheckResponse] -> ShowS
GetHealthCheckResponse -> String
(Int -> GetHealthCheckResponse -> ShowS)
-> (GetHealthCheckResponse -> String)
-> ([GetHealthCheckResponse] -> ShowS)
-> Show GetHealthCheckResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetHealthCheckResponse] -> ShowS
$cshowList :: [GetHealthCheckResponse] -> ShowS
show :: GetHealthCheckResponse -> String
$cshow :: GetHealthCheckResponse -> String
showsPrec :: Int -> GetHealthCheckResponse -> ShowS
$cshowsPrec :: Int -> GetHealthCheckResponse -> ShowS
Prelude.Show, (forall x. GetHealthCheckResponse -> Rep GetHealthCheckResponse x)
-> (forall x.
    Rep GetHealthCheckResponse x -> GetHealthCheckResponse)
-> Generic GetHealthCheckResponse
forall x. Rep GetHealthCheckResponse x -> GetHealthCheckResponse
forall x. GetHealthCheckResponse -> Rep GetHealthCheckResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetHealthCheckResponse x -> GetHealthCheckResponse
$cfrom :: forall x. GetHealthCheckResponse -> Rep GetHealthCheckResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetHealthCheckResponse' 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:
--
-- 'httpStatus', 'getHealthCheckResponse_httpStatus' - The response's http status code.
--
-- 'healthCheck', 'getHealthCheckResponse_healthCheck' - A complex type that contains information about one health check that is
-- associated with the current Amazon Web Services account.
newGetHealthCheckResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'healthCheck'
  HealthCheck ->
  GetHealthCheckResponse
newGetHealthCheckResponse :: Int -> HealthCheck -> GetHealthCheckResponse
newGetHealthCheckResponse Int
pHttpStatus_ HealthCheck
pHealthCheck_ =
  GetHealthCheckResponse' :: Int -> HealthCheck -> GetHealthCheckResponse
GetHealthCheckResponse'
    { $sel:httpStatus:GetHealthCheckResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:healthCheck:GetHealthCheckResponse' :: HealthCheck
healthCheck = HealthCheck
pHealthCheck_
    }

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

-- | A complex type that contains information about one health check that is
-- associated with the current Amazon Web Services account.
getHealthCheckResponse_healthCheck :: Lens.Lens' GetHealthCheckResponse HealthCheck
getHealthCheckResponse_healthCheck :: (HealthCheck -> f HealthCheck)
-> GetHealthCheckResponse -> f GetHealthCheckResponse
getHealthCheckResponse_healthCheck = (GetHealthCheckResponse -> HealthCheck)
-> (GetHealthCheckResponse
    -> HealthCheck -> GetHealthCheckResponse)
-> Lens
     GetHealthCheckResponse
     GetHealthCheckResponse
     HealthCheck
     HealthCheck
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetHealthCheckResponse' {HealthCheck
healthCheck :: HealthCheck
$sel:healthCheck:GetHealthCheckResponse' :: GetHealthCheckResponse -> HealthCheck
healthCheck} -> HealthCheck
healthCheck) (\s :: GetHealthCheckResponse
s@GetHealthCheckResponse' {} HealthCheck
a -> GetHealthCheckResponse
s {$sel:healthCheck:GetHealthCheckResponse' :: HealthCheck
healthCheck = HealthCheck
a} :: GetHealthCheckResponse)

instance Prelude.NFData GetHealthCheckResponse