{-# 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.SecurityHub.Types.AwsElbLoadBalancerConnectionDraining
-- 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.SecurityHub.Types.AwsElbLoadBalancerConnectionDraining where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the connection draining configuration for the
-- load balancer.
--
-- /See:/ 'newAwsElbLoadBalancerConnectionDraining' smart constructor.
data AwsElbLoadBalancerConnectionDraining = AwsElbLoadBalancerConnectionDraining'
  { -- | Indicates whether connection draining is enabled for the load balancer.
    AwsElbLoadBalancerConnectionDraining -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | The maximum time, in seconds, to keep the existing connections open
    -- before deregistering the instances.
    AwsElbLoadBalancerConnectionDraining -> Maybe Int
timeout :: Prelude.Maybe Prelude.Int
  }
  deriving (AwsElbLoadBalancerConnectionDraining
-> AwsElbLoadBalancerConnectionDraining -> Bool
(AwsElbLoadBalancerConnectionDraining
 -> AwsElbLoadBalancerConnectionDraining -> Bool)
-> (AwsElbLoadBalancerConnectionDraining
    -> AwsElbLoadBalancerConnectionDraining -> Bool)
-> Eq AwsElbLoadBalancerConnectionDraining
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsElbLoadBalancerConnectionDraining
-> AwsElbLoadBalancerConnectionDraining -> Bool
$c/= :: AwsElbLoadBalancerConnectionDraining
-> AwsElbLoadBalancerConnectionDraining -> Bool
== :: AwsElbLoadBalancerConnectionDraining
-> AwsElbLoadBalancerConnectionDraining -> Bool
$c== :: AwsElbLoadBalancerConnectionDraining
-> AwsElbLoadBalancerConnectionDraining -> Bool
Prelude.Eq, ReadPrec [AwsElbLoadBalancerConnectionDraining]
ReadPrec AwsElbLoadBalancerConnectionDraining
Int -> ReadS AwsElbLoadBalancerConnectionDraining
ReadS [AwsElbLoadBalancerConnectionDraining]
(Int -> ReadS AwsElbLoadBalancerConnectionDraining)
-> ReadS [AwsElbLoadBalancerConnectionDraining]
-> ReadPrec AwsElbLoadBalancerConnectionDraining
-> ReadPrec [AwsElbLoadBalancerConnectionDraining]
-> Read AwsElbLoadBalancerConnectionDraining
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsElbLoadBalancerConnectionDraining]
$creadListPrec :: ReadPrec [AwsElbLoadBalancerConnectionDraining]
readPrec :: ReadPrec AwsElbLoadBalancerConnectionDraining
$creadPrec :: ReadPrec AwsElbLoadBalancerConnectionDraining
readList :: ReadS [AwsElbLoadBalancerConnectionDraining]
$creadList :: ReadS [AwsElbLoadBalancerConnectionDraining]
readsPrec :: Int -> ReadS AwsElbLoadBalancerConnectionDraining
$creadsPrec :: Int -> ReadS AwsElbLoadBalancerConnectionDraining
Prelude.Read, Int -> AwsElbLoadBalancerConnectionDraining -> ShowS
[AwsElbLoadBalancerConnectionDraining] -> ShowS
AwsElbLoadBalancerConnectionDraining -> String
(Int -> AwsElbLoadBalancerConnectionDraining -> ShowS)
-> (AwsElbLoadBalancerConnectionDraining -> String)
-> ([AwsElbLoadBalancerConnectionDraining] -> ShowS)
-> Show AwsElbLoadBalancerConnectionDraining
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsElbLoadBalancerConnectionDraining] -> ShowS
$cshowList :: [AwsElbLoadBalancerConnectionDraining] -> ShowS
show :: AwsElbLoadBalancerConnectionDraining -> String
$cshow :: AwsElbLoadBalancerConnectionDraining -> String
showsPrec :: Int -> AwsElbLoadBalancerConnectionDraining -> ShowS
$cshowsPrec :: Int -> AwsElbLoadBalancerConnectionDraining -> ShowS
Prelude.Show, (forall x.
 AwsElbLoadBalancerConnectionDraining
 -> Rep AwsElbLoadBalancerConnectionDraining x)
-> (forall x.
    Rep AwsElbLoadBalancerConnectionDraining x
    -> AwsElbLoadBalancerConnectionDraining)
-> Generic AwsElbLoadBalancerConnectionDraining
forall x.
Rep AwsElbLoadBalancerConnectionDraining x
-> AwsElbLoadBalancerConnectionDraining
forall x.
AwsElbLoadBalancerConnectionDraining
-> Rep AwsElbLoadBalancerConnectionDraining x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsElbLoadBalancerConnectionDraining x
-> AwsElbLoadBalancerConnectionDraining
$cfrom :: forall x.
AwsElbLoadBalancerConnectionDraining
-> Rep AwsElbLoadBalancerConnectionDraining x
Prelude.Generic)

-- |
-- Create a value of 'AwsElbLoadBalancerConnectionDraining' 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:
--
-- 'enabled', 'awsElbLoadBalancerConnectionDraining_enabled' - Indicates whether connection draining is enabled for the load balancer.
--
-- 'timeout', 'awsElbLoadBalancerConnectionDraining_timeout' - The maximum time, in seconds, to keep the existing connections open
-- before deregistering the instances.
newAwsElbLoadBalancerConnectionDraining ::
  AwsElbLoadBalancerConnectionDraining
newAwsElbLoadBalancerConnectionDraining :: AwsElbLoadBalancerConnectionDraining
newAwsElbLoadBalancerConnectionDraining =
  AwsElbLoadBalancerConnectionDraining' :: Maybe Bool -> Maybe Int -> AwsElbLoadBalancerConnectionDraining
AwsElbLoadBalancerConnectionDraining'
    { $sel:enabled:AwsElbLoadBalancerConnectionDraining' :: Maybe Bool
enabled =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:timeout:AwsElbLoadBalancerConnectionDraining' :: Maybe Int
timeout = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates whether connection draining is enabled for the load balancer.
awsElbLoadBalancerConnectionDraining_enabled :: Lens.Lens' AwsElbLoadBalancerConnectionDraining (Prelude.Maybe Prelude.Bool)
awsElbLoadBalancerConnectionDraining_enabled :: (Maybe Bool -> f (Maybe Bool))
-> AwsElbLoadBalancerConnectionDraining
-> f AwsElbLoadBalancerConnectionDraining
awsElbLoadBalancerConnectionDraining_enabled = (AwsElbLoadBalancerConnectionDraining -> Maybe Bool)
-> (AwsElbLoadBalancerConnectionDraining
    -> Maybe Bool -> AwsElbLoadBalancerConnectionDraining)
-> Lens
     AwsElbLoadBalancerConnectionDraining
     AwsElbLoadBalancerConnectionDraining
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsElbLoadBalancerConnectionDraining' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:AwsElbLoadBalancerConnectionDraining' :: AwsElbLoadBalancerConnectionDraining -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: AwsElbLoadBalancerConnectionDraining
s@AwsElbLoadBalancerConnectionDraining' {} Maybe Bool
a -> AwsElbLoadBalancerConnectionDraining
s {$sel:enabled:AwsElbLoadBalancerConnectionDraining' :: Maybe Bool
enabled = Maybe Bool
a} :: AwsElbLoadBalancerConnectionDraining)

-- | The maximum time, in seconds, to keep the existing connections open
-- before deregistering the instances.
awsElbLoadBalancerConnectionDraining_timeout :: Lens.Lens' AwsElbLoadBalancerConnectionDraining (Prelude.Maybe Prelude.Int)
awsElbLoadBalancerConnectionDraining_timeout :: (Maybe Int -> f (Maybe Int))
-> AwsElbLoadBalancerConnectionDraining
-> f AwsElbLoadBalancerConnectionDraining
awsElbLoadBalancerConnectionDraining_timeout = (AwsElbLoadBalancerConnectionDraining -> Maybe Int)
-> (AwsElbLoadBalancerConnectionDraining
    -> Maybe Int -> AwsElbLoadBalancerConnectionDraining)
-> Lens
     AwsElbLoadBalancerConnectionDraining
     AwsElbLoadBalancerConnectionDraining
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsElbLoadBalancerConnectionDraining' {Maybe Int
timeout :: Maybe Int
$sel:timeout:AwsElbLoadBalancerConnectionDraining' :: AwsElbLoadBalancerConnectionDraining -> Maybe Int
timeout} -> Maybe Int
timeout) (\s :: AwsElbLoadBalancerConnectionDraining
s@AwsElbLoadBalancerConnectionDraining' {} Maybe Int
a -> AwsElbLoadBalancerConnectionDraining
s {$sel:timeout:AwsElbLoadBalancerConnectionDraining' :: Maybe Int
timeout = Maybe Int
a} :: AwsElbLoadBalancerConnectionDraining)

instance
  Core.FromJSON
    AwsElbLoadBalancerConnectionDraining
  where
  parseJSON :: Value -> Parser AwsElbLoadBalancerConnectionDraining
parseJSON =
    String
-> (Object -> Parser AwsElbLoadBalancerConnectionDraining)
-> Value
-> Parser AwsElbLoadBalancerConnectionDraining
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsElbLoadBalancerConnectionDraining"
      ( \Object
x ->
          Maybe Bool -> Maybe Int -> AwsElbLoadBalancerConnectionDraining
AwsElbLoadBalancerConnectionDraining'
            (Maybe Bool -> Maybe Int -> AwsElbLoadBalancerConnectionDraining)
-> Parser (Maybe Bool)
-> Parser (Maybe Int -> AwsElbLoadBalancerConnectionDraining)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Enabled")
            Parser (Maybe Int -> AwsElbLoadBalancerConnectionDraining)
-> Parser (Maybe Int)
-> Parser AwsElbLoadBalancerConnectionDraining
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Timeout")
      )

instance
  Prelude.Hashable
    AwsElbLoadBalancerConnectionDraining

instance
  Prelude.NFData
    AwsElbLoadBalancerConnectionDraining

instance
  Core.ToJSON
    AwsElbLoadBalancerConnectionDraining
  where
  toJSON :: AwsElbLoadBalancerConnectionDraining -> Value
toJSON AwsElbLoadBalancerConnectionDraining' {Maybe Bool
Maybe Int
timeout :: Maybe Int
enabled :: Maybe Bool
$sel:timeout:AwsElbLoadBalancerConnectionDraining' :: AwsElbLoadBalancerConnectionDraining -> Maybe Int
$sel:enabled:AwsElbLoadBalancerConnectionDraining' :: AwsElbLoadBalancerConnectionDraining -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Enabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enabled,
            (Text
"Timeout" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
timeout
          ]
      )