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

import Amazonka.AppMesh.Types.VirtualNodeGrpcConnectionPool
import Amazonka.AppMesh.Types.VirtualNodeHttp2ConnectionPool
import Amazonka.AppMesh.Types.VirtualNodeHttpConnectionPool
import Amazonka.AppMesh.Types.VirtualNodeTcpConnectionPool
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that represents the type of virtual node connection pool.
--
-- Only one protocol is used at a time and should be the same protocol as
-- the one chosen under port mapping.
--
-- If not present the default value for @maxPendingRequests@ is
-- @2147483647@.
--
-- /See:/ 'newVirtualNodeConnectionPool' smart constructor.
data VirtualNodeConnectionPool = VirtualNodeConnectionPool'
  { -- | An object that represents a type of connection pool.
    VirtualNodeConnectionPool -> Maybe VirtualNodeHttp2ConnectionPool
http2 :: Prelude.Maybe VirtualNodeHttp2ConnectionPool,
    -- | An object that represents a type of connection pool.
    VirtualNodeConnectionPool -> Maybe VirtualNodeGrpcConnectionPool
grpc :: Prelude.Maybe VirtualNodeGrpcConnectionPool,
    -- | An object that represents a type of connection pool.
    VirtualNodeConnectionPool -> Maybe VirtualNodeTcpConnectionPool
tcp :: Prelude.Maybe VirtualNodeTcpConnectionPool,
    -- | An object that represents a type of connection pool.
    VirtualNodeConnectionPool -> Maybe VirtualNodeHttpConnectionPool
http :: Prelude.Maybe VirtualNodeHttpConnectionPool
  }
  deriving (VirtualNodeConnectionPool -> VirtualNodeConnectionPool -> Bool
(VirtualNodeConnectionPool -> VirtualNodeConnectionPool -> Bool)
-> (VirtualNodeConnectionPool -> VirtualNodeConnectionPool -> Bool)
-> Eq VirtualNodeConnectionPool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualNodeConnectionPool -> VirtualNodeConnectionPool -> Bool
$c/= :: VirtualNodeConnectionPool -> VirtualNodeConnectionPool -> Bool
== :: VirtualNodeConnectionPool -> VirtualNodeConnectionPool -> Bool
$c== :: VirtualNodeConnectionPool -> VirtualNodeConnectionPool -> Bool
Prelude.Eq, ReadPrec [VirtualNodeConnectionPool]
ReadPrec VirtualNodeConnectionPool
Int -> ReadS VirtualNodeConnectionPool
ReadS [VirtualNodeConnectionPool]
(Int -> ReadS VirtualNodeConnectionPool)
-> ReadS [VirtualNodeConnectionPool]
-> ReadPrec VirtualNodeConnectionPool
-> ReadPrec [VirtualNodeConnectionPool]
-> Read VirtualNodeConnectionPool
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VirtualNodeConnectionPool]
$creadListPrec :: ReadPrec [VirtualNodeConnectionPool]
readPrec :: ReadPrec VirtualNodeConnectionPool
$creadPrec :: ReadPrec VirtualNodeConnectionPool
readList :: ReadS [VirtualNodeConnectionPool]
$creadList :: ReadS [VirtualNodeConnectionPool]
readsPrec :: Int -> ReadS VirtualNodeConnectionPool
$creadsPrec :: Int -> ReadS VirtualNodeConnectionPool
Prelude.Read, Int -> VirtualNodeConnectionPool -> ShowS
[VirtualNodeConnectionPool] -> ShowS
VirtualNodeConnectionPool -> String
(Int -> VirtualNodeConnectionPool -> ShowS)
-> (VirtualNodeConnectionPool -> String)
-> ([VirtualNodeConnectionPool] -> ShowS)
-> Show VirtualNodeConnectionPool
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VirtualNodeConnectionPool] -> ShowS
$cshowList :: [VirtualNodeConnectionPool] -> ShowS
show :: VirtualNodeConnectionPool -> String
$cshow :: VirtualNodeConnectionPool -> String
showsPrec :: Int -> VirtualNodeConnectionPool -> ShowS
$cshowsPrec :: Int -> VirtualNodeConnectionPool -> ShowS
Prelude.Show, (forall x.
 VirtualNodeConnectionPool -> Rep VirtualNodeConnectionPool x)
-> (forall x.
    Rep VirtualNodeConnectionPool x -> VirtualNodeConnectionPool)
-> Generic VirtualNodeConnectionPool
forall x.
Rep VirtualNodeConnectionPool x -> VirtualNodeConnectionPool
forall x.
VirtualNodeConnectionPool -> Rep VirtualNodeConnectionPool x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep VirtualNodeConnectionPool x -> VirtualNodeConnectionPool
$cfrom :: forall x.
VirtualNodeConnectionPool -> Rep VirtualNodeConnectionPool x
Prelude.Generic)

-- |
-- Create a value of 'VirtualNodeConnectionPool' 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:
--
-- 'http2', 'virtualNodeConnectionPool_http2' - An object that represents a type of connection pool.
--
-- 'grpc', 'virtualNodeConnectionPool_grpc' - An object that represents a type of connection pool.
--
-- 'tcp', 'virtualNodeConnectionPool_tcp' - An object that represents a type of connection pool.
--
-- 'http', 'virtualNodeConnectionPool_http' - An object that represents a type of connection pool.
newVirtualNodeConnectionPool ::
  VirtualNodeConnectionPool
newVirtualNodeConnectionPool :: VirtualNodeConnectionPool
newVirtualNodeConnectionPool =
  VirtualNodeConnectionPool' :: Maybe VirtualNodeHttp2ConnectionPool
-> Maybe VirtualNodeGrpcConnectionPool
-> Maybe VirtualNodeTcpConnectionPool
-> Maybe VirtualNodeHttpConnectionPool
-> VirtualNodeConnectionPool
VirtualNodeConnectionPool'
    { $sel:http2:VirtualNodeConnectionPool' :: Maybe VirtualNodeHttp2ConnectionPool
http2 = Maybe VirtualNodeHttp2ConnectionPool
forall a. Maybe a
Prelude.Nothing,
      $sel:grpc:VirtualNodeConnectionPool' :: Maybe VirtualNodeGrpcConnectionPool
grpc = Maybe VirtualNodeGrpcConnectionPool
forall a. Maybe a
Prelude.Nothing,
      $sel:tcp:VirtualNodeConnectionPool' :: Maybe VirtualNodeTcpConnectionPool
tcp = Maybe VirtualNodeTcpConnectionPool
forall a. Maybe a
Prelude.Nothing,
      $sel:http:VirtualNodeConnectionPool' :: Maybe VirtualNodeHttpConnectionPool
http = Maybe VirtualNodeHttpConnectionPool
forall a. Maybe a
Prelude.Nothing
    }

-- | An object that represents a type of connection pool.
virtualNodeConnectionPool_http2 :: Lens.Lens' VirtualNodeConnectionPool (Prelude.Maybe VirtualNodeHttp2ConnectionPool)
virtualNodeConnectionPool_http2 :: (Maybe VirtualNodeHttp2ConnectionPool
 -> f (Maybe VirtualNodeHttp2ConnectionPool))
-> VirtualNodeConnectionPool -> f VirtualNodeConnectionPool
virtualNodeConnectionPool_http2 = (VirtualNodeConnectionPool -> Maybe VirtualNodeHttp2ConnectionPool)
-> (VirtualNodeConnectionPool
    -> Maybe VirtualNodeHttp2ConnectionPool
    -> VirtualNodeConnectionPool)
-> Lens
     VirtualNodeConnectionPool
     VirtualNodeConnectionPool
     (Maybe VirtualNodeHttp2ConnectionPool)
     (Maybe VirtualNodeHttp2ConnectionPool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualNodeConnectionPool' {Maybe VirtualNodeHttp2ConnectionPool
http2 :: Maybe VirtualNodeHttp2ConnectionPool
$sel:http2:VirtualNodeConnectionPool' :: VirtualNodeConnectionPool -> Maybe VirtualNodeHttp2ConnectionPool
http2} -> Maybe VirtualNodeHttp2ConnectionPool
http2) (\s :: VirtualNodeConnectionPool
s@VirtualNodeConnectionPool' {} Maybe VirtualNodeHttp2ConnectionPool
a -> VirtualNodeConnectionPool
s {$sel:http2:VirtualNodeConnectionPool' :: Maybe VirtualNodeHttp2ConnectionPool
http2 = Maybe VirtualNodeHttp2ConnectionPool
a} :: VirtualNodeConnectionPool)

-- | An object that represents a type of connection pool.
virtualNodeConnectionPool_grpc :: Lens.Lens' VirtualNodeConnectionPool (Prelude.Maybe VirtualNodeGrpcConnectionPool)
virtualNodeConnectionPool_grpc :: (Maybe VirtualNodeGrpcConnectionPool
 -> f (Maybe VirtualNodeGrpcConnectionPool))
-> VirtualNodeConnectionPool -> f VirtualNodeConnectionPool
virtualNodeConnectionPool_grpc = (VirtualNodeConnectionPool -> Maybe VirtualNodeGrpcConnectionPool)
-> (VirtualNodeConnectionPool
    -> Maybe VirtualNodeGrpcConnectionPool
    -> VirtualNodeConnectionPool)
-> Lens
     VirtualNodeConnectionPool
     VirtualNodeConnectionPool
     (Maybe VirtualNodeGrpcConnectionPool)
     (Maybe VirtualNodeGrpcConnectionPool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualNodeConnectionPool' {Maybe VirtualNodeGrpcConnectionPool
grpc :: Maybe VirtualNodeGrpcConnectionPool
$sel:grpc:VirtualNodeConnectionPool' :: VirtualNodeConnectionPool -> Maybe VirtualNodeGrpcConnectionPool
grpc} -> Maybe VirtualNodeGrpcConnectionPool
grpc) (\s :: VirtualNodeConnectionPool
s@VirtualNodeConnectionPool' {} Maybe VirtualNodeGrpcConnectionPool
a -> VirtualNodeConnectionPool
s {$sel:grpc:VirtualNodeConnectionPool' :: Maybe VirtualNodeGrpcConnectionPool
grpc = Maybe VirtualNodeGrpcConnectionPool
a} :: VirtualNodeConnectionPool)

-- | An object that represents a type of connection pool.
virtualNodeConnectionPool_tcp :: Lens.Lens' VirtualNodeConnectionPool (Prelude.Maybe VirtualNodeTcpConnectionPool)
virtualNodeConnectionPool_tcp :: (Maybe VirtualNodeTcpConnectionPool
 -> f (Maybe VirtualNodeTcpConnectionPool))
-> VirtualNodeConnectionPool -> f VirtualNodeConnectionPool
virtualNodeConnectionPool_tcp = (VirtualNodeConnectionPool -> Maybe VirtualNodeTcpConnectionPool)
-> (VirtualNodeConnectionPool
    -> Maybe VirtualNodeTcpConnectionPool -> VirtualNodeConnectionPool)
-> Lens
     VirtualNodeConnectionPool
     VirtualNodeConnectionPool
     (Maybe VirtualNodeTcpConnectionPool)
     (Maybe VirtualNodeTcpConnectionPool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualNodeConnectionPool' {Maybe VirtualNodeTcpConnectionPool
tcp :: Maybe VirtualNodeTcpConnectionPool
$sel:tcp:VirtualNodeConnectionPool' :: VirtualNodeConnectionPool -> Maybe VirtualNodeTcpConnectionPool
tcp} -> Maybe VirtualNodeTcpConnectionPool
tcp) (\s :: VirtualNodeConnectionPool
s@VirtualNodeConnectionPool' {} Maybe VirtualNodeTcpConnectionPool
a -> VirtualNodeConnectionPool
s {$sel:tcp:VirtualNodeConnectionPool' :: Maybe VirtualNodeTcpConnectionPool
tcp = Maybe VirtualNodeTcpConnectionPool
a} :: VirtualNodeConnectionPool)

-- | An object that represents a type of connection pool.
virtualNodeConnectionPool_http :: Lens.Lens' VirtualNodeConnectionPool (Prelude.Maybe VirtualNodeHttpConnectionPool)
virtualNodeConnectionPool_http :: (Maybe VirtualNodeHttpConnectionPool
 -> f (Maybe VirtualNodeHttpConnectionPool))
-> VirtualNodeConnectionPool -> f VirtualNodeConnectionPool
virtualNodeConnectionPool_http = (VirtualNodeConnectionPool -> Maybe VirtualNodeHttpConnectionPool)
-> (VirtualNodeConnectionPool
    -> Maybe VirtualNodeHttpConnectionPool
    -> VirtualNodeConnectionPool)
-> Lens
     VirtualNodeConnectionPool
     VirtualNodeConnectionPool
     (Maybe VirtualNodeHttpConnectionPool)
     (Maybe VirtualNodeHttpConnectionPool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualNodeConnectionPool' {Maybe VirtualNodeHttpConnectionPool
http :: Maybe VirtualNodeHttpConnectionPool
$sel:http:VirtualNodeConnectionPool' :: VirtualNodeConnectionPool -> Maybe VirtualNodeHttpConnectionPool
http} -> Maybe VirtualNodeHttpConnectionPool
http) (\s :: VirtualNodeConnectionPool
s@VirtualNodeConnectionPool' {} Maybe VirtualNodeHttpConnectionPool
a -> VirtualNodeConnectionPool
s {$sel:http:VirtualNodeConnectionPool' :: Maybe VirtualNodeHttpConnectionPool
http = Maybe VirtualNodeHttpConnectionPool
a} :: VirtualNodeConnectionPool)

instance Core.FromJSON VirtualNodeConnectionPool where
  parseJSON :: Value -> Parser VirtualNodeConnectionPool
parseJSON =
    String
-> (Object -> Parser VirtualNodeConnectionPool)
-> Value
-> Parser VirtualNodeConnectionPool
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VirtualNodeConnectionPool"
      ( \Object
x ->
          Maybe VirtualNodeHttp2ConnectionPool
-> Maybe VirtualNodeGrpcConnectionPool
-> Maybe VirtualNodeTcpConnectionPool
-> Maybe VirtualNodeHttpConnectionPool
-> VirtualNodeConnectionPool
VirtualNodeConnectionPool'
            (Maybe VirtualNodeHttp2ConnectionPool
 -> Maybe VirtualNodeGrpcConnectionPool
 -> Maybe VirtualNodeTcpConnectionPool
 -> Maybe VirtualNodeHttpConnectionPool
 -> VirtualNodeConnectionPool)
-> Parser (Maybe VirtualNodeHttp2ConnectionPool)
-> Parser
     (Maybe VirtualNodeGrpcConnectionPool
      -> Maybe VirtualNodeTcpConnectionPool
      -> Maybe VirtualNodeHttpConnectionPool
      -> VirtualNodeConnectionPool)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe VirtualNodeHttp2ConnectionPool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"http2")
            Parser
  (Maybe VirtualNodeGrpcConnectionPool
   -> Maybe VirtualNodeTcpConnectionPool
   -> Maybe VirtualNodeHttpConnectionPool
   -> VirtualNodeConnectionPool)
-> Parser (Maybe VirtualNodeGrpcConnectionPool)
-> Parser
     (Maybe VirtualNodeTcpConnectionPool
      -> Maybe VirtualNodeHttpConnectionPool
      -> VirtualNodeConnectionPool)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe VirtualNodeGrpcConnectionPool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"grpc")
            Parser
  (Maybe VirtualNodeTcpConnectionPool
   -> Maybe VirtualNodeHttpConnectionPool
   -> VirtualNodeConnectionPool)
-> Parser (Maybe VirtualNodeTcpConnectionPool)
-> Parser
     (Maybe VirtualNodeHttpConnectionPool -> VirtualNodeConnectionPool)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe VirtualNodeTcpConnectionPool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"tcp")
            Parser
  (Maybe VirtualNodeHttpConnectionPool -> VirtualNodeConnectionPool)
-> Parser (Maybe VirtualNodeHttpConnectionPool)
-> Parser VirtualNodeConnectionPool
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe VirtualNodeHttpConnectionPool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"http")
      )

instance Prelude.Hashable VirtualNodeConnectionPool

instance Prelude.NFData VirtualNodeConnectionPool

instance Core.ToJSON VirtualNodeConnectionPool where
  toJSON :: VirtualNodeConnectionPool -> Value
toJSON VirtualNodeConnectionPool' {Maybe VirtualNodeGrpcConnectionPool
Maybe VirtualNodeHttp2ConnectionPool
Maybe VirtualNodeHttpConnectionPool
Maybe VirtualNodeTcpConnectionPool
http :: Maybe VirtualNodeHttpConnectionPool
tcp :: Maybe VirtualNodeTcpConnectionPool
grpc :: Maybe VirtualNodeGrpcConnectionPool
http2 :: Maybe VirtualNodeHttp2ConnectionPool
$sel:http:VirtualNodeConnectionPool' :: VirtualNodeConnectionPool -> Maybe VirtualNodeHttpConnectionPool
$sel:tcp:VirtualNodeConnectionPool' :: VirtualNodeConnectionPool -> Maybe VirtualNodeTcpConnectionPool
$sel:grpc:VirtualNodeConnectionPool' :: VirtualNodeConnectionPool -> Maybe VirtualNodeGrpcConnectionPool
$sel:http2:VirtualNodeConnectionPool' :: VirtualNodeConnectionPool -> Maybe VirtualNodeHttp2ConnectionPool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"http2" Text -> VirtualNodeHttp2ConnectionPool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (VirtualNodeHttp2ConnectionPool -> Pair)
-> Maybe VirtualNodeHttp2ConnectionPool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VirtualNodeHttp2ConnectionPool
http2,
            (Text
"grpc" Text -> VirtualNodeGrpcConnectionPool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (VirtualNodeGrpcConnectionPool -> Pair)
-> Maybe VirtualNodeGrpcConnectionPool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VirtualNodeGrpcConnectionPool
grpc,
            (Text
"tcp" Text -> VirtualNodeTcpConnectionPool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (VirtualNodeTcpConnectionPool -> Pair)
-> Maybe VirtualNodeTcpConnectionPool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VirtualNodeTcpConnectionPool
tcp,
            (Text
"http" Text -> VirtualNodeHttpConnectionPool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (VirtualNodeHttpConnectionPool -> Pair)
-> Maybe VirtualNodeHttpConnectionPool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VirtualNodeHttpConnectionPool
http
          ]
      )