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

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

-- |
-- Module      : Amazonka.AppRunner.Types.HealthCheckConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AppRunner.Types.HealthCheckConfiguration where

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

-- | Describes the settings for the health check that App Runner performs to
-- monitor the health of a service.
--
-- /See:/ 'newHealthCheckConfiguration' smart constructor.
data HealthCheckConfiguration = HealthCheckConfiguration'
  { -- | The number of consecutive checks that must succeed before App Runner
    -- decides that the service is healthy.
    --
    -- Default: @1@
    HealthCheckConfiguration -> Maybe Natural
healthyThreshold :: Prelude.Maybe Prelude.Natural,
    -- | The time interval, in seconds, between health checks.
    --
    -- Default: @5@
    HealthCheckConfiguration -> Maybe Natural
interval :: Prelude.Maybe Prelude.Natural,
    -- | The URL that health check requests are sent to.
    --
    -- @Path@ is only applicable when you set @Protocol@ to @HTTP@.
    --
    -- Default: @\"\/\"@
    HealthCheckConfiguration -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
    -- | The IP protocol that App Runner uses to perform health checks for your
    -- service.
    --
    -- If you set @Protocol@ to @HTTP@, App Runner sends health check requests
    -- to the HTTP path specified by @Path@.
    --
    -- Default: @TCP@
    HealthCheckConfiguration -> Maybe HealthCheckProtocol
protocol :: Prelude.Maybe HealthCheckProtocol,
    -- | The time, in seconds, to wait for a health check response before
    -- deciding it failed.
    --
    -- Default: @2@
    HealthCheckConfiguration -> Maybe Natural
timeout :: Prelude.Maybe Prelude.Natural,
    -- | The number of consecutive checks that must fail before App Runner
    -- decides that the service is unhealthy.
    --
    -- Default: @5@
    HealthCheckConfiguration -> Maybe Natural
unhealthyThreshold :: Prelude.Maybe Prelude.Natural
  }
  deriving (HealthCheckConfiguration -> HealthCheckConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HealthCheckConfiguration -> HealthCheckConfiguration -> Bool
$c/= :: HealthCheckConfiguration -> HealthCheckConfiguration -> Bool
== :: HealthCheckConfiguration -> HealthCheckConfiguration -> Bool
$c== :: HealthCheckConfiguration -> HealthCheckConfiguration -> Bool
Prelude.Eq, ReadPrec [HealthCheckConfiguration]
ReadPrec HealthCheckConfiguration
Int -> ReadS HealthCheckConfiguration
ReadS [HealthCheckConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HealthCheckConfiguration]
$creadListPrec :: ReadPrec [HealthCheckConfiguration]
readPrec :: ReadPrec HealthCheckConfiguration
$creadPrec :: ReadPrec HealthCheckConfiguration
readList :: ReadS [HealthCheckConfiguration]
$creadList :: ReadS [HealthCheckConfiguration]
readsPrec :: Int -> ReadS HealthCheckConfiguration
$creadsPrec :: Int -> ReadS HealthCheckConfiguration
Prelude.Read, Int -> HealthCheckConfiguration -> ShowS
[HealthCheckConfiguration] -> ShowS
HealthCheckConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HealthCheckConfiguration] -> ShowS
$cshowList :: [HealthCheckConfiguration] -> ShowS
show :: HealthCheckConfiguration -> String
$cshow :: HealthCheckConfiguration -> String
showsPrec :: Int -> HealthCheckConfiguration -> ShowS
$cshowsPrec :: Int -> HealthCheckConfiguration -> ShowS
Prelude.Show, forall x.
Rep HealthCheckConfiguration x -> HealthCheckConfiguration
forall x.
HealthCheckConfiguration -> Rep HealthCheckConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep HealthCheckConfiguration x -> HealthCheckConfiguration
$cfrom :: forall x.
HealthCheckConfiguration -> Rep HealthCheckConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'HealthCheckConfiguration' 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:
--
-- 'healthyThreshold', 'healthCheckConfiguration_healthyThreshold' - The number of consecutive checks that must succeed before App Runner
-- decides that the service is healthy.
--
-- Default: @1@
--
-- 'interval', 'healthCheckConfiguration_interval' - The time interval, in seconds, between health checks.
--
-- Default: @5@
--
-- 'path', 'healthCheckConfiguration_path' - The URL that health check requests are sent to.
--
-- @Path@ is only applicable when you set @Protocol@ to @HTTP@.
--
-- Default: @\"\/\"@
--
-- 'protocol', 'healthCheckConfiguration_protocol' - The IP protocol that App Runner uses to perform health checks for your
-- service.
--
-- If you set @Protocol@ to @HTTP@, App Runner sends health check requests
-- to the HTTP path specified by @Path@.
--
-- Default: @TCP@
--
-- 'timeout', 'healthCheckConfiguration_timeout' - The time, in seconds, to wait for a health check response before
-- deciding it failed.
--
-- Default: @2@
--
-- 'unhealthyThreshold', 'healthCheckConfiguration_unhealthyThreshold' - The number of consecutive checks that must fail before App Runner
-- decides that the service is unhealthy.
--
-- Default: @5@
newHealthCheckConfiguration ::
  HealthCheckConfiguration
newHealthCheckConfiguration :: HealthCheckConfiguration
newHealthCheckConfiguration =
  HealthCheckConfiguration'
    { $sel:healthyThreshold:HealthCheckConfiguration' :: Maybe Natural
healthyThreshold =
        forall a. Maybe a
Prelude.Nothing,
      $sel:interval:HealthCheckConfiguration' :: Maybe Natural
interval = forall a. Maybe a
Prelude.Nothing,
      $sel:path:HealthCheckConfiguration' :: Maybe Text
path = forall a. Maybe a
Prelude.Nothing,
      $sel:protocol:HealthCheckConfiguration' :: Maybe HealthCheckProtocol
protocol = forall a. Maybe a
Prelude.Nothing,
      $sel:timeout:HealthCheckConfiguration' :: Maybe Natural
timeout = forall a. Maybe a
Prelude.Nothing,
      $sel:unhealthyThreshold:HealthCheckConfiguration' :: Maybe Natural
unhealthyThreshold = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of consecutive checks that must succeed before App Runner
-- decides that the service is healthy.
--
-- Default: @1@
healthCheckConfiguration_healthyThreshold :: Lens.Lens' HealthCheckConfiguration (Prelude.Maybe Prelude.Natural)
healthCheckConfiguration_healthyThreshold :: Lens' HealthCheckConfiguration (Maybe Natural)
healthCheckConfiguration_healthyThreshold = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HealthCheckConfiguration' {Maybe Natural
healthyThreshold :: Maybe Natural
$sel:healthyThreshold:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Natural
healthyThreshold} -> Maybe Natural
healthyThreshold) (\s :: HealthCheckConfiguration
s@HealthCheckConfiguration' {} Maybe Natural
a -> HealthCheckConfiguration
s {$sel:healthyThreshold:HealthCheckConfiguration' :: Maybe Natural
healthyThreshold = Maybe Natural
a} :: HealthCheckConfiguration)

-- | The time interval, in seconds, between health checks.
--
-- Default: @5@
healthCheckConfiguration_interval :: Lens.Lens' HealthCheckConfiguration (Prelude.Maybe Prelude.Natural)
healthCheckConfiguration_interval :: Lens' HealthCheckConfiguration (Maybe Natural)
healthCheckConfiguration_interval = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HealthCheckConfiguration' {Maybe Natural
interval :: Maybe Natural
$sel:interval:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Natural
interval} -> Maybe Natural
interval) (\s :: HealthCheckConfiguration
s@HealthCheckConfiguration' {} Maybe Natural
a -> HealthCheckConfiguration
s {$sel:interval:HealthCheckConfiguration' :: Maybe Natural
interval = Maybe Natural
a} :: HealthCheckConfiguration)

-- | The URL that health check requests are sent to.
--
-- @Path@ is only applicable when you set @Protocol@ to @HTTP@.
--
-- Default: @\"\/\"@
healthCheckConfiguration_path :: Lens.Lens' HealthCheckConfiguration (Prelude.Maybe Prelude.Text)
healthCheckConfiguration_path :: Lens' HealthCheckConfiguration (Maybe Text)
healthCheckConfiguration_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HealthCheckConfiguration' {Maybe Text
path :: Maybe Text
$sel:path:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Text
path} -> Maybe Text
path) (\s :: HealthCheckConfiguration
s@HealthCheckConfiguration' {} Maybe Text
a -> HealthCheckConfiguration
s {$sel:path:HealthCheckConfiguration' :: Maybe Text
path = Maybe Text
a} :: HealthCheckConfiguration)

-- | The IP protocol that App Runner uses to perform health checks for your
-- service.
--
-- If you set @Protocol@ to @HTTP@, App Runner sends health check requests
-- to the HTTP path specified by @Path@.
--
-- Default: @TCP@
healthCheckConfiguration_protocol :: Lens.Lens' HealthCheckConfiguration (Prelude.Maybe HealthCheckProtocol)
healthCheckConfiguration_protocol :: Lens' HealthCheckConfiguration (Maybe HealthCheckProtocol)
healthCheckConfiguration_protocol = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HealthCheckConfiguration' {Maybe HealthCheckProtocol
protocol :: Maybe HealthCheckProtocol
$sel:protocol:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe HealthCheckProtocol
protocol} -> Maybe HealthCheckProtocol
protocol) (\s :: HealthCheckConfiguration
s@HealthCheckConfiguration' {} Maybe HealthCheckProtocol
a -> HealthCheckConfiguration
s {$sel:protocol:HealthCheckConfiguration' :: Maybe HealthCheckProtocol
protocol = Maybe HealthCheckProtocol
a} :: HealthCheckConfiguration)

-- | The time, in seconds, to wait for a health check response before
-- deciding it failed.
--
-- Default: @2@
healthCheckConfiguration_timeout :: Lens.Lens' HealthCheckConfiguration (Prelude.Maybe Prelude.Natural)
healthCheckConfiguration_timeout :: Lens' HealthCheckConfiguration (Maybe Natural)
healthCheckConfiguration_timeout = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HealthCheckConfiguration' {Maybe Natural
timeout :: Maybe Natural
$sel:timeout:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Natural
timeout} -> Maybe Natural
timeout) (\s :: HealthCheckConfiguration
s@HealthCheckConfiguration' {} Maybe Natural
a -> HealthCheckConfiguration
s {$sel:timeout:HealthCheckConfiguration' :: Maybe Natural
timeout = Maybe Natural
a} :: HealthCheckConfiguration)

-- | The number of consecutive checks that must fail before App Runner
-- decides that the service is unhealthy.
--
-- Default: @5@
healthCheckConfiguration_unhealthyThreshold :: Lens.Lens' HealthCheckConfiguration (Prelude.Maybe Prelude.Natural)
healthCheckConfiguration_unhealthyThreshold :: Lens' HealthCheckConfiguration (Maybe Natural)
healthCheckConfiguration_unhealthyThreshold = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HealthCheckConfiguration' {Maybe Natural
unhealthyThreshold :: Maybe Natural
$sel:unhealthyThreshold:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Natural
unhealthyThreshold} -> Maybe Natural
unhealthyThreshold) (\s :: HealthCheckConfiguration
s@HealthCheckConfiguration' {} Maybe Natural
a -> HealthCheckConfiguration
s {$sel:unhealthyThreshold:HealthCheckConfiguration' :: Maybe Natural
unhealthyThreshold = Maybe Natural
a} :: HealthCheckConfiguration)

instance Data.FromJSON HealthCheckConfiguration where
  parseJSON :: Value -> Parser HealthCheckConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"HealthCheckConfiguration"
      ( \Object
x ->
          Maybe Natural
-> Maybe Natural
-> Maybe Text
-> Maybe HealthCheckProtocol
-> Maybe Natural
-> Maybe Natural
-> HealthCheckConfiguration
HealthCheckConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"HealthyThreshold")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Interval")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Path")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Protocol")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Timeout")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"UnhealthyThreshold")
      )

instance Prelude.Hashable HealthCheckConfiguration where
  hashWithSalt :: Int -> HealthCheckConfiguration -> Int
hashWithSalt Int
_salt HealthCheckConfiguration' {Maybe Natural
Maybe Text
Maybe HealthCheckProtocol
unhealthyThreshold :: Maybe Natural
timeout :: Maybe Natural
protocol :: Maybe HealthCheckProtocol
path :: Maybe Text
interval :: Maybe Natural
healthyThreshold :: Maybe Natural
$sel:unhealthyThreshold:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Natural
$sel:timeout:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Natural
$sel:protocol:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe HealthCheckProtocol
$sel:path:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Text
$sel:interval:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Natural
$sel:healthyThreshold:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
healthyThreshold
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
interval
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
path
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe HealthCheckProtocol
protocol
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
timeout
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
unhealthyThreshold

instance Prelude.NFData HealthCheckConfiguration where
  rnf :: HealthCheckConfiguration -> ()
rnf HealthCheckConfiguration' {Maybe Natural
Maybe Text
Maybe HealthCheckProtocol
unhealthyThreshold :: Maybe Natural
timeout :: Maybe Natural
protocol :: Maybe HealthCheckProtocol
path :: Maybe Text
interval :: Maybe Natural
healthyThreshold :: Maybe Natural
$sel:unhealthyThreshold:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Natural
$sel:timeout:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Natural
$sel:protocol:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe HealthCheckProtocol
$sel:path:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Text
$sel:interval:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Natural
$sel:healthyThreshold:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
healthyThreshold
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
interval
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
path
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe HealthCheckProtocol
protocol
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
timeout
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
unhealthyThreshold

instance Data.ToJSON HealthCheckConfiguration where
  toJSON :: HealthCheckConfiguration -> Value
toJSON HealthCheckConfiguration' {Maybe Natural
Maybe Text
Maybe HealthCheckProtocol
unhealthyThreshold :: Maybe Natural
timeout :: Maybe Natural
protocol :: Maybe HealthCheckProtocol
path :: Maybe Text
interval :: Maybe Natural
healthyThreshold :: Maybe Natural
$sel:unhealthyThreshold:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Natural
$sel:timeout:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Natural
$sel:protocol:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe HealthCheckProtocol
$sel:path:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Text
$sel:interval:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Natural
$sel:healthyThreshold:HealthCheckConfiguration' :: HealthCheckConfiguration -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"HealthyThreshold" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
healthyThreshold,
            (Key
"Interval" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
interval,
            (Key
"Path" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
path,
            (Key
"Protocol" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HealthCheckProtocol
protocol,
            (Key
"Timeout" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
timeout,
            (Key
"UnhealthyThreshold" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
unhealthyThreshold
          ]
      )