{-# 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.VirtualNodeTcpConnectionPool
-- 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.VirtualNodeTcpConnectionPool where

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

-- | An object that represents a type of connection pool.
--
-- /See:/ 'newVirtualNodeTcpConnectionPool' smart constructor.
data VirtualNodeTcpConnectionPool = VirtualNodeTcpConnectionPool'
  { -- | Maximum number of outbound TCP connections Envoy can establish
    -- concurrently with all hosts in upstream cluster.
    VirtualNodeTcpConnectionPool -> Natural
maxConnections :: Prelude.Natural
  }
  deriving (VirtualNodeTcpConnectionPool
-> VirtualNodeTcpConnectionPool -> Bool
(VirtualNodeTcpConnectionPool
 -> VirtualNodeTcpConnectionPool -> Bool)
-> (VirtualNodeTcpConnectionPool
    -> VirtualNodeTcpConnectionPool -> Bool)
-> Eq VirtualNodeTcpConnectionPool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualNodeTcpConnectionPool
-> VirtualNodeTcpConnectionPool -> Bool
$c/= :: VirtualNodeTcpConnectionPool
-> VirtualNodeTcpConnectionPool -> Bool
== :: VirtualNodeTcpConnectionPool
-> VirtualNodeTcpConnectionPool -> Bool
$c== :: VirtualNodeTcpConnectionPool
-> VirtualNodeTcpConnectionPool -> Bool
Prelude.Eq, ReadPrec [VirtualNodeTcpConnectionPool]
ReadPrec VirtualNodeTcpConnectionPool
Int -> ReadS VirtualNodeTcpConnectionPool
ReadS [VirtualNodeTcpConnectionPool]
(Int -> ReadS VirtualNodeTcpConnectionPool)
-> ReadS [VirtualNodeTcpConnectionPool]
-> ReadPrec VirtualNodeTcpConnectionPool
-> ReadPrec [VirtualNodeTcpConnectionPool]
-> Read VirtualNodeTcpConnectionPool
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VirtualNodeTcpConnectionPool]
$creadListPrec :: ReadPrec [VirtualNodeTcpConnectionPool]
readPrec :: ReadPrec VirtualNodeTcpConnectionPool
$creadPrec :: ReadPrec VirtualNodeTcpConnectionPool
readList :: ReadS [VirtualNodeTcpConnectionPool]
$creadList :: ReadS [VirtualNodeTcpConnectionPool]
readsPrec :: Int -> ReadS VirtualNodeTcpConnectionPool
$creadsPrec :: Int -> ReadS VirtualNodeTcpConnectionPool
Prelude.Read, Int -> VirtualNodeTcpConnectionPool -> ShowS
[VirtualNodeTcpConnectionPool] -> ShowS
VirtualNodeTcpConnectionPool -> String
(Int -> VirtualNodeTcpConnectionPool -> ShowS)
-> (VirtualNodeTcpConnectionPool -> String)
-> ([VirtualNodeTcpConnectionPool] -> ShowS)
-> Show VirtualNodeTcpConnectionPool
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VirtualNodeTcpConnectionPool] -> ShowS
$cshowList :: [VirtualNodeTcpConnectionPool] -> ShowS
show :: VirtualNodeTcpConnectionPool -> String
$cshow :: VirtualNodeTcpConnectionPool -> String
showsPrec :: Int -> VirtualNodeTcpConnectionPool -> ShowS
$cshowsPrec :: Int -> VirtualNodeTcpConnectionPool -> ShowS
Prelude.Show, (forall x.
 VirtualNodeTcpConnectionPool -> Rep VirtualNodeTcpConnectionPool x)
-> (forall x.
    Rep VirtualNodeTcpConnectionPool x -> VirtualNodeTcpConnectionPool)
-> Generic VirtualNodeTcpConnectionPool
forall x.
Rep VirtualNodeTcpConnectionPool x -> VirtualNodeTcpConnectionPool
forall x.
VirtualNodeTcpConnectionPool -> Rep VirtualNodeTcpConnectionPool x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep VirtualNodeTcpConnectionPool x -> VirtualNodeTcpConnectionPool
$cfrom :: forall x.
VirtualNodeTcpConnectionPool -> Rep VirtualNodeTcpConnectionPool x
Prelude.Generic)

-- |
-- Create a value of 'VirtualNodeTcpConnectionPool' 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:
--
-- 'maxConnections', 'virtualNodeTcpConnectionPool_maxConnections' - Maximum number of outbound TCP connections Envoy can establish
-- concurrently with all hosts in upstream cluster.
newVirtualNodeTcpConnectionPool ::
  -- | 'maxConnections'
  Prelude.Natural ->
  VirtualNodeTcpConnectionPool
newVirtualNodeTcpConnectionPool :: Natural -> VirtualNodeTcpConnectionPool
newVirtualNodeTcpConnectionPool Natural
pMaxConnections_ =
  VirtualNodeTcpConnectionPool' :: Natural -> VirtualNodeTcpConnectionPool
VirtualNodeTcpConnectionPool'
    { $sel:maxConnections:VirtualNodeTcpConnectionPool' :: Natural
maxConnections =
        Natural
pMaxConnections_
    }

-- | Maximum number of outbound TCP connections Envoy can establish
-- concurrently with all hosts in upstream cluster.
virtualNodeTcpConnectionPool_maxConnections :: Lens.Lens' VirtualNodeTcpConnectionPool Prelude.Natural
virtualNodeTcpConnectionPool_maxConnections :: (Natural -> f Natural)
-> VirtualNodeTcpConnectionPool -> f VirtualNodeTcpConnectionPool
virtualNodeTcpConnectionPool_maxConnections = (VirtualNodeTcpConnectionPool -> Natural)
-> (VirtualNodeTcpConnectionPool
    -> Natural -> VirtualNodeTcpConnectionPool)
-> Lens
     VirtualNodeTcpConnectionPool
     VirtualNodeTcpConnectionPool
     Natural
     Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualNodeTcpConnectionPool' {Natural
maxConnections :: Natural
$sel:maxConnections:VirtualNodeTcpConnectionPool' :: VirtualNodeTcpConnectionPool -> Natural
maxConnections} -> Natural
maxConnections) (\s :: VirtualNodeTcpConnectionPool
s@VirtualNodeTcpConnectionPool' {} Natural
a -> VirtualNodeTcpConnectionPool
s {$sel:maxConnections:VirtualNodeTcpConnectionPool' :: Natural
maxConnections = Natural
a} :: VirtualNodeTcpConnectionPool)

instance Core.FromJSON VirtualNodeTcpConnectionPool where
  parseJSON :: Value -> Parser VirtualNodeTcpConnectionPool
parseJSON =
    String
-> (Object -> Parser VirtualNodeTcpConnectionPool)
-> Value
-> Parser VirtualNodeTcpConnectionPool
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VirtualNodeTcpConnectionPool"
      ( \Object
x ->
          Natural -> VirtualNodeTcpConnectionPool
VirtualNodeTcpConnectionPool'
            (Natural -> VirtualNodeTcpConnectionPool)
-> Parser Natural -> Parser VirtualNodeTcpConnectionPool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"maxConnections")
      )

instance
  Prelude.Hashable
    VirtualNodeTcpConnectionPool

instance Prelude.NFData VirtualNodeTcpConnectionPool

instance Core.ToJSON VirtualNodeTcpConnectionPool where
  toJSON :: VirtualNodeTcpConnectionPool -> Value
toJSON VirtualNodeTcpConnectionPool' {Natural
maxConnections :: Natural
$sel:maxConnections:VirtualNodeTcpConnectionPool' :: VirtualNodeTcpConnectionPool -> Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"maxConnections" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
maxConnections)
          ]
      )