{-# 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.GetHealthCheckStatus
-- 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 status of a specified health check.
--
-- This API is intended for use during development to diagnose behavior. It
-- doesn’t support production use-cases with high query rates that require
-- immediate and actionable responses.
module Amazonka.Route53.GetHealthCheckStatus
  ( -- * Creating a Request
    GetHealthCheckStatus (..),
    newGetHealthCheckStatus,

    -- * Request Lenses
    getHealthCheckStatus_healthCheckId,

    -- * Destructuring the Response
    GetHealthCheckStatusResponse (..),
    newGetHealthCheckStatusResponse,

    -- * Response Lenses
    getHealthCheckStatusResponse_httpStatus,
    getHealthCheckStatusResponse_healthCheckObservations,
  )
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 the status for a health check.
--
-- /See:/ 'newGetHealthCheckStatus' smart constructor.
data GetHealthCheckStatus = GetHealthCheckStatus'
  { -- | The ID for the health check that you want the current status for. When
    -- you created the health check, @CreateHealthCheck@ returned the ID in the
    -- response, in the @HealthCheckId@ element.
    --
    -- If you want to check the status of a calculated health check, you must
    -- use the Amazon Route 53 console or the CloudWatch console. You can\'t
    -- use @GetHealthCheckStatus@ to get the status of a calculated health
    -- check.
    GetHealthCheckStatus -> Text
healthCheckId :: Prelude.Text
  }
  deriving (GetHealthCheckStatus -> GetHealthCheckStatus -> Bool
(GetHealthCheckStatus -> GetHealthCheckStatus -> Bool)
-> (GetHealthCheckStatus -> GetHealthCheckStatus -> Bool)
-> Eq GetHealthCheckStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetHealthCheckStatus -> GetHealthCheckStatus -> Bool
$c/= :: GetHealthCheckStatus -> GetHealthCheckStatus -> Bool
== :: GetHealthCheckStatus -> GetHealthCheckStatus -> Bool
$c== :: GetHealthCheckStatus -> GetHealthCheckStatus -> Bool
Prelude.Eq, ReadPrec [GetHealthCheckStatus]
ReadPrec GetHealthCheckStatus
Int -> ReadS GetHealthCheckStatus
ReadS [GetHealthCheckStatus]
(Int -> ReadS GetHealthCheckStatus)
-> ReadS [GetHealthCheckStatus]
-> ReadPrec GetHealthCheckStatus
-> ReadPrec [GetHealthCheckStatus]
-> Read GetHealthCheckStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetHealthCheckStatus]
$creadListPrec :: ReadPrec [GetHealthCheckStatus]
readPrec :: ReadPrec GetHealthCheckStatus
$creadPrec :: ReadPrec GetHealthCheckStatus
readList :: ReadS [GetHealthCheckStatus]
$creadList :: ReadS [GetHealthCheckStatus]
readsPrec :: Int -> ReadS GetHealthCheckStatus
$creadsPrec :: Int -> ReadS GetHealthCheckStatus
Prelude.Read, Int -> GetHealthCheckStatus -> ShowS
[GetHealthCheckStatus] -> ShowS
GetHealthCheckStatus -> String
(Int -> GetHealthCheckStatus -> ShowS)
-> (GetHealthCheckStatus -> String)
-> ([GetHealthCheckStatus] -> ShowS)
-> Show GetHealthCheckStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetHealthCheckStatus] -> ShowS
$cshowList :: [GetHealthCheckStatus] -> ShowS
show :: GetHealthCheckStatus -> String
$cshow :: GetHealthCheckStatus -> String
showsPrec :: Int -> GetHealthCheckStatus -> ShowS
$cshowsPrec :: Int -> GetHealthCheckStatus -> ShowS
Prelude.Show, (forall x. GetHealthCheckStatus -> Rep GetHealthCheckStatus x)
-> (forall x. Rep GetHealthCheckStatus x -> GetHealthCheckStatus)
-> Generic GetHealthCheckStatus
forall x. Rep GetHealthCheckStatus x -> GetHealthCheckStatus
forall x. GetHealthCheckStatus -> Rep GetHealthCheckStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetHealthCheckStatus x -> GetHealthCheckStatus
$cfrom :: forall x. GetHealthCheckStatus -> Rep GetHealthCheckStatus x
Prelude.Generic)

-- |
-- Create a value of 'GetHealthCheckStatus' 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', 'getHealthCheckStatus_healthCheckId' - The ID for the health check that you want the current status for. When
-- you created the health check, @CreateHealthCheck@ returned the ID in the
-- response, in the @HealthCheckId@ element.
--
-- If you want to check the status of a calculated health check, you must
-- use the Amazon Route 53 console or the CloudWatch console. You can\'t
-- use @GetHealthCheckStatus@ to get the status of a calculated health
-- check.
newGetHealthCheckStatus ::
  -- | 'healthCheckId'
  Prelude.Text ->
  GetHealthCheckStatus
newGetHealthCheckStatus :: Text -> GetHealthCheckStatus
newGetHealthCheckStatus Text
pHealthCheckId_ =
  GetHealthCheckStatus' :: Text -> GetHealthCheckStatus
GetHealthCheckStatus'
    { $sel:healthCheckId:GetHealthCheckStatus' :: Text
healthCheckId =
        Text
pHealthCheckId_
    }

-- | The ID for the health check that you want the current status for. When
-- you created the health check, @CreateHealthCheck@ returned the ID in the
-- response, in the @HealthCheckId@ element.
--
-- If you want to check the status of a calculated health check, you must
-- use the Amazon Route 53 console or the CloudWatch console. You can\'t
-- use @GetHealthCheckStatus@ to get the status of a calculated health
-- check.
getHealthCheckStatus_healthCheckId :: Lens.Lens' GetHealthCheckStatus Prelude.Text
getHealthCheckStatus_healthCheckId :: (Text -> f Text) -> GetHealthCheckStatus -> f GetHealthCheckStatus
getHealthCheckStatus_healthCheckId = (GetHealthCheckStatus -> Text)
-> (GetHealthCheckStatus -> Text -> GetHealthCheckStatus)
-> Lens GetHealthCheckStatus GetHealthCheckStatus Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetHealthCheckStatus' {Text
healthCheckId :: Text
$sel:healthCheckId:GetHealthCheckStatus' :: GetHealthCheckStatus -> Text
healthCheckId} -> Text
healthCheckId) (\s :: GetHealthCheckStatus
s@GetHealthCheckStatus' {} Text
a -> GetHealthCheckStatus
s {$sel:healthCheckId:GetHealthCheckStatus' :: Text
healthCheckId = Text
a} :: GetHealthCheckStatus)

instance Core.AWSRequest GetHealthCheckStatus where
  type
    AWSResponse GetHealthCheckStatus =
      GetHealthCheckStatusResponse
  request :: GetHealthCheckStatus -> Request GetHealthCheckStatus
request = Service -> GetHealthCheckStatus -> Request GetHealthCheckStatus
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetHealthCheckStatus
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetHealthCheckStatus)))
response =
    (Int
 -> ResponseHeaders
 -> [Node]
 -> Either String (AWSResponse GetHealthCheckStatus))
-> Logger
-> Service
-> Proxy GetHealthCheckStatus
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetHealthCheckStatus)))
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 -> [HealthCheckObservation] -> GetHealthCheckStatusResponse
GetHealthCheckStatusResponse'
            (Int -> [HealthCheckObservation] -> GetHealthCheckStatusResponse)
-> Either String Int
-> Either
     String ([HealthCheckObservation] -> GetHealthCheckStatusResponse)
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 ([HealthCheckObservation] -> GetHealthCheckStatusResponse)
-> Either String [HealthCheckObservation]
-> Either String GetHealthCheckStatusResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"HealthCheckObservations"
                            Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String [HealthCheckObservation])
-> Either String [HealthCheckObservation]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= Text -> [Node] -> Either String [HealthCheckObservation]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"HealthCheckObservation"
                        )
      )

instance Prelude.Hashable GetHealthCheckStatus

instance Prelude.NFData GetHealthCheckStatus

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

instance Core.ToPath GetHealthCheckStatus where
  toPath :: GetHealthCheckStatus -> ByteString
toPath GetHealthCheckStatus' {Text
healthCheckId :: Text
$sel:healthCheckId:GetHealthCheckStatus' :: GetHealthCheckStatus -> 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,
        ByteString
"/status"
      ]

instance Core.ToQuery GetHealthCheckStatus where
  toQuery :: GetHealthCheckStatus -> QueryString
toQuery = QueryString -> GetHealthCheckStatus -> 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:/ 'newGetHealthCheckStatusResponse' smart constructor.
data GetHealthCheckStatusResponse = GetHealthCheckStatusResponse'
  { -- | The response's http status code.
    GetHealthCheckStatusResponse -> Int
httpStatus :: Prelude.Int,
    -- | A list that contains one @HealthCheckObservation@ element for each
    -- Amazon Route 53 health checker that is reporting a status about the
    -- health check endpoint.
    GetHealthCheckStatusResponse -> [HealthCheckObservation]
healthCheckObservations :: [HealthCheckObservation]
  }
  deriving (GetHealthCheckStatusResponse
-> GetHealthCheckStatusResponse -> Bool
(GetHealthCheckStatusResponse
 -> GetHealthCheckStatusResponse -> Bool)
-> (GetHealthCheckStatusResponse
    -> GetHealthCheckStatusResponse -> Bool)
-> Eq GetHealthCheckStatusResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetHealthCheckStatusResponse
-> GetHealthCheckStatusResponse -> Bool
$c/= :: GetHealthCheckStatusResponse
-> GetHealthCheckStatusResponse -> Bool
== :: GetHealthCheckStatusResponse
-> GetHealthCheckStatusResponse -> Bool
$c== :: GetHealthCheckStatusResponse
-> GetHealthCheckStatusResponse -> Bool
Prelude.Eq, ReadPrec [GetHealthCheckStatusResponse]
ReadPrec GetHealthCheckStatusResponse
Int -> ReadS GetHealthCheckStatusResponse
ReadS [GetHealthCheckStatusResponse]
(Int -> ReadS GetHealthCheckStatusResponse)
-> ReadS [GetHealthCheckStatusResponse]
-> ReadPrec GetHealthCheckStatusResponse
-> ReadPrec [GetHealthCheckStatusResponse]
-> Read GetHealthCheckStatusResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetHealthCheckStatusResponse]
$creadListPrec :: ReadPrec [GetHealthCheckStatusResponse]
readPrec :: ReadPrec GetHealthCheckStatusResponse
$creadPrec :: ReadPrec GetHealthCheckStatusResponse
readList :: ReadS [GetHealthCheckStatusResponse]
$creadList :: ReadS [GetHealthCheckStatusResponse]
readsPrec :: Int -> ReadS GetHealthCheckStatusResponse
$creadsPrec :: Int -> ReadS GetHealthCheckStatusResponse
Prelude.Read, Int -> GetHealthCheckStatusResponse -> ShowS
[GetHealthCheckStatusResponse] -> ShowS
GetHealthCheckStatusResponse -> String
(Int -> GetHealthCheckStatusResponse -> ShowS)
-> (GetHealthCheckStatusResponse -> String)
-> ([GetHealthCheckStatusResponse] -> ShowS)
-> Show GetHealthCheckStatusResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetHealthCheckStatusResponse] -> ShowS
$cshowList :: [GetHealthCheckStatusResponse] -> ShowS
show :: GetHealthCheckStatusResponse -> String
$cshow :: GetHealthCheckStatusResponse -> String
showsPrec :: Int -> GetHealthCheckStatusResponse -> ShowS
$cshowsPrec :: Int -> GetHealthCheckStatusResponse -> ShowS
Prelude.Show, (forall x.
 GetHealthCheckStatusResponse -> Rep GetHealthCheckStatusResponse x)
-> (forall x.
    Rep GetHealthCheckStatusResponse x -> GetHealthCheckStatusResponse)
-> Generic GetHealthCheckStatusResponse
forall x.
Rep GetHealthCheckStatusResponse x -> GetHealthCheckStatusResponse
forall x.
GetHealthCheckStatusResponse -> Rep GetHealthCheckStatusResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetHealthCheckStatusResponse x -> GetHealthCheckStatusResponse
$cfrom :: forall x.
GetHealthCheckStatusResponse -> Rep GetHealthCheckStatusResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetHealthCheckStatusResponse' 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', 'getHealthCheckStatusResponse_httpStatus' - The response's http status code.
--
-- 'healthCheckObservations', 'getHealthCheckStatusResponse_healthCheckObservations' - A list that contains one @HealthCheckObservation@ element for each
-- Amazon Route 53 health checker that is reporting a status about the
-- health check endpoint.
newGetHealthCheckStatusResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetHealthCheckStatusResponse
newGetHealthCheckStatusResponse :: Int -> GetHealthCheckStatusResponse
newGetHealthCheckStatusResponse Int
pHttpStatus_ =
  GetHealthCheckStatusResponse' :: Int -> [HealthCheckObservation] -> GetHealthCheckStatusResponse
GetHealthCheckStatusResponse'
    { $sel:httpStatus:GetHealthCheckStatusResponse' :: Int
httpStatus =
        Int
pHttpStatus_,
      $sel:healthCheckObservations:GetHealthCheckStatusResponse' :: [HealthCheckObservation]
healthCheckObservations = [HealthCheckObservation]
forall a. Monoid a => a
Prelude.mempty
    }

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

-- | A list that contains one @HealthCheckObservation@ element for each
-- Amazon Route 53 health checker that is reporting a status about the
-- health check endpoint.
getHealthCheckStatusResponse_healthCheckObservations :: Lens.Lens' GetHealthCheckStatusResponse [HealthCheckObservation]
getHealthCheckStatusResponse_healthCheckObservations :: ([HealthCheckObservation] -> f [HealthCheckObservation])
-> GetHealthCheckStatusResponse -> f GetHealthCheckStatusResponse
getHealthCheckStatusResponse_healthCheckObservations = (GetHealthCheckStatusResponse -> [HealthCheckObservation])
-> (GetHealthCheckStatusResponse
    -> [HealthCheckObservation] -> GetHealthCheckStatusResponse)
-> Lens
     GetHealthCheckStatusResponse
     GetHealthCheckStatusResponse
     [HealthCheckObservation]
     [HealthCheckObservation]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetHealthCheckStatusResponse' {[HealthCheckObservation]
healthCheckObservations :: [HealthCheckObservation]
$sel:healthCheckObservations:GetHealthCheckStatusResponse' :: GetHealthCheckStatusResponse -> [HealthCheckObservation]
healthCheckObservations} -> [HealthCheckObservation]
healthCheckObservations) (\s :: GetHealthCheckStatusResponse
s@GetHealthCheckStatusResponse' {} [HealthCheckObservation]
a -> GetHealthCheckStatusResponse
s {$sel:healthCheckObservations:GetHealthCheckStatusResponse' :: [HealthCheckObservation]
healthCheckObservations = [HealthCheckObservation]
a} :: GetHealthCheckStatusResponse) (([HealthCheckObservation] -> f [HealthCheckObservation])
 -> GetHealthCheckStatusResponse -> f GetHealthCheckStatusResponse)
-> (([HealthCheckObservation] -> f [HealthCheckObservation])
    -> [HealthCheckObservation] -> f [HealthCheckObservation])
-> ([HealthCheckObservation] -> f [HealthCheckObservation])
-> GetHealthCheckStatusResponse
-> f GetHealthCheckStatusResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([HealthCheckObservation] -> f [HealthCheckObservation])
-> [HealthCheckObservation] -> f [HealthCheckObservation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData GetHealthCheckStatusResponse