{-# 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.AppMesh.Types.VirtualGatewayHealthCheckPolicy
-- 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)
module Amazonka.AppMesh.Types.VirtualGatewayHealthCheckPolicy where

import Amazonka.AppMesh.Types.VirtualGatewayPortProtocol
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that represents the health check policy for a virtual
-- gateway\'s listener.
--
-- /See:/ 'newVirtualGatewayHealthCheckPolicy' smart constructor.
data VirtualGatewayHealthCheckPolicy = VirtualGatewayHealthCheckPolicy'
  { -- | The destination path for the health check request. This value is only
    -- used if the specified protocol is HTTP or HTTP\/2. For any other
    -- protocol, this value is ignored.
    VirtualGatewayHealthCheckPolicy -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
    -- | The destination port for the health check request. This port must match
    -- the port defined in the PortMapping for the listener.
    VirtualGatewayHealthCheckPolicy -> Maybe Natural
port :: Prelude.Maybe Prelude.Natural,
    -- | The number of consecutive successful health checks that must occur
    -- before declaring the listener healthy.
    VirtualGatewayHealthCheckPolicy -> Natural
healthyThreshold :: Prelude.Natural,
    -- | The time period in milliseconds between each health check execution.
    VirtualGatewayHealthCheckPolicy -> Natural
intervalMillis :: Prelude.Natural,
    -- | The protocol for the health check request. If you specify @grpc@, then
    -- your service must conform to the
    -- <https://github.com/grpc/grpc/blob/master/doc/health-checking.md GRPC Health Checking Protocol>.
    VirtualGatewayHealthCheckPolicy -> VirtualGatewayPortProtocol
protocol :: VirtualGatewayPortProtocol,
    -- | The amount of time to wait when receiving a response from the health
    -- check, in milliseconds.
    VirtualGatewayHealthCheckPolicy -> Natural
timeoutMillis :: Prelude.Natural,
    -- | The number of consecutive failed health checks that must occur before
    -- declaring a virtual gateway unhealthy.
    VirtualGatewayHealthCheckPolicy -> Natural
unhealthyThreshold :: Prelude.Natural
  }
  deriving (VirtualGatewayHealthCheckPolicy
-> VirtualGatewayHealthCheckPolicy -> Bool
(VirtualGatewayHealthCheckPolicy
 -> VirtualGatewayHealthCheckPolicy -> Bool)
-> (VirtualGatewayHealthCheckPolicy
    -> VirtualGatewayHealthCheckPolicy -> Bool)
-> Eq VirtualGatewayHealthCheckPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualGatewayHealthCheckPolicy
-> VirtualGatewayHealthCheckPolicy -> Bool
$c/= :: VirtualGatewayHealthCheckPolicy
-> VirtualGatewayHealthCheckPolicy -> Bool
== :: VirtualGatewayHealthCheckPolicy
-> VirtualGatewayHealthCheckPolicy -> Bool
$c== :: VirtualGatewayHealthCheckPolicy
-> VirtualGatewayHealthCheckPolicy -> Bool
Prelude.Eq, ReadPrec [VirtualGatewayHealthCheckPolicy]
ReadPrec VirtualGatewayHealthCheckPolicy
Int -> ReadS VirtualGatewayHealthCheckPolicy
ReadS [VirtualGatewayHealthCheckPolicy]
(Int -> ReadS VirtualGatewayHealthCheckPolicy)
-> ReadS [VirtualGatewayHealthCheckPolicy]
-> ReadPrec VirtualGatewayHealthCheckPolicy
-> ReadPrec [VirtualGatewayHealthCheckPolicy]
-> Read VirtualGatewayHealthCheckPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VirtualGatewayHealthCheckPolicy]
$creadListPrec :: ReadPrec [VirtualGatewayHealthCheckPolicy]
readPrec :: ReadPrec VirtualGatewayHealthCheckPolicy
$creadPrec :: ReadPrec VirtualGatewayHealthCheckPolicy
readList :: ReadS [VirtualGatewayHealthCheckPolicy]
$creadList :: ReadS [VirtualGatewayHealthCheckPolicy]
readsPrec :: Int -> ReadS VirtualGatewayHealthCheckPolicy
$creadsPrec :: Int -> ReadS VirtualGatewayHealthCheckPolicy
Prelude.Read, Int -> VirtualGatewayHealthCheckPolicy -> ShowS
[VirtualGatewayHealthCheckPolicy] -> ShowS
VirtualGatewayHealthCheckPolicy -> String
(Int -> VirtualGatewayHealthCheckPolicy -> ShowS)
-> (VirtualGatewayHealthCheckPolicy -> String)
-> ([VirtualGatewayHealthCheckPolicy] -> ShowS)
-> Show VirtualGatewayHealthCheckPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VirtualGatewayHealthCheckPolicy] -> ShowS
$cshowList :: [VirtualGatewayHealthCheckPolicy] -> ShowS
show :: VirtualGatewayHealthCheckPolicy -> String
$cshow :: VirtualGatewayHealthCheckPolicy -> String
showsPrec :: Int -> VirtualGatewayHealthCheckPolicy -> ShowS
$cshowsPrec :: Int -> VirtualGatewayHealthCheckPolicy -> ShowS
Prelude.Show, (forall x.
 VirtualGatewayHealthCheckPolicy
 -> Rep VirtualGatewayHealthCheckPolicy x)
-> (forall x.
    Rep VirtualGatewayHealthCheckPolicy x
    -> VirtualGatewayHealthCheckPolicy)
-> Generic VirtualGatewayHealthCheckPolicy
forall x.
Rep VirtualGatewayHealthCheckPolicy x
-> VirtualGatewayHealthCheckPolicy
forall x.
VirtualGatewayHealthCheckPolicy
-> Rep VirtualGatewayHealthCheckPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep VirtualGatewayHealthCheckPolicy x
-> VirtualGatewayHealthCheckPolicy
$cfrom :: forall x.
VirtualGatewayHealthCheckPolicy
-> Rep VirtualGatewayHealthCheckPolicy x
Prelude.Generic)

-- |
-- Create a value of 'VirtualGatewayHealthCheckPolicy' 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:
--
-- 'path', 'virtualGatewayHealthCheckPolicy_path' - The destination path for the health check request. This value is only
-- used if the specified protocol is HTTP or HTTP\/2. For any other
-- protocol, this value is ignored.
--
-- 'port', 'virtualGatewayHealthCheckPolicy_port' - The destination port for the health check request. This port must match
-- the port defined in the PortMapping for the listener.
--
-- 'healthyThreshold', 'virtualGatewayHealthCheckPolicy_healthyThreshold' - The number of consecutive successful health checks that must occur
-- before declaring the listener healthy.
--
-- 'intervalMillis', 'virtualGatewayHealthCheckPolicy_intervalMillis' - The time period in milliseconds between each health check execution.
--
-- 'protocol', 'virtualGatewayHealthCheckPolicy_protocol' - The protocol for the health check request. If you specify @grpc@, then
-- your service must conform to the
-- <https://github.com/grpc/grpc/blob/master/doc/health-checking.md GRPC Health Checking Protocol>.
--
-- 'timeoutMillis', 'virtualGatewayHealthCheckPolicy_timeoutMillis' - The amount of time to wait when receiving a response from the health
-- check, in milliseconds.
--
-- 'unhealthyThreshold', 'virtualGatewayHealthCheckPolicy_unhealthyThreshold' - The number of consecutive failed health checks that must occur before
-- declaring a virtual gateway unhealthy.
newVirtualGatewayHealthCheckPolicy ::
  -- | 'healthyThreshold'
  Prelude.Natural ->
  -- | 'intervalMillis'
  Prelude.Natural ->
  -- | 'protocol'
  VirtualGatewayPortProtocol ->
  -- | 'timeoutMillis'
  Prelude.Natural ->
  -- | 'unhealthyThreshold'
  Prelude.Natural ->
  VirtualGatewayHealthCheckPolicy
newVirtualGatewayHealthCheckPolicy :: Natural
-> Natural
-> VirtualGatewayPortProtocol
-> Natural
-> Natural
-> VirtualGatewayHealthCheckPolicy
newVirtualGatewayHealthCheckPolicy
  Natural
pHealthyThreshold_
  Natural
pIntervalMillis_
  VirtualGatewayPortProtocol
pProtocol_
  Natural
pTimeoutMillis_
  Natural
pUnhealthyThreshold_ =
    VirtualGatewayHealthCheckPolicy' :: Maybe Text
-> Maybe Natural
-> Natural
-> Natural
-> VirtualGatewayPortProtocol
-> Natural
-> Natural
-> VirtualGatewayHealthCheckPolicy
VirtualGatewayHealthCheckPolicy'
      { $sel:path:VirtualGatewayHealthCheckPolicy' :: Maybe Text
path =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:port:VirtualGatewayHealthCheckPolicy' :: Maybe Natural
port = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:healthyThreshold:VirtualGatewayHealthCheckPolicy' :: Natural
healthyThreshold = Natural
pHealthyThreshold_,
        $sel:intervalMillis:VirtualGatewayHealthCheckPolicy' :: Natural
intervalMillis = Natural
pIntervalMillis_,
        $sel:protocol:VirtualGatewayHealthCheckPolicy' :: VirtualGatewayPortProtocol
protocol = VirtualGatewayPortProtocol
pProtocol_,
        $sel:timeoutMillis:VirtualGatewayHealthCheckPolicy' :: Natural
timeoutMillis = Natural
pTimeoutMillis_,
        $sel:unhealthyThreshold:VirtualGatewayHealthCheckPolicy' :: Natural
unhealthyThreshold = Natural
pUnhealthyThreshold_
      }

-- | The destination path for the health check request. This value is only
-- used if the specified protocol is HTTP or HTTP\/2. For any other
-- protocol, this value is ignored.
virtualGatewayHealthCheckPolicy_path :: Lens.Lens' VirtualGatewayHealthCheckPolicy (Prelude.Maybe Prelude.Text)
virtualGatewayHealthCheckPolicy_path :: (Maybe Text -> f (Maybe Text))
-> VirtualGatewayHealthCheckPolicy
-> f VirtualGatewayHealthCheckPolicy
virtualGatewayHealthCheckPolicy_path = (VirtualGatewayHealthCheckPolicy -> Maybe Text)
-> (VirtualGatewayHealthCheckPolicy
    -> Maybe Text -> VirtualGatewayHealthCheckPolicy)
-> Lens
     VirtualGatewayHealthCheckPolicy
     VirtualGatewayHealthCheckPolicy
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayHealthCheckPolicy' {Maybe Text
path :: Maybe Text
$sel:path:VirtualGatewayHealthCheckPolicy' :: VirtualGatewayHealthCheckPolicy -> Maybe Text
path} -> Maybe Text
path) (\s :: VirtualGatewayHealthCheckPolicy
s@VirtualGatewayHealthCheckPolicy' {} Maybe Text
a -> VirtualGatewayHealthCheckPolicy
s {$sel:path:VirtualGatewayHealthCheckPolicy' :: Maybe Text
path = Maybe Text
a} :: VirtualGatewayHealthCheckPolicy)

-- | The destination port for the health check request. This port must match
-- the port defined in the PortMapping for the listener.
virtualGatewayHealthCheckPolicy_port :: Lens.Lens' VirtualGatewayHealthCheckPolicy (Prelude.Maybe Prelude.Natural)
virtualGatewayHealthCheckPolicy_port :: (Maybe Natural -> f (Maybe Natural))
-> VirtualGatewayHealthCheckPolicy
-> f VirtualGatewayHealthCheckPolicy
virtualGatewayHealthCheckPolicy_port = (VirtualGatewayHealthCheckPolicy -> Maybe Natural)
-> (VirtualGatewayHealthCheckPolicy
    -> Maybe Natural -> VirtualGatewayHealthCheckPolicy)
-> Lens
     VirtualGatewayHealthCheckPolicy
     VirtualGatewayHealthCheckPolicy
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayHealthCheckPolicy' {Maybe Natural
port :: Maybe Natural
$sel:port:VirtualGatewayHealthCheckPolicy' :: VirtualGatewayHealthCheckPolicy -> Maybe Natural
port} -> Maybe Natural
port) (\s :: VirtualGatewayHealthCheckPolicy
s@VirtualGatewayHealthCheckPolicy' {} Maybe Natural
a -> VirtualGatewayHealthCheckPolicy
s {$sel:port:VirtualGatewayHealthCheckPolicy' :: Maybe Natural
port = Maybe Natural
a} :: VirtualGatewayHealthCheckPolicy)

-- | The number of consecutive successful health checks that must occur
-- before declaring the listener healthy.
virtualGatewayHealthCheckPolicy_healthyThreshold :: Lens.Lens' VirtualGatewayHealthCheckPolicy Prelude.Natural
virtualGatewayHealthCheckPolicy_healthyThreshold :: (Natural -> f Natural)
-> VirtualGatewayHealthCheckPolicy
-> f VirtualGatewayHealthCheckPolicy
virtualGatewayHealthCheckPolicy_healthyThreshold = (VirtualGatewayHealthCheckPolicy -> Natural)
-> (VirtualGatewayHealthCheckPolicy
    -> Natural -> VirtualGatewayHealthCheckPolicy)
-> Lens
     VirtualGatewayHealthCheckPolicy
     VirtualGatewayHealthCheckPolicy
     Natural
     Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayHealthCheckPolicy' {Natural
healthyThreshold :: Natural
$sel:healthyThreshold:VirtualGatewayHealthCheckPolicy' :: VirtualGatewayHealthCheckPolicy -> Natural
healthyThreshold} -> Natural
healthyThreshold) (\s :: VirtualGatewayHealthCheckPolicy
s@VirtualGatewayHealthCheckPolicy' {} Natural
a -> VirtualGatewayHealthCheckPolicy
s {$sel:healthyThreshold:VirtualGatewayHealthCheckPolicy' :: Natural
healthyThreshold = Natural
a} :: VirtualGatewayHealthCheckPolicy)

-- | The time period in milliseconds between each health check execution.
virtualGatewayHealthCheckPolicy_intervalMillis :: Lens.Lens' VirtualGatewayHealthCheckPolicy Prelude.Natural
virtualGatewayHealthCheckPolicy_intervalMillis :: (Natural -> f Natural)
-> VirtualGatewayHealthCheckPolicy
-> f VirtualGatewayHealthCheckPolicy
virtualGatewayHealthCheckPolicy_intervalMillis = (VirtualGatewayHealthCheckPolicy -> Natural)
-> (VirtualGatewayHealthCheckPolicy
    -> Natural -> VirtualGatewayHealthCheckPolicy)
-> Lens
     VirtualGatewayHealthCheckPolicy
     VirtualGatewayHealthCheckPolicy
     Natural
     Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayHealthCheckPolicy' {Natural
intervalMillis :: Natural
$sel:intervalMillis:VirtualGatewayHealthCheckPolicy' :: VirtualGatewayHealthCheckPolicy -> Natural
intervalMillis} -> Natural
intervalMillis) (\s :: VirtualGatewayHealthCheckPolicy
s@VirtualGatewayHealthCheckPolicy' {} Natural
a -> VirtualGatewayHealthCheckPolicy
s {$sel:intervalMillis:VirtualGatewayHealthCheckPolicy' :: Natural
intervalMillis = Natural
a} :: VirtualGatewayHealthCheckPolicy)

-- | The protocol for the health check request. If you specify @grpc@, then
-- your service must conform to the
-- <https://github.com/grpc/grpc/blob/master/doc/health-checking.md GRPC Health Checking Protocol>.
virtualGatewayHealthCheckPolicy_protocol :: Lens.Lens' VirtualGatewayHealthCheckPolicy VirtualGatewayPortProtocol
virtualGatewayHealthCheckPolicy_protocol :: (VirtualGatewayPortProtocol -> f VirtualGatewayPortProtocol)
-> VirtualGatewayHealthCheckPolicy
-> f VirtualGatewayHealthCheckPolicy
virtualGatewayHealthCheckPolicy_protocol = (VirtualGatewayHealthCheckPolicy -> VirtualGatewayPortProtocol)
-> (VirtualGatewayHealthCheckPolicy
    -> VirtualGatewayPortProtocol -> VirtualGatewayHealthCheckPolicy)
-> Lens
     VirtualGatewayHealthCheckPolicy
     VirtualGatewayHealthCheckPolicy
     VirtualGatewayPortProtocol
     VirtualGatewayPortProtocol
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayHealthCheckPolicy' {VirtualGatewayPortProtocol
protocol :: VirtualGatewayPortProtocol
$sel:protocol:VirtualGatewayHealthCheckPolicy' :: VirtualGatewayHealthCheckPolicy -> VirtualGatewayPortProtocol
protocol} -> VirtualGatewayPortProtocol
protocol) (\s :: VirtualGatewayHealthCheckPolicy
s@VirtualGatewayHealthCheckPolicy' {} VirtualGatewayPortProtocol
a -> VirtualGatewayHealthCheckPolicy
s {$sel:protocol:VirtualGatewayHealthCheckPolicy' :: VirtualGatewayPortProtocol
protocol = VirtualGatewayPortProtocol
a} :: VirtualGatewayHealthCheckPolicy)

-- | The amount of time to wait when receiving a response from the health
-- check, in milliseconds.
virtualGatewayHealthCheckPolicy_timeoutMillis :: Lens.Lens' VirtualGatewayHealthCheckPolicy Prelude.Natural
virtualGatewayHealthCheckPolicy_timeoutMillis :: (Natural -> f Natural)
-> VirtualGatewayHealthCheckPolicy
-> f VirtualGatewayHealthCheckPolicy
virtualGatewayHealthCheckPolicy_timeoutMillis = (VirtualGatewayHealthCheckPolicy -> Natural)
-> (VirtualGatewayHealthCheckPolicy
    -> Natural -> VirtualGatewayHealthCheckPolicy)
-> Lens
     VirtualGatewayHealthCheckPolicy
     VirtualGatewayHealthCheckPolicy
     Natural
     Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayHealthCheckPolicy' {Natural
timeoutMillis :: Natural
$sel:timeoutMillis:VirtualGatewayHealthCheckPolicy' :: VirtualGatewayHealthCheckPolicy -> Natural
timeoutMillis} -> Natural
timeoutMillis) (\s :: VirtualGatewayHealthCheckPolicy
s@VirtualGatewayHealthCheckPolicy' {} Natural
a -> VirtualGatewayHealthCheckPolicy
s {$sel:timeoutMillis:VirtualGatewayHealthCheckPolicy' :: Natural
timeoutMillis = Natural
a} :: VirtualGatewayHealthCheckPolicy)

-- | The number of consecutive failed health checks that must occur before
-- declaring a virtual gateway unhealthy.
virtualGatewayHealthCheckPolicy_unhealthyThreshold :: Lens.Lens' VirtualGatewayHealthCheckPolicy Prelude.Natural
virtualGatewayHealthCheckPolicy_unhealthyThreshold :: (Natural -> f Natural)
-> VirtualGatewayHealthCheckPolicy
-> f VirtualGatewayHealthCheckPolicy
virtualGatewayHealthCheckPolicy_unhealthyThreshold = (VirtualGatewayHealthCheckPolicy -> Natural)
-> (VirtualGatewayHealthCheckPolicy
    -> Natural -> VirtualGatewayHealthCheckPolicy)
-> Lens
     VirtualGatewayHealthCheckPolicy
     VirtualGatewayHealthCheckPolicy
     Natural
     Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayHealthCheckPolicy' {Natural
unhealthyThreshold :: Natural
$sel:unhealthyThreshold:VirtualGatewayHealthCheckPolicy' :: VirtualGatewayHealthCheckPolicy -> Natural
unhealthyThreshold} -> Natural
unhealthyThreshold) (\s :: VirtualGatewayHealthCheckPolicy
s@VirtualGatewayHealthCheckPolicy' {} Natural
a -> VirtualGatewayHealthCheckPolicy
s {$sel:unhealthyThreshold:VirtualGatewayHealthCheckPolicy' :: Natural
unhealthyThreshold = Natural
a} :: VirtualGatewayHealthCheckPolicy)

instance
  Core.FromJSON
    VirtualGatewayHealthCheckPolicy
  where
  parseJSON :: Value -> Parser VirtualGatewayHealthCheckPolicy
parseJSON =
    String
-> (Object -> Parser VirtualGatewayHealthCheckPolicy)
-> Value
-> Parser VirtualGatewayHealthCheckPolicy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VirtualGatewayHealthCheckPolicy"
      ( \Object
x ->
          Maybe Text
-> Maybe Natural
-> Natural
-> Natural
-> VirtualGatewayPortProtocol
-> Natural
-> Natural
-> VirtualGatewayHealthCheckPolicy
VirtualGatewayHealthCheckPolicy'
            (Maybe Text
 -> Maybe Natural
 -> Natural
 -> Natural
 -> VirtualGatewayPortProtocol
 -> Natural
 -> Natural
 -> VirtualGatewayHealthCheckPolicy)
-> Parser (Maybe Text)
-> Parser
     (Maybe Natural
      -> Natural
      -> Natural
      -> VirtualGatewayPortProtocol
      -> Natural
      -> Natural
      -> VirtualGatewayHealthCheckPolicy)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"path")
            Parser
  (Maybe Natural
   -> Natural
   -> Natural
   -> VirtualGatewayPortProtocol
   -> Natural
   -> Natural
   -> VirtualGatewayHealthCheckPolicy)
-> Parser (Maybe Natural)
-> Parser
     (Natural
      -> Natural
      -> VirtualGatewayPortProtocol
      -> Natural
      -> Natural
      -> VirtualGatewayHealthCheckPolicy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"port")
            Parser
  (Natural
   -> Natural
   -> VirtualGatewayPortProtocol
   -> Natural
   -> Natural
   -> VirtualGatewayHealthCheckPolicy)
-> Parser Natural
-> Parser
     (Natural
      -> VirtualGatewayPortProtocol
      -> Natural
      -> Natural
      -> VirtualGatewayHealthCheckPolicy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"healthyThreshold")
            Parser
  (Natural
   -> VirtualGatewayPortProtocol
   -> Natural
   -> Natural
   -> VirtualGatewayHealthCheckPolicy)
-> Parser Natural
-> Parser
     (VirtualGatewayPortProtocol
      -> Natural -> Natural -> VirtualGatewayHealthCheckPolicy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"intervalMillis")
            Parser
  (VirtualGatewayPortProtocol
   -> Natural -> Natural -> VirtualGatewayHealthCheckPolicy)
-> Parser VirtualGatewayPortProtocol
-> Parser (Natural -> Natural -> VirtualGatewayHealthCheckPolicy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser VirtualGatewayPortProtocol
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"protocol")
            Parser (Natural -> Natural -> VirtualGatewayHealthCheckPolicy)
-> Parser Natural
-> Parser (Natural -> VirtualGatewayHealthCheckPolicy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"timeoutMillis")
            Parser (Natural -> VirtualGatewayHealthCheckPolicy)
-> Parser Natural -> Parser VirtualGatewayHealthCheckPolicy
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"unhealthyThreshold")
      )

instance
  Prelude.Hashable
    VirtualGatewayHealthCheckPolicy

instance
  Prelude.NFData
    VirtualGatewayHealthCheckPolicy

instance Core.ToJSON VirtualGatewayHealthCheckPolicy where
  toJSON :: VirtualGatewayHealthCheckPolicy -> Value
toJSON VirtualGatewayHealthCheckPolicy' {Natural
Maybe Natural
Maybe Text
VirtualGatewayPortProtocol
unhealthyThreshold :: Natural
timeoutMillis :: Natural
protocol :: VirtualGatewayPortProtocol
intervalMillis :: Natural
healthyThreshold :: Natural
port :: Maybe Natural
path :: Maybe Text
$sel:unhealthyThreshold:VirtualGatewayHealthCheckPolicy' :: VirtualGatewayHealthCheckPolicy -> Natural
$sel:timeoutMillis:VirtualGatewayHealthCheckPolicy' :: VirtualGatewayHealthCheckPolicy -> Natural
$sel:protocol:VirtualGatewayHealthCheckPolicy' :: VirtualGatewayHealthCheckPolicy -> VirtualGatewayPortProtocol
$sel:intervalMillis:VirtualGatewayHealthCheckPolicy' :: VirtualGatewayHealthCheckPolicy -> Natural
$sel:healthyThreshold:VirtualGatewayHealthCheckPolicy' :: VirtualGatewayHealthCheckPolicy -> Natural
$sel:port:VirtualGatewayHealthCheckPolicy' :: VirtualGatewayHealthCheckPolicy -> Maybe Natural
$sel:path:VirtualGatewayHealthCheckPolicy' :: VirtualGatewayHealthCheckPolicy -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"path" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
path,
            (Text
"port" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
port,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"healthyThreshold" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
healthyThreshold),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"intervalMillis" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
intervalMillis),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"protocol" Text -> VirtualGatewayPortProtocol -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= VirtualGatewayPortProtocol
protocol),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"timeoutMillis" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
timeoutMillis),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"unhealthyThreshold" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
unhealthyThreshold)
          ]
      )